diff --git a/conpaas-director/cpsdirector/iaas/controller.py b/conpaas-director/cpsdirector/iaas/controller.py index 81c5012d..5f3c5afd 100644 --- a/conpaas-director/cpsdirector/iaas/controller.py +++ b/conpaas-director/cpsdirector/iaas/controller.py @@ -22,6 +22,7 @@ from ConfigParser import ConfigParser from cpsdirector.common import config_parser as default_config_parser + class Controller(object): def __init__(self): @@ -99,11 +100,6 @@ def _set_clouds(self): raise e self._logger.debug("succeeded iaas.get_clouds()") - - - #=========================================================================# - # generate_context(self, service_name, replace, cloud) # - #=========================================================================# def generate_context(self, clouds, context_replacement={}, startup_script=None): """Generates the contextualization file for the given clouds. """ @@ -113,11 +109,6 @@ def generate_context(self, clouds, context_replacement={}, startup_script=None): context = self._generate_context_file(cloud, context_replacement, startup_script) cloud.set_context(context) - def generate_config_file(self, cloud_name): - #TODO (genc) copy the config generation part of the method below here - pass - - def get_cloud_by_name(self, cloud_name): """ @param cloud_name @@ -132,9 +123,6 @@ def get_cloud_by_name(self, cloud_name): except IndexError: raise Exception("Unknown cloud: %s. Available clouds: %s" % (cloud_name, self._available_clouds)) - #=========================================================================# - # create_nodes(self, count, contextFile, test_agent) # - #=========================================================================# def create_nodes(self, nodes_info, clouds): self._logger.debug('[create_nodes]: %s' % nodes_info) @@ -186,7 +174,6 @@ def _create_nodes(self, nodes_info, cloud): self._logger.debug("[create_nodes]: cloud.new_instances(%s)" % str(nodes_info) ) return cloud.new_instances(nodes_info) - # def create_nodes(self, count, cloud_name=None, inst_type=None): # """ # Creates the VMs associated with the list of nodes. It also tests @@ -368,9 +355,6 @@ def _check_node(self, node): return False - #=========================================================================# - # list_vms(self, cloud=None) # - #=========================================================================# def list_vms(self, cloud=None): """Returns an array with the VMs running at the given/default(s) cloud. @@ -382,9 +366,6 @@ def list_vms(self, cloud=None): return cloud.list_vms() - #=========================================================================# - # delete_nodes(self, nodes) # - #=========================================================================# def delete_nodes(self, nodes): """Kills the VMs associated with the list of nodes. @@ -416,7 +397,6 @@ def create_volume(self, size, name, vm_id, cloud=None): return cloud.create_volume(size, name, vm_id) - def attach_volume(self, vm_id, volume_id, device, cloud=None): cloud = self.get_cloud_by_name(cloud) if cloud.connected is False: @@ -449,7 +429,6 @@ class volume: self._logger.debug("destroy_volume(volume=%s)" % volume.id) return cloud.destroy_volume(volume) - def _create_manager_config(self, user_id, app_id, vpn=None): """Add manager configuration""" config_string = StringIO.StringIO() @@ -494,6 +473,7 @@ def check_process(self, host): return self._check(https.client.jsonrpc_get(host, self.port, '/', method)) class AgentController(Controller): + def __init__(self, user_id, app_id, service_id, service_type, manager_ip): Controller.__init__(self) self.config_parser = self._create_agent_config(str(user_id), str(app_id), service_id, service_type, manager_ip) @@ -511,38 +491,11 @@ def _create_agent_config(self, user_id, app_id, service_id, service_type, manage config_parser.set('manager', 'MANAGER_IP', manager_ip) return config_parser - def _generate_context_file(self, cloud, context_replacement={}, startup_script=None): - ''' - the context file runs the scripts necessary on each node created - it's installing all the necessary dependencies for the service - on the cloud you are installing - - ''' - - cloud_type = cloud.get_cloud_type() - # conpaas_home = self.config_parser.get('manager', 'CONPAAS_HOME') + def generate_config_file(self, context_replacement): conpaas_home = self.config_parser.get('conpaas', 'CONF_DIR') - - cloud_scripts_dir = conpaas_home + '/scripts/cloud' agent_cfg_dir = conpaas_home + '/config/agent' - agent_scripts_dir = conpaas_home + '/scripts/agent' - - # COMMENT (genc): the following line is temporarily commented, should be uncommented when we know how to reactivate ipop - # bootstrap = self.config_parser.get('manager', 'BOOTSTRAP') - # bootstrap = 'lesh' - director = self.config_parser.get('director', 'DIRECTOR_URL') manager_ip = self.config_parser.get('manager', 'MANAGER_IP') - - # Get contextualization script for the corresponding cloud - cloud_script_file = open(cloud_scripts_dir + '/' + cloud_type, 'r') - cloud_script = cloud_script_file.read() - - # Get agent setup file - agent_setup_file = open(agent_scripts_dir + '/agent-setup', 'r') - - agent_setup = Template(agent_setup_file.read()).safe_substitute(DIRECTOR=director) - # Get agent config file - add to the default one the one specific # to the service if it exists default_agent_cfg_file = open(agent_cfg_dir + '/default-agent.cfg') @@ -552,7 +505,6 @@ def _generate_context_file(self, cloud, context_replacement={}, startup_script=N CONPAAS_USER_ID=self._conpaas_user_id, CONPAAS_SERVICE_ID=self._conpaas_service_id, CONPAAS_APP_ID=self._conpaas_app_id, - CLOUD_TYPE=cloud_type, # IPOP_BASE_NAMESPACE=self._ipop_base_namespace ) @@ -566,9 +518,39 @@ def _generate_context_file(self, cloud, context_replacement={}, startup_script=N if os.path.isfile(agent_cfg_dir + '/' + self._conpaas_service_type + '-agent.cfg'): agent_cfg_file = open(agent_cfg_dir +'/' + self._conpaas_service_type + '-agent.cfg') - # agent_cfg += '\n' + Template(agent_cfg_file.read()).safe_substitute(CLOUD_TYPE=cloud_type,) agent_cfg += '\n' + Template(agent_cfg_file.read()).safe_substitute(context_replacement) + return agent_cfg + + def _generate_context_file(self, cloud, context_replacement={}, startup_script=None): + ''' + the context file runs the scripts necessary on each node created + it's installing all the necessary dependencies for the service + on the cloud you are installing + + ''' + cloud_type = cloud.get_cloud_type() + # conpaas_home = self.config_parser.get('manager', 'CONPAAS_HOME') + conpaas_home = self.config_parser.get('conpaas', 'CONF_DIR') + + cloud_scripts_dir = conpaas_home + '/scripts/cloud' + agent_scripts_dir = conpaas_home + '/scripts/agent' + + # COMMENT (genc): the following line is temporarily commented, should be uncommented when we know how to reactivate ipop + # bootstrap = self.config_parser.get('manager', 'BOOTSTRAP') + director = self.config_parser.get('director', 'DIRECTOR_URL') + + # Get contextualization script for the corresponding cloud + cloud_script_file = open(cloud_scripts_dir + '/' + cloud_type, 'r') + cloud_script = cloud_script_file.read() + + # Get agent setup file + agent_setup_file = open(agent_scripts_dir + '/agent-setup', 'r') + agent_setup = Template(agent_setup_file.read()).safe_substitute(DIRECTOR=director) + + # Get agent config file + agent_cfg = self.generate_config_file(context_replacement) + # Get agent start file - if none for this service, use the default one if os.path.isfile(agent_scripts_dir +'/' + self._conpaas_service_type + '-agent-start'): agent_start_file = open(agent_scripts_dir +'/' + self._conpaas_service_type + '-agent-start') @@ -577,7 +559,6 @@ def _generate_context_file(self, cloud, context_replacement={}, startup_script=N agent_start = agent_start_file.read() # Get key and a certificate from CA - # agent_certs = self._get_certificate() agent_certs = self._get_certificate(role="agent", email="info@conpaas.eu", cn="ConPaaS", @@ -595,17 +576,7 @@ def _generate_context_file(self, cloud, context_replacement={}, startup_script=N + 'cat < $ROOT_DIR/config.cfg\n' + agent_cfg + '\n' + 'EOF\n\n') - # COMMENT (genc): the following code copies the start script from the menager to agents - # i don't know if this can be possible at this point since we are at the director and agent - # startup scritps are at the manager - - # # Get user-provided startup script's absolute path - # basedir = self.config_parser.get('manager', 'CONPAAS_HOME') - # startup_script = os.path.join(basedir, 'startup.sh') - # # Append user-provided startup script (if any) - # if os.path.isfile(startup_script): - # context_file += open(startup_script).read() + '\n' if startup_script: context_file += startup_script + '\n' @@ -625,7 +596,6 @@ def __init__(self, user_id, app_id, vpn): self.port = 443 def generate_config_file(self): - tmpl_values = {} # cloud_name = cloud.get_cloud_name() conpaas_home = self.config_parser.get('conpaas', 'CONF_DIR') mngr_cfg_dir = os.path.join(conpaas_home, 'config', 'manager') @@ -635,26 +605,9 @@ def generate_config_file(self): else: conpaas_deployment_name = 'conpaas' - cloud_sections = ['iaas'] - if self.config_parser.has_option('iaas', 'OTHER_CLOUDS'): - cloud_sections.extend( - [cld_name for cld_name - in self.config_parser.get('iaas', 'OTHER_CLOUDS').split(',') - if self.config_parser.has_section(cld_name)]) - - - def _extract_cloud_cfg(section_name): - tmpl_values['cloud_cfg'] += "["+section_name+"]\n" - for key, value in self.config_parser.items(section_name): - tmpl_values['cloud_cfg'] += key.upper() + " = " + value + "\n" - - tmpl_values['cloud_cfg'] = '' - for section_name in cloud_sections: - _extract_cloud_cfg(section_name) - # Get manager config file - # mngr_cfg = file_get_contents(os.path.join(mngr_cfg_dir, 'default-manager.cfg')) # TODO (genc): Don't forget about having two default manager files (delete one when done) + # mngr_cfg = file_get_contents(os.path.join(mngr_cfg_dir, 'default-manager.cfg')) mngr_cfg = file_get_contents(os.path.join(mngr_cfg_dir, 'default-manager-new.cfg')) # Modify manager config file setting the required variables @@ -686,7 +639,6 @@ def _extract_cloud_cfg(section_name): # # mngr_cfg = mngr_cfg.replace('%CLOUD_COST_PER_TIME%', cloud_cost_per_time); - # COMMENT (genc): the IPOP part is commented until we have a working IPOP # # Check if we want to use IPOP. If so, add IPOP directives to manager @@ -707,11 +659,7 @@ def _extract_cloud_cfg(section_name): # if self.config_parser.has_option('conpaas', 'VPN_BOOTSTRAP_NODES'): # mngr_cfg += '\nIPOP_BOOTSTRAP_NODES = %s' % self.config_parser.get('conpaas', 'VPN_BOOTSTRAP_NODES') - tmpl_values['mngr_cfg'] = mngr_cfg - return """ -%(cloud_cfg)s -%(mngr_cfg)s -""" % tmpl_values + return mngr_cfg def _generate_context_file(self, cloud, context_replacement={}, startup_script=None): """Override default _get_context_file. Here we generate the context diff --git a/conpaas-services/sbin/manager/default-cpsmanager b/conpaas-services/sbin/manager/default-cpsmanager index 76e24b43..7ff38973 100755 --- a/conpaas-services/sbin/manager/default-cpsmanager +++ b/conpaas-services/sbin/manager/default-cpsmanager @@ -69,9 +69,8 @@ if __name__ == '__main__': Verify some sections and variables that must exist in the configuration file """ config_vars = { - # 'manager': ['TYPE', 'BOOTSTRAP', 'LOG_FILE','CREDIT_URL', 'TERMINATE_URL', 'SERVICE_ID'], + # 'manager': ['TYPE', 'BOOTSTRAP', 'LOG_FILE', 'CREDIT_URL', 'TERMINATE_URL', 'SERVICE_ID'], # 'manager': ['BOOTSTRAP', 'LOG_FILE', 'CREDIT_URL', 'TERMINATE_URL'], - 'iaas': ['DRIVER'], } config_ok = True for section in config_vars: diff --git a/conpaas-services/src/conpaas/services/webservers/manager/internal/php.py b/conpaas-services/src/conpaas/services/webservers/manager/internal/php.py index 33c778f9..c8b2cd2f 100755 --- a/conpaas-services/src/conpaas/services/webservers/manager/internal/php.py +++ b/conpaas-services/src/conpaas/services/webservers/manager/internal/php.py @@ -24,11 +24,11 @@ is_int, is_pos_nul_int, is_pos_int, is_dict, is_dict2, is_bool,\ is_uploaded_file -try: - from conpaas.services.webservers.manager.autoscaling.scaler import ProvisioningManager -except ImportError as ex: - provision_mng_error = "%s" % ex - ProvisioningManager = None +# try: +# from conpaas.services.webservers.manager.autoscaling.scaler import ProvisioningManager +# except ImportError as ex: +# provision_mng_error = "%s" % ex +ProvisioningManager = None from multiprocessing.pool import ThreadPool @@ -41,7 +41,7 @@ def __init__(self, config_parser, **kwargs): self._create_initial_configuration() if ProvisioningManager is None: - self.logger.info('Provisioning Manager can not be initialized: %s' % provision_mng_error) + # self.logger.info('Provisioning Manager can not be initialized: %s' % provision_mng_error) self.scaler = None else: try: