Exemplo n.º 1
0
def apply_patch(ip, file_path, user='******', password='******'):
    file_name = os.path.basename(file_path)
    patch_name, patch_version = file_name.split('_')[0:2]
    # Check if patch has already been installed
    ssh_client = RemoteClient(ip, user, password)
    patch_info = get_patch_info(ssh_client, patch_version)
    if patch_info and patch_info['Installed'] == 'Yes':
        LOG.info('Patch %s has already been installed, Skip installing it.',
                 file_name)
        return patch_info
    if not patch_info:
        LOG.info('Adding patch %s' % file_name)
        remote_path = os.path.join('/tmp', file_name)
        ssh_client.scp(file_name, '/tmp')
        ssh_client.run('viopatch add -l %s' % remote_path,
                       sudo=True,
                       raise_error=True)
        # Clean up patch file in case oms disk becomes full
        ssh_client.run('rm -f %s' % remote_path)
    patch_info = get_patch_info(ssh_client, patch_version)
    if not patch_info:
        raise NotSupportedError('Failed to add Patch %s' % file_name)
    LOG.info('Start to install patch %s' % file_name)
    ssh_client.run('viopatch install --patch %s --version %s --as-infra' %
                   (patch_name, patch_version),
                   sudo=True,
                   raise_error=True,
                   feed_input='Y')
    patch_info = get_patch_info(ssh_client, patch_version)
    if patch_info['Installed'] != 'Yes':
        LOG.error('Failed to install patch %s' % patch_info)
        raise NotCompletedError('Failed to install patch %s.' % file_name)
    LOG.info('Successfully Installed patch %s' % file_name)
    return patch_info
Exemplo n.º 2
0
def config_omjs(ip, vc_user, vc_password, properties, user='******',
                password='******'):
    LOG.info('Update omjs.properties: %s', properties)
    ssh_client = RemoteClient(ip, user, password)
    for key in properties:
        set_omjs_value(ssh_client, key, properties[key])
    ssh_client.run('restart oms', sudo=True, raise_error=True)
    wait_for_mgmt_service(ip, vc_user, vc_password)
Exemplo n.º 3
0
def apply_patch(ip, file_path, user='******', password='******'):
    file_name = os.path.basename(file_path)
    patch_name, patch_version = file_name.split('_')[0:2]
    # Check if patch has already been installed
    ssh_client = RemoteClient(ip, user, password)
    patch_info = get_patch_info(ssh_client, patch_version)
    if patch_info and patch_info['Installed'] == 'Yes':
        LOG.info('Patch %s has already been installed, Skip installing it.',
                 file_name)
        return patch_info
    if not patch_info:
        LOG.info('Adding patch %s' % file_name)
        remote_path = os.path.join('/tmp', file_name)
        ssh_client.scp(file_name, '/tmp')
        ssh_client.run('viopatch add -l %s' % remote_path, sudo=True,
                       raise_error=True)
        # Clean up patch file in case oms disk becomes full
        ssh_client.run('rm -f %s' % remote_path)
    patch_info = get_patch_info(ssh_client, patch_version)
    if not patch_info:
        raise NotSupportedError('Failed to add Patch %s' % file_name)
    LOG.info('Start to install patch %s' % file_name)
    ssh_client.run('viopatch install --patch %s --version %s --as-infra' %
                   (patch_name, patch_version), sudo=True, raise_error=True,
                   feed_input='Y')
    patch_info = get_patch_info(ssh_client, patch_version)
    if patch_info['Installed'] != 'Yes':
        LOG.error('Failed to install patch %s' % patch_info)
        raise NotCompletedError('Failed to install patch %s.' % file_name)
    LOG.info('Successfully Installed patch %s' % file_name)
    return patch_info
Exemplo n.º 4
0
def config_omjs(ip,
                vc_user,
                vc_password,
                properties,
                user='******',
                password='******'):
    LOG.info('Update omjs.properties: %s', properties)
    ssh_client = RemoteClient(ip, user, password)
    for key in properties:
        set_omjs_value(ssh_client, key, properties[key])
    ssh_client.run('restart oms', sudo=True, raise_error=True)
    wait_for_mgmt_service(ip, vc_user, vc_password)
Exemplo n.º 5
0
def apply_patch(ip, file_path, user='******', password='******'):
    file_name = os.path.basename(file_path)
    patch_name, patch_version = file_name.split('_')[0:2]
    LOG.info('Start to Apply patch %s' % patch_version)
    ssh_client = RemoteClient(ip, user, password)
    ssh_client.run('viopatch add -l %s' % file_path,
                   sudo=True,
                   raise_error=True,
                   log_method='info')
    ssh_client.run('viopatch install --patch %s --version %s --as-infra' %
                   (patch_name, patch_version),
                   sudo=True,
                   raise_error=True,
                   log_method='info',
                   feed_input='Y')
    output = ssh_client.run('viopatch list',
                            sudo=True,
                            raise_error=True,
                            log_method='info')
    patch_info = get_patch_info(output, patch_version)
    if patch_info['Installed'] != 'Yes':
        LOG.error('Applying patch failed. %s' % patch_info)
        raise NotCompletedError('Applying %s failed.' % file_path)
    LOG.info('Successfully Applied patch %s' % patch_version)