def _set_and_validate_config(self): basic_config = self.config.basicConfig deploy_config = self.config.deployerConfig self.zstack_pkg = self._full_path(basic_config.zstackPkg.text_) self.zstack_install_script = \ self._full_path(basic_config.zstackInstallScript.text_) if not os.path.exists(self.zstack_pkg): raise ActionError('unable to find %s for ZStack binary' \ % self.zstack_pkg) if basic_config.hasattr('zstackInstallPath'): self.install_path = \ self._full_path(basic_config.zstackInstallPath.text_) else: raise ActionError(\ 'need to set config.deployerConfig.zstackInstallPath in : %s' % self.deploy_config_path) #set ZSTACK_HOME, which will be used by zstack-ctl os.environ['ZSTACK_HOME'] = '%s/apache-tomcat/webapps/zstack/' % \ self.install_path if basic_config.hasattr('testAgent'): self.test_agent_path = self._full_path( basic_config.testAgent.text_) linux.error_if_path_missing(self.test_agent_path) for zone in deploy_config.zones.get_child_node_as_list('zone'): for cluster in zone.clusters.get_child_node_as_list('cluster'): if cluster.hypervisorType_ == inventory.KVM_HYPERVISOR_TYPE: for h in cluster.hosts.get_child_node_as_list('host'): h.managementIp_ h.username_ h.password_ # will raise exception if one of above not specified in xml filea. self.test_agent_hosts.append(h) else: if xmlobject.has_element(basic_config, 'testAgentHost'): raise ActionError( '<tesgAgent> is missing while <testAgentHost> presents') self.catalina_home = self.install_path + '/apache-tomcat' self.wait_for_start_timeout = basic_config.get( 'managementServerStartTimeout') if not self.wait_for_start_timeout: self.wait_for_start_timeout = 120 else: self.wait_for_start_timeout = int(self.wait_for_start_timeout) if hasattr(basic_config, 'rabbitmq'): self.rabbitmq_server = basic_config.rabbitmq.get( 'server', 'localhost') self.rabbitmq_server_root_passwd = basic_config.rabbitmq.get( 'password', '') if not self.rabbitmq_server_root_passwd: print('!!!WARN! Rabbitmq server root password are not set!') else: raise ActionError( 'need to set config.basicConfig.rabbitmq.server in: %s' % self.deploy_config_path) if hasattr(basic_config, 'db'): self.need_deploy_db = True self.db_server = basic_config.db.get('server', 'localhost') self.db_username = basic_config.db.get('username', 'zstack') self.db_password = basic_config.db.get('password', '') self.db_admin_username = basic_config.db.get('admin', 'root') self.db_admin_password = basic_config.db.get('adminPassword', '') self.db_server_root_password = basic_config.db.get( 'server_root_password', '') if not self.db_server_root_password: print('!!!WARN! Database server root password are not set!') self.db_port = basic_config.db.get('port', '3306') if basic_config.has_element('zstackProperties'): if basic_config.zstackProperties.text_: self.zstack_properties = self._full_path( basic_config.zstackProperties.text_) if not os.path.exists(self.zstack_properties): print( 'unable to find zstackProperties at %s, use \ default one' % self.zstack_properties) self.zstack_properties = None if basic_config.has_element('zstackHaVip'): self.zstack_ha_vip = basic_config.zstackHaVip.text_ else: self.zstack_ha_vip = None if basic_config.has_element('zstackManagementIp'): self.zstack_management_ip = basic_config.zstackManagementIp.text_ else: self.zstack_management_ip = None os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = '' if deploy_config.has_element('nodes') \ and deploy_config.nodes.has_element('node'): for node in deploy_config.nodes.get_child_node_as_list('node'): node.ip_ self.nodes.append(node) if linux.is_ip_existing(node.ip_): os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = node.ip_ elif not os.environ.get('ZSTACK_BUILT_IN_HTTP_SERVER_IP'): os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = node.ip_ else: raise ActionError( 'deploy.xml setting error. No deployerConfig.nodes.node is found. ' ) if self.zstack_ha_vip != None: os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = self.zstack_ha_vip if self.zstack_management_ip != None: os.environ[ 'ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = self.zstack_management_ip if not os.environ.get('ZSTACK_BUILT_IN_HTTP_SERVER_IP'): raise ActionError( 'deploy.xml setting error. No deployerConfig.nodes.node.ip is defined. ' )
def _set_and_validate_config(self): basic_config = self.config.basicConfig deploy_config = self.config.deployerConfig self.zstack_pkg = self._full_path(basic_config.zstackPkg.text_) self.zstack_install_script = \ self._full_path(basic_config.zstackInstallScript.text_) if not os.path.exists(self.zstack_pkg): raise ActionError('unable to find %s for ZStack binary' \ % self.zstack_pkg) if basic_config.hasattr('zstackInstallPath'): self.install_path = \ self._full_path(basic_config.zstackInstallPath.text_) else: raise ActionError(\ 'need to set config.deployerConfig.zstackInstallPath in : %s' % self.deploy_config_path) #set ZSTACK_HOME, which will be used by zstack-ctl os.environ['ZSTACK_HOME'] = '%s/apache-tomcat/webapps/zstack/' % \ self.install_path if basic_config.hasattr('testAgent'): self.test_agent_path = self._full_path(basic_config.testAgent.text_) linux.error_if_path_missing(self.test_agent_path) for zone in deploy_config.zones.get_child_node_as_list('zone'): for cluster in zone.clusters.get_child_node_as_list('cluster'): if cluster.hypervisorType_ == inventory.KVM_HYPERVISOR_TYPE: for h in cluster.hosts.get_child_node_as_list('host'): h.managementIp_ h.username_ h.password_ # will raise exception if one of above not specified in xml filea. self.test_agent_hosts.append(h) else: if xmlobject.has_element(basic_config, 'testAgentHost'): raise ActionError('<tesgAgent> is missing while <testAgentHost> presents') self.catalina_home = self.install_path + '/apache-tomcat' self.wait_for_start_timeout = basic_config.get('managementServerStartTimeout') if not self.wait_for_start_timeout: self.wait_for_start_timeout = 120 else: self.wait_for_start_timeout = int(self.wait_for_start_timeout) if hasattr(basic_config, 'rabbitmq'): self.rabbitmq_server = basic_config.rabbitmq.get('server', 'localhost') self.rabbitmq_server_root_passwd = basic_config.rabbitmq.get('password', '') if not self.rabbitmq_server_root_passwd: print ('!!!WARN! Rabbitmq server root password are not set!') else: raise ActionError('need to set config.basicConfig.rabbitmq.server in: %s' % self.deploy_config_path) if hasattr(basic_config, 'db'): self.need_deploy_db = True self.db_server = basic_config.db.get('server', 'localhost') self.db_username = basic_config.db.get('username', 'zstack') self.db_password = basic_config.db.get('password', '') self.db_admin_username = basic_config.db.get('admin', 'root') self.db_admin_password = basic_config.db.get('adminPassword', '') self.db_server_root_password = basic_config.db.get('server_root_password', '') if not self.db_server_root_password: print ('!!!WARN! Database server root password are not set!') self.db_port = basic_config.db.get('port', '3306') if basic_config.has_element('zstackProperties'): if basic_config.zstackProperties.text_: self.zstack_properties = self._full_path(basic_config.zstackProperties.text_) if not os.path.exists(self.zstack_properties): print('unable to find zstackProperties at %s, use \ default one' % self.zstack_properties) self.zstack_properties = None if basic_config.has_element('zstackHaVip'): self.zstack_ha_vip = basic_config.zstackHaVip.text_ else: self.zstack_ha_vip = None os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = '' if deploy_config.has_element('nodes') \ and deploy_config.nodes.has_element('node'): for node in deploy_config.nodes.get_child_node_as_list('node'): node.ip_ self.nodes.append(node) if linux.is_ip_existing(node.ip_): os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = node.ip_ elif not os.environ.get('ZSTACK_BUILT_IN_HTTP_SERVER_IP'): os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = node.ip_ else: raise ActionError('deploy.xml setting error. No deployerConfig.nodes.node is found. ') if self.zstack_ha_vip != None: os.environ['ZSTACK_BUILT_IN_HTTP_SERVER_IP'] = self.zstack_ha_vip if not os.environ.get('ZSTACK_BUILT_IN_HTTP_SERVER_IP'): raise ActionError('deploy.xml setting error. No deployerConfig.nodes.node.ip is defined. ')