def start(self): # Build model - This has to be executed at start not in init # The setup routine creates a Controller instance and then # calculates and establishes the initial placement. If the # model was initialized in the init method it would aquire the # infrastructure state before the calculated initial placement # was established self.model_initialize() # Create notification handler self.handler = MetricHandler(self.model) # Decides whether a simulation or a real # control system is run if config.PRODUCTION: # Connect with sonar to receive metric readings # This will start a new service in a separate thread # The controller and simulation run single threaded by message pump import connector connector.connect_sonar(self.model, self.handler) else: # Use the workload driver to simulate Sonar import driver driver = driver.Driver(self.scoreboard, self.pump, self.model, self.handler) driver.start() # Start controller self.strategy.dump() self.strategy.start() # Start message pump self.pump.start() self.pump.join()
def start(self): # Build model - This has to be executed at start not in init # The setup routine creates a Controller instance and then # calculates and establishes the initial placement. # # The model initialize method queries the libvirt for the # current domain placement. This placement is established after # creating a Controller instance and its __imit__ method call. # # Hence, if the model was initialized in the init method it would # acquire the infrastructure state before the calculated initial # placement was established if not self.__model_initialize(): print 'Exiting because of error in initial placement' return # Exit after intial placement if conf.EXIT_AFTER_INITIAL_PLACEMENT: return # Production mode connects with sonar if configuration.PRODUCTION: print 'RUNNING IN PRODUCTION MODE' if conf.is_start_reallocation(): # Connect with Sonar for metric readings import connector connector.connect_sonar(self.model, self.handler) # Start reallocation strategy self.strategy_reallocation.dump() self.strategy_reallocation.start() if conf.is_start_placement(): # Create domain provisioner (the concrete one in this case) pv = domain_provision.ConcreteProvisioning(self.model, self.pump, self.strategy_placement) # Start infrastructure service with a reference to the provisioner import infrastructure_service infrastructure_service.start(pv) else: print 'RUNNING IN SIMULATION MODE' # Start load driver that simulations Sonar import driver_load driver_load = driver_load.Driver(self.scoreboard, self.pump, self.model, self.handler, not conf.is_start_placement()) driver_load.start() if conf.is_start_reallocation(): print 'Starting reallocation strategy...' # Start reallocation strategy self.strategy_reallocation.dump() self.strategy_reallocation.start() if conf.is_start_placement(): print 'Starting placement strategy...' # Create domain provisioner (the model one in this case) pv = domain_provision.Provisioning(self.model, self.pump, self.strategy_placement) # Start domain driver that simulates Rain domain provisioning import driver_domains driver_domains = driver_domains.Driver(self.pump, self.scoreboard, pv) driver_domains.start() # Update scoreboard self.scoreboard.start()