def restart_service(self): log.info('Start to restart openstack service for nova/neutron/cinder.') cps_service = CPSServiceBusiness() for proxy in self.proxy_match_region.keys(): cps_service.stop_all(proxy) cps_service.start_all(proxy) log.info('Finish to restart openstack service for nova/neutron/cinder.')
class DispatchPatchTool(object): def __init__(self, proxy_match_region): # self.filter_for_dispatch = ['.py', '.sh', '.ini', '.pem', '.txt', '.vmx', '.json'] self.filter_for_dispatch = [] self.cps_service_business = CPSServiceBusiness() self.aws_cascaded_node_hosts = self.cps_service_business.get_aws_node_hosts() self.vcloud_cascaded_node_hosts = self.cps_service_business.get_vcloud_node_hosts() self.openstack_cascaded_node_hosts = self.cps_service_business.get_openstack_hosts() self.proxy_match_region = proxy_match_region log.info('proxy_match_region: %s' % self.proxy_match_region) self.proxy_hosts = self.cps_service_business.get_all_proxy_nodes(self.proxy_match_region) log.info('proxy_hosts: %s' % self.proxy_hosts) def dispatch_patch_tool_to_host(self, host): path_of_patch_tool = utils.get_patches_tool_path() files_need_to_dispatch = utils.get_files(path_of_patch_tool, self.filter_for_dispatch) ssh = sshutils.SSH(host=host, user=SysUserInfo.FSP, password=SysUserInfo.FSP_PWD) try: for absolute_file, relative_path_of_file in files_need_to_dispatch: log.info('start to copy file <<%s>> to host <<%s>>' % (relative_path_of_file, host)) file_copy_to = os.path.join(SysPath.HOME_FSP, SysPath.PATCHES_TOOL, relative_path_of_file) file_dir_copy_to = os.path.dirname(file_copy_to) ssh.run('mkdir -p %s' % file_dir_copy_to) ssh.put_file(absolute_file, file_copy_to) log.info('End to copy file <<%s>> to host <<%s>>' % (relative_path_of_file, host)) except Exception, e: log.error('Exception occur when dispatch patches tool to host: <%s>, Exception: %s' % (host, traceback.format_exc())) finally:
def get_all_hosts(): cps_business = CPSServiceBusiness() openstack_az_hosts = cps_business.get_openstack_hosts() aws_az_hosts = cps_business.get_aws_node_hosts() vcloud_az_hosts = cps_business.get_vcloud_node_hosts() all_proxy_host = cps_business.get_all_proxy_nodes(proxy_match_region=CONF.DEFAULT.proxy_match_region) return openstack_az_hosts + aws_az_hosts + vcloud_az_hosts + all_proxy_host
def check_service_status(self): print('****Start to check service status...') cps_service = CPSServiceBusiness() for proxy in self.proxies: cps_service.check_all_service_template_status(proxy) print('****End to check service status.')
def get_all_cascaded_hosts(): cps_business = CPSServiceBusiness() openstack_az_hosts = cps_business.get_openstack_hosts() aws_az_hosts = cps_business.get_aws_node_hosts() vcloud_az_hosts = cps_business.get_vcloud_node_hosts() # shaixun proxy_match_host = CONF.DEFAULT.proxy_match_host return openstack_az_hosts + aws_az_hosts + vcloud_az_hosts
def __init__(self, proxy_match_region): # self.filter_for_dispatch = ['.py', '.sh', '.ini', '.pem', '.txt', '.vmx', '.json'] self.filter_for_dispatch = [] self.cps_service_business = CPSServiceBusiness() self.aws_cascaded_node_hosts = self.cps_service_business.get_aws_node_hosts() self.vcloud_cascaded_node_hosts = self.cps_service_business.get_vcloud_node_hosts() self.openstack_cascaded_node_hosts = self.cps_service_business.get_openstack_hosts() self.proxy_match_region = proxy_match_region log.info('proxy_match_region: %s' % self.proxy_match_region) self.proxy_hosts = self.cps_service_business.get_all_proxy_nodes(self.proxy_match_region) log.info('proxy_hosts: %s' % self.proxy_hosts)
def restart_services(self): print('****Start to restart services...') cps_service = CPSServiceBusiness() for proxy in self.proxies: cps_service.stop_all(proxy) for proxy in self.proxies: cps_service.start_all(proxy) print('****Finish to restart services.')
def restart_service(self): log.info('Start to restart openstack service for nova/neutron/cinder.') cps_service = CPSServiceBusiness() for proxy in self.proxy_match_region.keys(): cps_service.stop_all(proxy) cps_service.start_all(proxy) log.info( 'Finish to restart openstack service for nova/neutron/cinder.')
def get_all_hosts(): cps_business = CPSServiceBusiness() openstack_az_hosts = cps_business.get_openstack_hosts() aws_az_hosts = cps_business.get_aws_node_hosts() vcloud_az_hosts = cps_business.get_vcloud_node_hosts() all_proxy_host = cps_business.get_all_proxy_nodes( proxy_match_region=CONF.DEFAULT.proxy_match_region) return openstack_az_hosts + aws_az_hosts + vcloud_az_hosts + all_proxy_host
def get_all_cascaded_hosts(): cps_business = CPSServiceBusiness() openstack_az_hosts = cps_business.get_openstack_hosts() aws_az_hosts = cps_business.get_aws_node_hosts() vcloud_az_hosts = cps_business.get_vcloud_node_hosts() return openstack_az_hosts + aws_az_hosts + vcloud_az_hosts
def get_os_region_name(): cps_business = CPSServiceBusiness() return cps_business.get_os_region_name()
def get_all_proxy_hosts(): cps_business = CPSServiceBusiness() all_proxy_hosts = cps_business.get_all_proxy_nodes(proxy_match_region=CONF.DEFAULT.proxy_match_region) return all_proxy_hosts
def verify_services_status(self): cps_service = CPSServiceBusiness() for proxy in self.proxy_match_region.keys(): cps_service.check_all_service_template_status(proxy)
def patch_for_cascaded_nodes(self): cps = CPSServiceBusiness()
def get_all_proxy_hosts(): cps_business = CPSServiceBusiness() all_proxy_hosts = cps_business.get_all_proxy_nodes( proxy_match_region=CONF.DEFAULT.proxy_match_region) return all_proxy_hosts