Пример #1
0
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:
Пример #2
0
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
Пример #3
0
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
Пример #4
0
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
Пример #5
0
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