Package haizea :: Package core :: Module configfile
[hide private]
[frames] | no frames]

Source Code for Module haizea.core.configfile

  1  # -------------------------------------------------------------------------- # 
  2  # Copyright 2006-2009, University of Chicago                                 # 
  3  # Copyright 2008-2009, Distributed Systems Architecture Group, Universidad   # 
  4  # Complutense de Madrid (dsa-research.org)                                   # 
  5  #                                                                            # 
  6  # Licensed under the Apache License, Version 2.0 (the "License"); you may    # 
  7  # not use this file except in compliance with the License. You may obtain    # 
  8  # a copy of the License at                                                   # 
  9  #                                                                            # 
 10  # http://www.apache.org/licenses/LICENSE-2.0                                 # 
 11  #                                                                            # 
 12  # Unless required by applicable law or agreed to in writing, software        # 
 13  # distributed under the License is distributed on an "AS IS" BASIS,          # 
 14  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   # 
 15  # See the License for the specific language governing permissions and        # 
 16  # limitations under the License.                                             # 
 17  # -------------------------------------------------------------------------- # 
 18   
 19  from haizea.common.config import ConfigException, Section, Option, Config, OPTTYPE_INT, OPTTYPE_FLOAT, OPTTYPE_STRING, OPTTYPE_BOOLEAN, OPTTYPE_DATETIME, OPTTYPE_TIMEDELTA  
 20  from haizea.common.utils import generate_config_name 
 21  import haizea.common.constants as constants 
 22  import haizea.common.defaults as defaults 
 23  import sys 
 24  from mx.DateTime import TimeDelta 
 25  import ConfigParser 
 26   
27 -class HaizeaConfig(Config):
28 29 sections = [] 30 31 # ============================= # 32 # # 33 # GENERAL OPTIONS # 34 # # 35 # ============================= # 36 37 general = Section("general", required=True, 38 doc = "This section is used for general options affecting Haizea as a whole.") 39 general.options = \ 40 [ 41 Option(name = "loglevel", 42 getter = "loglevel", 43 type = OPTTYPE_STRING, 44 required = False, 45 default = "INFO", 46 valid = ["STATUS","INFO","DEBUG","VDEBUG"], 47 doc = """ 48 Controls the level (and amount) of 49 log messages. Valid values are: 50 51 - STATUS: Only print status messages 52 - INFO: Slightly more verbose that STATUS 53 - DEBUG: Prints information useful for debugging the scheduler. 54 - VDEBUG: Prints very verbose information 55 on the scheduler's internal data structures. Use only 56 for short runs. 57 """), 58 59 Option(name = "logfile", 60 getter = "logfile", 61 type = OPTTYPE_STRING, 62 required = False, 63 default = "/var/tmp/haizea.log", 64 doc = """ 65 When running Haizea as a daemon, this option specifies the file 66 that log messages should be written to. 67 """), 68 69 Option(name = "mode", 70 getter = "mode", 71 type = OPTTYPE_STRING, 72 required = True, 73 valid = ["simulated","opennebula"], 74 doc = """ 75 Sets the mode the scheduler will run in. 76 Currently the only valid values are "simulated" and 77 "opennebula". The "simulated" mode expects lease 78 requests to be provided through a trace file, and 79 all enactment is simulated. The "opennebula" mode 80 interacts with the OpenNebula virtual infrastructure 81 manager (http://www.opennebula.org/) to obtain lease 82 requests and to do enactment on physical resources. 83 """), 84 85 Option(name = "lease-preparation", 86 getter = "lease-preparation", 87 type = OPTTYPE_STRING, 88 required = False, 89 default = constants.PREPARATION_UNMANAGED, 90 valid = [constants.PREPARATION_UNMANAGED, 91 constants.PREPARATION_TRANSFER], 92 doc = """ 93 Sets how the scheduler will handle the 94 preparation overhead of leases. Valid values are: 95 96 - unmanaged: The scheduler can assume that there 97 is no deployment overhead, or that some 98 other entity is taking care of it (e.g., one 99 of the enactment backends) 100 - imagetransfer: A disk image has to be transferred 101 from a repository node before the lease can start. 102 """), 103 104 Option(name = "lease-failure-handling", 105 getter = "lease-failure-handling", 106 type = OPTTYPE_STRING, 107 required = False, 108 default = constants.ONFAILURE_CANCEL, 109 valid = [constants.ONFAILURE_CANCEL, 110 constants.ONFAILURE_EXIT, 111 constants.ONFAILURE_EXIT_RAISE], 112 doc = """ 113 Sets how the scheduler will handle a failure in 114 a lease. Valid values are: 115 116 - cancel: The lease is cancelled and marked as "FAILED" 117 - exit: Haizea will exit cleanly, printing relevant debugging 118 information to its log. 119 - exit-raise: Haizea will exit by raising an exception. This is 120 useful for debugging, as IDEs will recognize this as an exception 121 and will facilitate debugging it. 122 """), 123 124 Option(name = "persistence-file", 125 getter = "persistence-file", 126 type = OPTTYPE_STRING, 127 required = False, 128 default = defaults.PERSISTENCE_LOCATION, 129 doc = """ 130 This is the file where lease information, along with some 131 additional scheduling information, is persisted to. If set 132 to "none", no information will be persisted to disk, and 133 Haizea will run entirely in-memory (this is advisable 134 when running in simulation, as persisting to disk adds 135 considerable overhead, compared to running in-memory). 136 """) 137 138 ] 139 140 sections.append(general) 141 142 # ============================= # 143 # # 144 # SCHEDULING OPTIONS # 145 # # 146 # ============================= # 147 148 scheduling = Section("scheduling", required=True, 149 doc = "The options in this section control how Haizea schedules leases.") 150 scheduling.options = \ 151 [ 152 Option(name = "mapper", 153 getter = "mapper", 154 type = OPTTYPE_STRING, 155 required = False, 156 default = "greedy", 157 doc = """ 158 VM-to-physical node mapping algorithm used by Haizea. There is currently 159 only one mapper available (the greedy mapper). 160 """), 161 162 Option(name = "policy-admission", 163 getter = "policy.admission", 164 type = OPTTYPE_STRING, 165 required = False, 166 default = "accept-all", 167 doc = """ 168 Lease admission policy. This controls what leases are accepted by Haizea. 169 Take into account that this decision takes place before Haizea even 170 attempts to schedule the lease (so, you can think of lease admission as 171 "eligibility to be scheduled"). 172 173 There are two built-in policies: 174 175 - accept-all: Accept all leases. 176 - no-ARs: Accept all leases except advance reservations. 177 178 See the Haizea documentation for details on how to write your own 179 policies. 180 """), 181 182 Option(name = "policy-preemption", 183 getter = "policy.preemption", 184 type = OPTTYPE_STRING, 185 required = False, 186 default = "no-preemption", 187 doc = """ 188 Lease preemption policy. Determines what leases can be preempted. There 189 are two built-in policies: 190 191 - no-preemption: Do not allow any preemptions 192 - ar-preempts-everything: Allow all ARs to preempt other leases. 193 194 See the Haizea documentation for details on how to write your own 195 policies. 196 """), 197 198 Option(name = "policy-host-selection", 199 getter = "policy.host-selection", 200 type = OPTTYPE_STRING, 201 required = False, 202 default = "greedy", 203 doc = """ 204 Physical host selection policy. controls how Haizea chooses what physical hosts 205 to map VMs to. This option is closely related to the mapper options 206 (if the greedy mapper is used, then the greedy host selection policy 207 should be used, or unexpected results will happen). 208 209 The two built-in policies are: 210 - no-policy: Choose nodes arbitrarily 211 - greedy: Apply a greedy policy that tries to minimize the number 212 of preemptions. 213 214 See the Haizea documentation for details on how to write your own 215 policies. 216 """), 217 218 Option(name = "wakeup-interval", 219 getter = "wakeup-interval", 220 type = OPTTYPE_TIMEDELTA, 221 required = False, 222 default = TimeDelta(seconds=60), 223 doc = """ 224 Interval at which Haizea will wake up 225 to manage resources and process pending requests. 226 This option is not used when using a simulated clock, 227 since the clock will skip directly to the time where an 228 event is happening. 229 """), 230 231 Option(name = "backfilling", 232 getter = "backfilling", 233 type = OPTTYPE_STRING, 234 required = False, 235 default = None, 236 valid = [constants.BACKFILLING_OFF, 237 constants.BACKFILLING_AGGRESSIVE, 238 constants.BACKFILLING_CONSERVATIVE, 239 constants.BACKFILLING_INTERMEDIATE], 240 doc = """ 241 Backfilling algorithm to use. Valid values are: 242 243 - off: don't do backfilling 244 - aggressive: at most 1 reservation in the future 245 - conservative: unlimited reservations in the future 246 - intermediate: N reservations in the future (N is specified 247 in the backfilling-reservations option) 248 """), 249 250 Option(name = "backfilling-reservations", 251 getter = "backfilling-reservations", 252 type = OPTTYPE_INT, 253 required = False, 254 required_if = [(("scheduling","backfilling"),constants.BACKFILLING_INTERMEDIATE)], 255 doc = """ 256 Number of future reservations to allow when 257 using the "intermediate" backfilling option. 258 """), 259 260 Option(name = "suspension", 261 getter = "suspension", 262 type = OPTTYPE_STRING, 263 required = True, 264 valid = [constants.SUSPENSION_NONE, 265 constants.SUSPENSION_SERIAL, 266 constants.SUSPENSION_ALL], 267 doc = """ 268 Specifies what can be suspended. Valid values are: 269 270 - none: suspension is never allowed 271 - serial-only: only 1-node leases can be suspended 272 - all: any lease can be suspended 273 """), 274 275 Option(name = "suspend-rate", 276 getter = "suspend-rate", 277 type = OPTTYPE_FLOAT, 278 required = True, 279 doc = """ 280 Rate at which VMs are assumed to suspend (in MB of 281 memory per second) 282 """), 283 284 Option(name = "resume-rate", 285 getter = "resume-rate", 286 type = OPTTYPE_FLOAT, 287 required = True, 288 doc = """ 289 Rate at which VMs are assumed to resume (in MB of 290 memory per second) 291 """), 292 293 Option(name = "suspendresume-exclusion", 294 getter = "suspendresume-exclusion", 295 type = OPTTYPE_STRING, 296 required = False, 297 default = constants.SUSPRES_EXCLUSION_LOCAL, 298 valid = [constants.SUSPRES_EXCLUSION_LOCAL, 299 constants.SUSPRES_EXCLUSION_GLOBAL], 300 doc = """ 301 When suspending or resuming a VM, the VM's memory is dumped to a 302 file on disk. To correctly estimate the time required to suspend 303 a lease with multiple VMs, Haizea makes sure that no two 304 suspensions/resumptions happen at the same time (e.g., if eight 305 memory files were being saved at the same time to disk, the disk's 306 performance would be reduced in a way that is not as easy to estimate 307 as if only one file were being saved at a time). 308 309 Depending on whether the files are being saved to/read from a global 310 or local filesystem, this exclusion can be either global or local. 311 """), 312 313 Option(name = "scheduling-threshold-factor", 314 getter = "scheduling-threshold-factor", 315 type = OPTTYPE_INT, 316 required = False, 317 default = 1, 318 doc = """ 319 To avoid thrashing, Haizea will not schedule a lease unless all overheads 320 can be correctly scheduled (which includes image transfers, suspensions, etc.). 321 However, this can still result in situations where a lease is prepared, 322 and then immediately suspended because of a blocking lease in the future. 323 The scheduling threshold factor can be used to specify that a lease must 324 not be scheduled unless it is guaranteed to run for a minimum amount of 325 time (the rationale behind this is that you ideally don't want leases 326 to be scheduled if they're not going to be active for at least as much time 327 as was spent in overheads). 328 329 The default value is 1, meaning that the lease will be active for at least 330 as much time T as was spent on overheads (e.g., if preparing the lease requires 331 60 seconds, and we know that it will have to be suspended, requiring 30 seconds, 332 Haizea won't schedule the lease unless it can run for at least 90 minutes). 333 In other words, a scheduling factor of F required a minimum duration of 334 F*T. A value of 0 could lead to thrashing, since Haizea could end up with 335 situations where a lease starts and immediately gets suspended. 336 """), 337 338 Option(name = "override-suspend-time", 339 getter = "override-suspend-time", 340 type = OPTTYPE_INT, 341 required = False, 342 default = None, 343 doc = """ 344 Overrides the time it takes to suspend a VM to a fixed value 345 (i.e., not computed based on amount of memory, enactment overhead, etc.) 346 """), 347 348 Option(name = "override-resume-time", 349 getter = "override-resume-time", 350 type = OPTTYPE_INT, 351 required = False, 352 default = None, 353 doc = """ 354 Overrides the time it takes to suspend a VM to a fixed value 355 (i.e., not computed based on amount of memory, enactment overhead, etc.) 356 """), 357 358 Option(name = "force-scheduling-threshold", 359 getter = "force-scheduling-threshold", 360 type = OPTTYPE_TIMEDELTA, 361 required = False, 362 doc = """ 363 This option can be used to force a specific scheduling threshold time 364 to be used, instead of calculating one based on overheads. 365 """), 366 367 Option(name = "migration", 368 getter = "migration", 369 type = OPTTYPE_STRING, 370 required = False, 371 default = constants.MIGRATE_NO, 372 valid = [constants.MIGRATE_NO, 373 constants.MIGRATE_YES, 374 constants.MIGRATE_YES_NOTRANSFER], 375 doc = """ 376 Specifies whether leases can be migrated from one 377 physical node to another. Valid values are: 378 379 - no 380 - yes 381 - yes-notransfer: migration is performed without 382 transferring any files. 383 """), 384 385 Option(name = "non-schedulable-interval", 386 getter = "non-schedulable-interval", 387 type = OPTTYPE_TIMEDELTA, 388 required = False, 389 default = TimeDelta(seconds=10), 390 doc = """ 391 The minimum amount of time that must pass between 392 when a request is scheduled to when it can actually start. 393 The default should be good for most configurations, but 394 may need to be increased if you're dealing with exceptionally 395 high loads. 396 """), 397 398 Option(name = "shutdown-time", 399 getter = "shutdown-time", 400 type = OPTTYPE_TIMEDELTA, 401 required = False, 402 default = TimeDelta(seconds=0), 403 doc = """ 404 The amount of time that will be allocated for a VM to shutdown. 405 When running in OpenNebula mode, it is advisable to set this to 406 a few seconds, so no operation gets scheduled right when a 407 VM is shutting down. The most common scenario is that a VM 408 will start resuming right when another VM shuts down. However, 409 since both these activities involve I/O, it can delay the resume 410 operation and affect Haizea's estimation of how long the resume 411 will take. 412 """), 413 414 Option(name = "enactment-overhead", 415 getter = "enactment-overhead", 416 type = OPTTYPE_TIMEDELTA, 417 required = False, 418 default = TimeDelta(seconds=0), 419 doc = """ 420 The amount of time that is required to send 421 an enactment command. This value will affect suspend/resume 422 estimations and, in OpenNebula mode, will force a pause 423 of this much time between suspend/resume enactment 424 commands. When suspending/resuming many VMs at the same time 425 (which is likely to happen if suspendresume-exclusion is set 426 to "local"), it will take OpenNebula 1-2 seconds to process 427 each command (this is a small amount of time, but if 32 VMs 428 are being suspended at the same time, on in each physical node, 429 this time can compound up to 32-64 seconds, which has to be 430 taken into account when estimating when to start a suspend 431 operation that must be completed before another lease starts). 432 """) 433 434 ] 435 sections.append(scheduling) 436 437 # ============================= # 438 # # 439 # SIMULATION OPTIONS # 440 # # 441 # ============================= # 442 443 simulation = Section("simulation", required=False, 444 required_if = [(("general","mode"),"simulated")], 445 doc = "This section is used to specify options when Haizea runs in simulation" ) 446 simulation.options = \ 447 [ 448 Option(name = "clock", 449 getter = "clock", 450 type = OPTTYPE_STRING, 451 required = False, 452 default = constants.CLOCK_REAL, 453 valid = [constants.CLOCK_REAL, 454 constants.CLOCK_SIMULATED], 455 doc = """ 456 Type of clock to use in simulation: 457 458 - simulated: A simulated clock that fastforwards through 459 time. Can only use the tracefile request 460 frontend 461 - real: A real clock is used, but simulated resources and 462 enactment actions are used. Can only use the RPC 463 request frontend. 464 """), 465 466 Option(name = "starttime", 467 getter = "starttime", 468 type = OPTTYPE_DATETIME, 469 required = False, 470 required_if = [(("simulation","clock"),constants.CLOCK_SIMULATED)], 471 doc = """ 472 Time at which simulated clock will start. 473 """), 474 475 Option(name = "resources", 476 getter = "simul.resources", 477 type = OPTTYPE_STRING, 478 required = True, 479 doc = """ 480 Simulated resources. This option can take two values, 481 "in-tracefile" (which means that the description of 482 the simulated site is in the tracefile) or a string 483 specifying a site with homogeneous resources. 484 The format is: 485 486 <numnodes> [ <resource_type>:<resource_quantity>]+ 487 488 For example, "4 CPU:100 Memory:1024" describes a site 489 with four nodes, each with one CPU and 1024 MB of memory. 490 """), 491 492 Option(name = "imagetransfer-bandwidth", 493 getter = "imagetransfer-bandwidth", 494 type = OPTTYPE_INT, 495 required = True, 496 doc = """ 497 Bandwidth (in Mbps) available for image transfers. 498 This would correspond to the outbound network bandwidth of the 499 node where the images are stored. 500 """), 501 502 Option(name = "stop-when", 503 getter = "stop-when", 504 type = OPTTYPE_STRING, 505 required = False, 506 default = constants.STOPWHEN_ALLDONE, 507 valid = [constants.STOPWHEN_ALLDONE, 508 constants.STOPWHEN_BESUBMITTED, 509 constants.STOPWHEN_BEDONE], 510 doc = """ 511 When using the simulated clock, this specifies when the 512 simulation must end. Valid options are: 513 514 - all-leases-done: All requested leases have been completed 515 and there are no queued/pending requests. 516 - besteffort-submitted: When all best-effort leases have been 517 submitted. 518 - besteffort-done: When all best-effort leases have been 519 completed. 520 """), 521 522 Option(name = "status-message-interval", 523 getter = "status-message-interval", 524 type = OPTTYPE_INT, 525 required = False, 526 default = None, 527 doc = """ 528 If specified, the simulated clock will print a status 529 message with some basic statistics. This is useful to keep track 530 of long simulations. The interval is specified in minutes. 531 """) 532 533 ] 534 sections.append(simulation) 535 536 537 # ============================= # 538 # # 539 # ACCOUNTING OPTIONS # 540 # # 541 # ============================= # 542 543 accounting = Section("accounting", required=True, 544 doc = "Haizea can collect information while running, and save that information to a file for off-line processing. This section includes options controlling this feature.") 545 546 accounting.options = \ 547 [ 548 Option(name = "datafile", 549 getter = "datafile", 550 type = OPTTYPE_STRING, 551 required = False, 552 default = None, 553 doc = """ 554 This is the file where statistics on 555 the scheduler's run will be saved to (waiting time of leases, 556 utilization data, etc.). If omitted, no data will be saved. 557 """), 558 559 Option(name = "probes", 560 getter = "accounting-probes", 561 type = OPTTYPE_STRING, 562 required = False, 563 doc = """ 564 Accounting probes. 565 566 There are four built-in probes: 567 568 - AR: Collects information on AR leases. 569 - best-effort: Collects information on best effort leases. 570 - immediate: Collects information immediate leases. 571 - utilization: Collects information on resource utilization. 572 573 See the Haizea documentation for details on how to write your 574 own accounting probes. 575 576 """), 577 578 Option(name = "attributes", 579 getter = "attributes", 580 type = OPTTYPE_STRING, 581 required = False, 582 doc = """ 583 This option is used internally by Haizea when using 584 multiconfiguration files. See the multiconfiguration 585 documentation for more details. 586 """) 587 ] 588 589 sections.append(accounting) 590 591 # ============================= # 592 # # 593 # DEPLOYMENT OPTIONS # 594 # (w/ image transfers) # 595 # # 596 # ============================= # 597 598 imgtransfer = Section("deploy-imagetransfer", required=False, 599 required_if = [(("general","lease-deployment"),"imagetransfer")], 600 doc = """ 601 When lease deployment with disk image transfers is selected, 602 this section is used to control image deployment parameters.""") 603 imgtransfer.options = \ 604 [ 605 Option(name = "transfer-mechanism", 606 getter = "transfer-mechanism", 607 type = OPTTYPE_STRING, 608 required = True, 609 valid = [constants.TRANSFER_UNICAST, 610 constants.TRANSFER_MULTICAST], 611 doc = """ 612 Specifies how disk images are transferred. Valid values are: 613 614 - unicast: A disk image can be transferred to just one node at a time 615 - multicast: A disk image can be multicast to multiple nodes at 616 the same time. 617 """), 618 619 Option(name = "avoid-redundant-transfers", 620 getter = "avoid-redundant-transfers", 621 type = OPTTYPE_BOOLEAN, 622 required = False, 623 default = True, 624 doc = """ 625 Specifies whether the scheduler should take steps to 626 detect and avoid redundant transfers (e.g., if two leases are 627 scheduled on the same node, and they both require the same disk 628 image, don't transfer the image twice; allow one to "piggyback" 629 on the other). There is generally no reason to set this option 630 to False. 631 """), 632 633 Option(name = "force-imagetransfer-time", 634 getter = "force-imagetransfer-time", 635 type = OPTTYPE_TIMEDELTA, 636 required = False, 637 doc = """ 638 Forces the image transfer time to a specific amount. 639 This options is intended for testing purposes. 640 """), 641 642 Option(name = "diskimage-reuse", 643 getter = "diskimage-reuse", 644 type = OPTTYPE_STRING, 645 required = False, 646 required_if = None, 647 default = constants.REUSE_NONE, 648 valid = [constants.REUSE_NONE, 649 constants.REUSE_IMAGECACHES], 650 doc = """ 651 Specifies whether disk image caches should be created 652 on the nodes, so the scheduler can reduce the number of transfers 653 by reusing images. Valid values are: 654 655 - none: No image reuse 656 - image-caches: Use image caching algorithm described in Haizea 657 publications 658 """), 659 660 Option(name = "diskimage-cache-size", 661 getter = "diskimage-cache-size", 662 type = OPTTYPE_INT, 663 required = False, 664 required_if = [(("deploy-imagetransfer","diskimage-reuse"),True)], 665 doc = """ 666 Specifies the size (in MB) of the disk image cache on 667 each physical node. 668 """) 669 ] 670 sections.append(imgtransfer) 671 672 # ============================= # 673 # # 674 # TRACEFILE OPTIONS # 675 # # 676 # ============================= # 677 678 tracefile = Section("tracefile", required=False, 679 doc=""" 680 When reading in requests from a tracefile, this section is used 681 to specify the tracefile and other parameters.""") 682 tracefile.options = \ 683 [ 684 Option(name = "tracefile", 685 getter = "tracefile", 686 type = OPTTYPE_STRING, 687 required = True, 688 doc = """ 689 Path to tracefile to use. 690 """), 691 692 Option(name = "imagefile", 693 getter = "imagefile", 694 type = OPTTYPE_STRING, 695 required = False, 696 doc = """ 697 Path to list of images to append to lease requests. 698 If omitted, the images in the tracefile are used. 699 """), 700 701 Option(name = "injectionfile", 702 getter = "injectionfile", 703 type = OPTTYPE_STRING, 704 required = False, 705 doc = """ 706 Path to file with leases to "inject" into the tracefile. 707 """), 708 709 Option(name = "runtime-slowdown-overhead", 710 getter = "runtime-slowdown-overhead", 711 type = OPTTYPE_FLOAT, 712 required = False, 713 default = 0, 714 doc = """ 715 Adds a runtime overhead (in %) to the lease duration. 716 """), 717 718 Option(name = "add-overhead", 719 getter = "add-overhead", 720 type = OPTTYPE_STRING, 721 required = False, 722 default = constants.RUNTIMEOVERHEAD_NONE, 723 valid = [constants.RUNTIMEOVERHEAD_NONE, 724 constants.RUNTIMEOVERHEAD_ALL, 725 constants.RUNTIMEOVERHEAD_BE], 726 doc = """ 727 Specifies what leases will have a runtime overhead added: 728 729 - none: No runtime overhead must be added. 730 - besteffort: Add only to best-effort leases 731 - all: Add runtime overhead to all leases 732 """), 733 734 Option(name = "bootshutdown-overhead", 735 getter = "bootshutdown-overhead", 736 type = OPTTYPE_TIMEDELTA, 737 required = False, 738 default = TimeDelta(seconds=0), 739 doc = """ 740 Specifies how many seconds will be alloted to 741 boot and shutdown of the lease. 742 """), 743 744 Option(name = "override-memory", 745 getter = "override-memory", 746 type = OPTTYPE_INT, 747 required = False, 748 default = constants.NO_MEMORY_OVERRIDE, 749 doc = """ 750 Overrides memory requirements specified in tracefile. 751 """), 752 ] 753 sections.append(tracefile) 754 755 # ============================= # 756 # # 757 # OPENNEBULA OPTIONS # 758 # # 759 # ============================= # 760 761 opennebula = Section("opennebula", required=False, 762 required_if = [(("general","mode"),"opennebula")], 763 doc = """ 764 This section is used to specify OpenNebula parameters, 765 necessary when using Haizea as an OpenNebula scheduling backend.""") 766 opennebula.options = \ 767 [ 768 Option(name = "host", 769 getter = "one.host", 770 type = OPTTYPE_STRING, 771 required = True, 772 doc = """ 773 Host where OpenNebula is running. 774 Typically, OpenNebula and Haizea will be installed 775 on the same host, so the following option should be 776 set to 'localhost'. If they're on different hosts, 777 make sure you modify this option accordingly. 778 """), 779 780 Option(name = "port", 781 getter = "one.port", 782 type = OPTTYPE_INT, 783 required = False, 784 default = defaults.OPENNEBULA_RPC_PORT, 785 doc = """ 786 TCP port of OpenNebula's XML RPC server 787 """), 788 789 Option(name = "stop-when-no-more-leases", 790 getter = "stop-when-no-more-leases", 791 type = OPTTYPE_BOOLEAN, 792 required = False, 793 default = False, 794 doc = """ 795 This option is useful for testing and running experiments. 796 If set to True, Haizea will stop when there are no more leases 797 to process (which allows you to tun Haizea and OpenNebula unattended, 798 and count on it stopping when there are no more leases to process). 799 For now, this only makes sense if you're seeding Haizea with requests from 800 the start (otherwise, it will start and immediately stop). 801 """), 802 803 Option(name = "dry-run", 804 getter = "dry-run", 805 type = OPTTYPE_BOOLEAN, 806 required = False, 807 default = False, 808 doc = """ 809 This option is useful for testing. 810 If set to True, Haizea will fast-forward through time (note that this is 811 different that using the simulated clock, which has to be used with a tracefile; 812 with an Haizea/OpenNebula dry run, you will have to seed OpenNebula with requests 813 before starting Haizea). You will generally want to set stop-when-no-more-leases 814 when doing a dry-run. 815 816 IMPORTANT: Haizea will still send out enactment commands to OpenNebula. Make 817 sure you replace onevm with a dummy command that does nothing (or that reacts 818 in some way you want to test; e.g., by emulating a deployment failure, etc.) 819 """), 820 821 ] 822 sections.append(opennebula) 823
824 - def __init__(self, config):
825 Config.__init__(self, config, self.sections) 826 827 self.attrs = {} 828 if self._options["attributes"] != None: 829 attrs = self._options["attributes"].split(",") 830 for attr in attrs: 831 (k,v) = attr.split("=") 832 self.attrs[k] = v
833 834
835 - def get_attr(self, attr):
836 return self.attrs[attr]
837
838 - def get_attrs(self):
839 return self.attrs.keys()
840 841
842 -class HaizeaMultiConfig(Config):
843 844 MULTI_SEC = "multi" 845 COMMON_SEC = "common" 846 TRACEDIR_OPT = "tracedir" 847 TRACEFILES_OPT = "tracefiles" 848 INJDIR_OPT = "injectiondir" 849 INJFILES_OPT = "injectionfiles" 850 DATADIR_OPT = "datadir" 851
852 - def __init__(self, config):
853 # TODO: Define "multi" section as a Section object 854 Config.__init__(self, config, [])
855
856 - def get_profiles(self):
857 sections = set([s.split(":")[0] for s in self.config.sections()]) 858 # Remove multi and common sections 859 sections.difference_update([self.COMMON_SEC, self.MULTI_SEC]) 860 return list(sections)
861
862 - def get_trace_files(self):
863 dir = self.config.get(self.MULTI_SEC, self.TRACEDIR_OPT) 864 traces = self.config.get(self.MULTI_SEC, self.TRACEFILES_OPT).split() 865 return [dir + "/" + t for t in traces]
866
867 - def get_inject_files(self):
868 dir = self.config.get(self.MULTI_SEC, self.INJDIR_OPT) 869 inj = self.config.get(self.MULTI_SEC, self.INJFILES_OPT).split() 870 inj = [dir + "/" + i for i in inj] 871 inj.append(None) 872 return inj
873
874 - def get_configs(self):
875 profiles = self.get_profiles() 876 tracefiles = self.get_trace_files() 877 injectfiles = self.get_inject_files() 878 879 configs = [] 880 for profile in profiles: 881 for tracefile in tracefiles: 882 for injectfile in injectfiles: 883 profileconfig = ConfigParser.ConfigParser() 884 commonsections = [s for s in self.config.sections() if s.startswith("common:")] 885 profilesections = [s for s in self.config.sections() if s.startswith(profile +":")] 886 sections = commonsections + profilesections 887 for s in sections: 888 s_noprefix = s.split(":")[1] 889 items = self.config.items(s) 890 if not profileconfig.has_section(s_noprefix): 891 profileconfig.add_section(s_noprefix) 892 for item in items: 893 profileconfig.set(s_noprefix, item[0], item[1]) 894 895 # The tracefile section may have not been created 896 if not profileconfig.has_section("tracefile"): 897 profileconfig.add_section("tracefile") 898 899 # Add tracefile option 900 profileconfig.set("tracefile", "tracefile", tracefile) 901 902 # Add injected file option 903 if injectfile != None: 904 profileconfig.set("tracefile", "injectionfile", injectfile) 905 906 # Add datafile option 907 datadir = self.config.get(self.MULTI_SEC, self.DATADIR_OPT) 908 datafilename = generate_config_name(profile, tracefile, injectfile) 909 datafile = datadir + "/" + datafilename + ".dat" 910 # The accounting section may have not been created 911 if not profileconfig.has_section("accounting"): 912 profileconfig.add_section("accounting") 913 profileconfig.set("accounting", "datafile", datafile) 914 915 # Set "attributes" option (only used internally) 916 attrs = {"profile":profile,"tracefile":tracefile,"injectfile":injectfile} 917 # TODO: Load additional attributes from trace/injfiles 918 attrs_str = ",".join(["%s=%s" % (k,v) for (k,v) in attrs.items()]) 919 if profileconfig.has_option("accounting", "attributes"): 920 attrs_str += ",%s" % profileconfig.get("general", "attributes") 921 profileconfig.set("accounting", "attributes", attrs_str) 922 923 try: 924 c = HaizeaConfig(profileconfig) 925 except ConfigException, msg: 926 print >> sys.stderr, "Error in configuration file:" 927 print >> sys.stderr, msg 928 exit(1) 929 configs.append(c) 930 931 return configs
932