def _replace_neutron_l2_proxy_json(self, host_info): """ TODO: to get host ip of proxies, and scp config file of json to these proxies. :return: """ log.info('Start to replace neutron l2 proxy json in proxy nodes..') print('Start to replace neutron l2 proxy json..') for proxy in self.proxies: neutron_network_role = self._get_neutron_role_name(proxy) for host in host_info['hosts']: roles_list = host['roles'] local_path_of_neutron_l2_proxy = os.path.join( utils.get_patches_tool_path(), CfgFilePath.NEUTRON_L2_PROXY_PATH_TEMPLATE) if neutron_network_role in roles_list: proxy_host_ip = host['manageip'] log.info( 'Start remote copy neutron l2 proxy json to host: %s' % proxy_host_ip) try: utils.remote_open_root_permit_for_host(proxy_host_ip) ssh = SSHConnection(proxy_host_ip, SysUserInfo.ROOT, SysUserInfo.ROOT_PWD) ssh.put(local_path_of_neutron_l2_proxy, CfgFilePath.NEUTRON_L2_PROXY_PATH) ssh.close() except Exception, e: log.error( 'Exception when remote copy neutron l2 proxy json to host: %s' % proxy_host_ip) log.error('Exception: %s' % traceback.format_exc()) log.info( 'Finish remote copy neutron l2 proxy json to host: %s' % proxy_host_ip)
def _replace_neutron_l2_proxy_json(self, host_info): """ TODO: to get host ip of proxies, and scp config file of json to these proxies. :return: """ log.info('Start to replace neutron l2 proxy json in proxy nodes. self.proxies = %s' % self.proxies) log.info('Start to replace neutron l2 proxy json in proxy nodes. host_info = %s' % host_info) for proxy in self.proxies: log.info('Start to replace neutron l2 proxy json in proxy nodes. proxy = %s' % proxy) neutron_network_role = self._get_neutron_role_name(proxy) for host in host_info['hosts']: roles_list = host['roles'] local_path_of_neutron_l2_proxy = os.path.join( utils.get_patches_tool_path(), CfgFilePath.NEUTRON_L2_PROXY_PATH_TEMPLATE) if neutron_network_role in roles_list: proxy_host_ip = host['manageip'] log.info('Start remote copy neutron l2 proxy json to host: %s' % proxy_host_ip) try: # utils.remote_open_root_permit_for_host(proxy_host_ip) ssh = SSHConnection(proxy_host_ip, SysUserInfo.ROOT, SysUserInfo.ROOT_PWD) ssh.put(local_path_of_neutron_l2_proxy, CfgFilePath.NEUTRON_L2_PROXY_PATH) ssh.close() log.info('Finish remote copy neutron l2 proxy json to host: %s' % proxy_host_ip) except Exception, e: log.error('Exception when remote copy neutron l2 proxy json to host: %s' % proxy_host_ip) log.error('Exception: %s' % traceback.format_exc()) finally: break
def config_big_l2_layer_in_proxy_node(self): host_list = None for i in range(3): try: host_list = RefCPSService.host_list() log.info("get host list success.") break except Exception as e: log.error("get host list error, try again. error: %s" % e.message) time.sleep(1) continue if host_list is None: log.error("config big l2 layer for proxies failed, get host list failed.") return False for proxy in self.proxies: # enable l2 remote port self.__enable_l2_remote_port_for_proxy__(proxy) # copy file host_id = self.proxy_match_host[proxy] host_ip = None for host in host_list["hosts"]: if host_id == host["id"]: host_ip = host["manageip"] break if host_ip is None: log.error("proxy not exist, proxy: %s, proxy id: %s" % (proxy, host_id)) continue log.info('start to replace neutron l2 proxy json in proxy nodes. proxy: %s' % proxy) replace_result = False for i in range(3): try: # utils.remote_open_root_permit_for_host(proxy_host_ip) local_path_of_neutron_l2_proxy = os.path.join( utils.get_patches_tool_path(), CfgFilePath.NEUTRON_L2_PROXY_PATH_TEMPLATE) ssh = SSHConnection(host_ip, SysUserInfo.ROOT, SysUserInfo.ROOT_PWD) ssh.put(local_path_of_neutron_l2_proxy, CfgFilePath.NEUTRON_L2_PROXY_PATH) ssh.close() replace_result = True log.info('replace neutron l2 proxy json success, proxy: %s' % proxy) break except Exception, e: log.error('replace neutron l2 proxy json error, try again, proxy: %s, error: %s' % (proxy, e.message)) time.sleep(1) continue finally: ssh.close()
def config_big_l2_layer_in_proxy_node(self): host_list = None for i in range(3): try: host_list = RefCPSService.host_list() log.info("get host list success.") break except Exception as e: log.error("get host list error, try again. error: %s" % e.message) time.sleep(1) continue if host_list is None: log.error( "config big l2 layer for proxies failed, get host list failed." ) return False for proxy in self.proxies: # enable l2 remote port self.__enable_l2_remote_port_for_proxy__(proxy) # copy file host_id = self.proxy_match_host[proxy] host_ip = None for host in host_list["hosts"]: if host_id == host["id"]: host_ip = host["manageip"] break if host_ip is None: log.error("proxy not exist, proxy: %s, proxy id: %s" % (proxy, host_id)) continue log.info( 'start to replace neutron l2 proxy json in proxy nodes. proxy: %s' % proxy) replace_result = False for i in range(3): try: # utils.remote_open_root_permit_for_host(proxy_host_ip) local_path_of_neutron_l2_proxy = os.path.join( utils.get_patches_tool_path(), CfgFilePath.NEUTRON_L2_PROXY_PATH_TEMPLATE) ssh = SSHConnection(host_ip, SysUserInfo.ROOT, SysUserInfo.ROOT_PWD) ssh.put(local_path_of_neutron_l2_proxy, CfgFilePath.NEUTRON_L2_PROXY_PATH) ssh.close() replace_result = True log.info( 'replace neutron l2 proxy json success, proxy: %s' % proxy) break except Exception, e: log.error( 'replace neutron l2 proxy json error, try again, proxy: %s, error: %s' % (proxy, e.message)) time.sleep(1) continue finally: ssh.close()