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 __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.operation_ids = PersistentDictionary(store) else: self.operation_ids = PersistentDictionary()
def __init__(self, host=DEFAULT_HOST, port=DEFAULT_PORT, ssl=True): """ Initialize a new instance of the EAGER service. Args: host Hostname to which the service should bind (Optional). Defaults to 0.0.0.0. port Port of the service (Optional). Default to 18444. ssl True if SSL should be engaged or False otherwise (Optional). Defaults to True. When engaged, this implementation expects to find the necessary SSL certificates in the /etc/appscale/certs directory. """ self.host = host self.port = port secret = None while True: try: secret = utils.get_secret(self.APPSCALE_DIR + 'secret.key') break except Exception: utils.log('Waiting for the secret key to become available') utils.sleep(5) utils.log('Found the secret set to: {0}'.format(secret)) SOAPpy.Config.simplify_objects = True if ssl: utils.log('Checking for the certificate and private key') cert = self.APPSCALE_DIR + 'certs/mycert.pem' key = self.APPSCALE_DIR + 'certs/mykey.pem' while True: if os.path.exists(cert) and os.path.exists(key): break else: utils.log('Waiting for certificates') utils.sleep(5) ssl_context = SSL.Context() ssl_context.load_cert(cert, key) self.server = SOAPpy.SOAPServer((host, port), ssl_context=ssl_context) else: self.server = SOAPpy.SOAPServer((host, port)) e = Eager() self.server.registerFunction(e.ping) self.server.registerFunction(e.validate_application_for_deployment) self.server.registerFunction(e.publish_api_list) self.server.registerFunction(e.add_policy) self.server.registerFunction(e.remove_policy) self.server.registerFunction(e.enable_policy) self.server.registerFunction(e.disable_policy) self.server.registerFunction(e.list_policy) self.server.registerFunction(e.info_policy) self.started = False
def __init__(self, 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. """ self.blocking = blocking self.secret = utils.get_secret() self.reservations = {} self.agent_factory = InfrastructureAgentFactory()
def __init__(self, host=DEFAULT_HOST, port=DEFAULT_PORT, ssl=True): """ Initialize a new instance of the infrastructure manager service. Args: host Hostname to which the service should bind (Optional). Defaults to 0.0.0.0. port Port of the service (Optional). Default to 17444. ssl True if SSL should be engaged or False otherwise (Optional). Defaults to True. When engaged, this implementation expects to find the necessary SSL certificates in the /etc/appscale/certs directory. """ self.host = host self.port = port secret = None while True: try: secret = utils.get_secret(self.APPSCALE_DIR + 'secret.key') break except Exception: logging.info('Waiting for the secret key to become available') utils.sleep(5) logging.info('Found the secret set to: {0}'.format(secret)) SOAPpy.Config.simplify_objects = True if ssl: logging.info('Checking for the certificate and private key') cert = self.APPSCALE_DIR + 'certs/mycert.pem' key = self.APPSCALE_DIR + 'certs/mykey.pem' while True: if os.path.exists(cert) and os.path.exists(key): break else: logging.info('Waiting for certificates') utils.sleep(5) ssl_context = SSL.Context() ssl_context.load_cert(cert, key) self.server = SOAPpy.SOAPServer((host, port), ssl_context=ssl_context) else: self.server = SOAPpy.SOAPServer((host, port)) parent_dir = os.path.dirname(os.path.realpath(sys.argv[0])) config_file = os.path.join(parent_dir, self.CONFIG_FILE) if os.path.exists(config_file): with open(config_file) as file_handle: params = json.load(file_handle) if params.has_key(PersistentStoreFactory.PARAM_STORE_TYPE): logging.info( 'Loading infrastructure manager configuration from ' + config_file) i = InfrastructureManager(params) else: i = InfrastructureManager() else: i = InfrastructureManager() self.server.registerFunction(i.describe_operation) self.server.registerFunction(i.run_instances) self.server.registerFunction(i.terminate_instances) self.server.registerFunction(i.attach_disk) system_manager = SystemManager() self.server.registerFunction(system_manager.get_cpu_usage) self.server.registerFunction(system_manager.get_disk_usage) self.server.registerFunction(system_manager.get_memory_usage) self.server.registerFunction(system_manager.get_service_summary) self.server.registerFunction(system_manager.get_swap_usage) self.server.registerFunction(system_manager.get_loadavg) self.started = False
def __init__(self): self.secret = utils.get_secret()
'specification' : spec } app = { 'name' : '{0}_app'.format(api_name), 'version' : '1.0', 'api_list' : [ api ], 'dependencies' : v, 'owner' : '*****@*****.**' } add_application(eager, secret, app) count += 1 def cleanup_string(s): s = string.translate(s.lower(), None, "'/ &+*@%\"<>!,#;^(){}|~=") return ''.join([i if ord(i) < 128 else '' for i in s]) if __name__ == '__main__': secret = utils.get_secret() eager = Eager() spec = load_template_specification() file_name = sys.argv[1] print 'Loading data set from {0}'.format(file_name) fh = open(file_name, 'r') lines = fh.readlines() fh.close() add_api_set(lines, eager, secret, spec) add_mashup_set(lines, eager, secret, spec)
def __init__(self): self.secret = utils.get_secret() parent_dir = os.path.dirname(os.path.realpath(sys.argv[0])) config_file = os.path.join(parent_dir, self.CONFIG_FILE) self.adaptor = utils.get_adaptor(config_file) self.policy_engine = policy_engine.PolicyEngine()
def __init__(self, host=DEFAULT_HOST, port=DEFAULT_PORT, ssl=True): """ Initialize a new instance of the infrastructure manager service. Args: host Hostname to which the service should bind (Optional). Defaults to 0.0.0.0. port Port of the service (Optional). Default to 17444. ssl True if SSL should be engaged or False otherwise (Optional). Defaults to True. When engaged, this implementation expects to find the necessary SSL certificates in the /etc/appscale/certs directory. """ self.host = host self.port = port secret = None while True: try: secret = utils.get_secret(self.APPSCALE_DIR + 'secret.key') break except Exception: logging.info('Waiting for the secret key to become available') utils.sleep(5) logging.info('Found the secret set to: {0}'.format(secret)) SOAPpy.Config.simplify_objects = True if ssl: logging.info('Checking for the certificate and private key') cert = self.APPSCALE_DIR + 'certs/mycert.pem' key = self.APPSCALE_DIR + 'certs/mykey.pem' while True: if os.path.exists(cert) and os.path.exists(key): break else: logging.info('Waiting for certificates') utils.sleep(5) ssl_context = SSL.Context() ssl_context.load_cert(cert, key) self.server = SOAPpy.SOAPServer((host, port), ssl_context=ssl_context) else: self.server = SOAPpy.SOAPServer((host, port)) parent_dir = os.path.dirname(os.path.realpath(sys.argv[0])) config_file = os.path.join(parent_dir, self.CONFIG_FILE) if os.path.exists(config_file): with open(config_file) as file_handle: params = json.load(file_handle) if params.has_key(PersistentStoreFactory.PARAM_STORE_TYPE): logging.info('Loading infrastructure manager configuration from ' + config_file) i = InfrastructureManager(params) else: i = InfrastructureManager() else: i = InfrastructureManager() self.server.registerFunction(i.describe_instances) self.server.registerFunction(i.run_instances) self.server.registerFunction(i.terminate_instances) self.server.registerFunction(i.attach_disk) system_manager = SystemManager() self.server.registerFunction(system_manager.get_cpu_usage) self.server.registerFunction(system_manager.get_disk_usage) self.server.registerFunction(system_manager.get_memory_usage) self.server.registerFunction(system_manager.get_service_summary) self.server.registerFunction(system_manager.get_swap_usage) self.server.registerFunction(system_manager.get_loadavg) self.started = False