def __init__(self, params=None, blocking=False): """ Create a new InfrastructureManager instance. This constructor accepts an optional boolean parameter which decides whether the InfrastructureManager instance should operate in blocking mode or not. A blocking InfrastructureManager does not return until each requested run/terminate operation is complete. This mode is useful for testing and verification purposes. In a real-world deployment it's advisable to instantiate the InfrastructureManager in the non-blocking mode as run/terminate operations could take a rather long time to complete. By default InfrastructureManager instances are created in the non-blocking mode. Args params A dictionary of parameters. Optional parameter. If specified it must at least include the 'store_type' parameter. blocking Whether to operate in blocking mode or not. Optional and defaults to false. """ self.blocking = blocking # self.secret = utils.get_secret() self.agent_factory = InfrastructureAgentFactory() if params is not None: store_factory = PersistentStoreFactory() store = store_factory.create_store(params) self.reservations = PersistentDictionary(store) else: self.reservations = PersistentDictionary()
def test_create_agent(self): factory = InfrastructureAgentFactory() agent = factory.create_agent('ec2') self.assertEquals(type(agent), type(EC2Agent())) agent = factory.create_agent('euca') self.assertEquals(type(agent), type(EucalyptusAgent())) try: factory.create_agent('bogus') self.fail('No exception thrown for invalid infrastructure') except NameError: pass except Exception: self.fail('Unexpected exception thrown for invalid infrastructure')