Ejemplo n.º 1
0
def install_tempest(repository='github.com/openstack/tempest.git',
                    branch='11.0.0',
                    nsx_repo='github.com/openstack/vmware-nsx',
                    nsx_branch='stable/mitaka',
                    protocol='http',
                    conf_template=None):
    if os.path.exists(TEMPEST_DIR):
        LOG.info('Tempest already exists, skip cloning.')
    else:
        LOG.info('Clone tempest from repository.')
        clone_url = '%s://%s' % (protocol, repository)
        shell.local('%s -b %s %s' % (GIT_CLONE, branch, clone_url),
                    raise_error=True)
    # Get vmware_nsx plugin
    if os.path.exists(VMWARE_NSX_DIR):
        LOG.info('vmware-nsx already exists, skip cloning.')
    else:
        LOG.info('Clone vmware-nsx from repository.')
        clone_url = '%s://%s' % (protocol, nsx_repo)
        shell.local('%s -b %s %s' % (GIT_CLONE, nsx_branch, clone_url),
                    raise_error=True)
    with shell.cd(TEMPEST_DIR):
        shell.local("sed -i 's/-500/-1500/g' .testr.conf")
        LOG.info('Copy template to etc/tempest.conf')
        conf_template = conf_template or os.path.join(get_data_path(),
                                                      'tempest.conf.template')
        shell.local('cp %s etc/tempest.conf' % conf_template, raise_error=True)
        LOG.info('Install tempest dependencies.')
        cmd = 'python tools/install_venv.py --no-site-packages'
        task_utils.safe_run(cmd, 'install tempest dependency')
    LOG.info('Install vmware-nsx.')
    cmd = './%s/tools/with_venv.sh pip install -e %s' % (TEMPEST_DIR,
                                                         VMWARE_NSX_DIR)
    task_utils.safe_run(cmd, 'install vmware-nsx')
    LOG.info('Tempest has been successfully installed.')
Ejemplo n.º 2
0
def download_file(url, path=None):
    file_name = os.path.basename(url)
    if path:
        abs_path = os.path.join(path, file_name)
    else:
        abs_path = os.path.join(os.getcwd(), file_name)
    if not os.path.exists(abs_path):
        cmd = "wget --no-verbose -O %s %s" % (abs_path, url)
        safe_run(cmd, 'download %s' % url)
        LOG.info('Downloaded %s to %s', url, abs_path)
    else:
        LOG.info('%s already exists, skip downloading it.', abs_path)
    return abs_path
Ejemplo n.º 3
0
def download_file(url, path=None):
    file_name = os.path.basename(url)
    if path:
        abs_path = os.path.join(path, file_name)
    else:
        abs_path = os.path.join(os.getcwd(), file_name)
    if not os.path.exists(abs_path):
        cmd = "wget --no-verbose -O %s %s" % (abs_path, url)
        safe_run(cmd, 'download %s' % url)
        LOG.info('Downloaded %s to %s', url, abs_path)
    else:
        LOG.info('%s already exists, skip downloading it.', abs_path)
    return abs_path
Ejemplo n.º 4
0
def deploy_vapp(vc_host,
                vc_user,
                vc_password,
                dc,
                cluster,
                ds,
                network,
                ova_path,
                ntp_server=None,
                viouser_pwd='vmware',
                log_path=None,
                ip=None,
                netmask=None,
                gateway=None,
                dns=None,
                ovf_tool_path=None):
    if not ovf_tool_path:
        ovf_tool_path = get_ovf_tool_path()
        if not ovf_tool_path:
            ovf_tool_path = DEFAULT_LOCAL_OVF_TOOL_PATH
    if not os.path.isfile(ovf_tool_path):
        LOG.error('ovftool not found.')
        raise NotSupportedError('ovftool not found')
    if not log_path:
        log_path = os.getcwd()

    ntp_config = '--prop:ntpServer=%s ' % ntp_server if ntp_server else ''
    dns_config = '--prop:vami.DNS.management-server=%s ' % dns if dns else ''
    # deploy ova and poweron vm
    # TODO: implement deploy with dhcp
    cmd = ('"%s" --X:"logFile"="%s/deploy_oms.log" '
           '--vService:"installation"='
           '"com.vmware.vim.vsm:extension_vservice" '
           '--acceptAllEulas --noSSLVerify --powerOn '
           '--datastore="%s" '
           '-dm=thin '
           '--net:"VIO Management Server Network"="%s" '
           '--prop:vami.ip0.management-server=%s '
           '--prop:vami.netmask0.management-server=%s '
           '--prop:vami.gateway.management-server=%s '
           '%s '
           '--prop:viouser_passwd="%s" '
           '%s "%s" "vi://%s:%s@%s/%s/host/%s"'
           '' % (ovf_tool_path, log_path, ds, network, ip, netmask, gateway,
                 dns_config, viouser_pwd, ntp_config, ova_path, vc_user,
                 vc_password, vc_host, dc, cluster))
    LOG.info('Start to deploy management server.')
    task_utils.safe_run(cmd, 'deploy VIO vApp')
    wait_for_mgmt_service(ip, vc_user, vc_password)
    LOG.info('Successfully deployed management server.')
Ejemplo n.º 5
0
def install_tempest(
        repository='github.com/openstack/tempest.git',
        branch='18.0.0',
        enable_nsx=True,
        nsx_repo='git.openstack.org/openstack/'
    'vmware-nsx-tempest-plugin',
        nsx_branch='master',
        enable_fwaas=True,
        fwaas_repo='github.com/openstack/neutron-fwaas',
        fwaas_branch='master',
        enable_heat=True,
        # heat_repo='p3-review.eng.vmware.com/heat',
        heat_repo='github.com/openstack/heat-tempest-plugin.git',
        heat_branch='master',
        protocol='http',
        conf_template=None):
    if os.path.exists(TEMPEST_DIR):
        LOG.info('Tempest already exists, skip cloning.')
    else:
        LOG.info('Clone tempest from repository.')
        clone_url = '%s://%s' % (protocol, repository)
        task_utils.safe_run('%s -b %s %s' % (GIT_CLONE, branch, clone_url),
                            'Clone tempest')
        try:
            git_pick = 'GIT_SSL_NO_VERIFY=true git fetch ' \
                       'http://git.openstack.org/openstack/tempest ' \
                       'refs/changes/57/557657/4 && git cherry-pick FETCH_HEAD'
            with shell.cd(TEMPEST_DIR):
                shell.local(git_pick)
        except Exception:
            LOG.debug('Cherry-pick tempest failed. %s' % git_pick)
    with shell.cd(TEMPEST_DIR):
        # shell.local("sed -i 's/-500/-1500/g' .testr.conf")
        LOG.info('Copy template to etc/tempest.conf')
        conf_template = conf_template or os.path.join(get_data_path(),
                                                      'tempest.conf.template')
        shell.local('cp %s etc/tempest.conf' % conf_template, raise_error=True)
        shell.local('virtualenv .venv')
    LOG.info('Install tempest.')
    # TODO: a workaround to fix cmd2 version error
    cmd = './%s/tools/with_venv.sh pip --no-cache-dir install ' \
          'cmd2==0.8.7' % TEMPEST_DIR
    task_utils.safe_run(cmd, 'install cmd2')
    cmd = './%s/tools/with_venv.sh pip --no-cache-dir install %s' % \
          (TEMPEST_DIR, TEMPEST_DIR)
    task_utils.safe_run(cmd, 'install tempest')
    # TODO: a workaround to fix the tempest dependency error.
    cmd = './%s/tools/with_venv.sh pip --no-cache-dir install ' \
          'babel' % TEMPEST_DIR
    task_utils.safe_run(cmd, 'install babel')
    if enable_fwaas:
        install_fwaas_tempest(protocol, fwaas_repo, fwaas_branch)
    if enable_heat:
        install_heat(protocol, heat_repo, heat_branch)
    LOG.info('Tempest has been successfully installed.')
Ejemplo n.º 6
0
def deploy_vapp(vc_host, vc_user, vc_password, dc, cluster, ds, network,
                ova_path, ntp_server=None, viouser_pwd='vmware', log_path=None,
                ip=None, netmask=None, gateway=None, dns=None,
                ovf_tool_path=None):
    if not ovf_tool_path:
        ovf_tool_path = get_ovf_tool_path()
        if not ovf_tool_path:
            ovf_tool_path = DEFAULT_LOCAL_OVF_TOOL_PATH
    if not os.path.isfile(ovf_tool_path):
        LOG.error('ovftool not found.')
        raise NotSupportedError('ovftool not found')
    if not log_path:
        log_path = os.getcwd()

    ntp_config = '--prop:ntpServer=%s ' % ntp_server if ntp_server else ''
    dns_config = '--prop:vami.DNS.management-server=%s ' % dns if dns else ''
    # deploy ova and poweron vm
    # TODO: implement deploy with dhcp
    cmd = ('"%s" --X:"logFile"="%s/deploy_oms.log" '
           '--vService:"installation"='
           '"com.vmware.vim.vsm:extension_vservice" '
           '--acceptAllEulas --noSSLVerify --powerOn '
           '--datastore="%s" '
           '-dm=thin '
           '--net:"VIO Management Server Network"="%s" '
           '--prop:vami.ip0.management-server=%s '
           '--prop:vami.netmask0.management-server=%s '
           '--prop:vami.gateway.management-server=%s '
           '%s '
           '--prop:viouser_passwd="%s" '
           '%s "%s" "vi://%s:%s@%s/%s/host/%s"'
           '' % (ovf_tool_path, log_path, ds, network, ip, netmask,
                 gateway, dns_config, viouser_pwd, ntp_config, ova_path,
                 vc_user, vc_password, vc_host, dc, cluster))
    LOG.info('Start to deploy management server.')
    task_utils.safe_run(cmd, 'deploy VIO vApp')
    wait_for_mgmt_service(ip, vc_user, vc_password)
    LOG.info('Successfully deployed management server.')
Ejemplo n.º 7
0
def install_heat(protocol, heat_repo, heat_branch):
    if os.path.exists(HEAT_DIR):
        LOG.info('Heat already exists, skip cloning.')
    else:
        LOG.info('Clone heat from repository.')
        clone_url = '%s://%s' % (protocol, heat_repo)
        task_utils.safe_run(
            '%s -b %s %s' % (GIT_CLONE, heat_branch, clone_url), 'Clone heat')
    LOG.info('Install %s.' % HEAT_DIR)
    cmd = './%s/tools/with_venv.sh pip --no-cache-dir install -e %s' % \
          (TEMPEST_DIR, HEAT_DIR)
    task_utils.safe_run(cmd, 'install heat')
    # ./tempest/tools/with_venv.sh pip install -r heat/test-requirements.txt
    cmd = './%s/tools/with_venv.sh pip install -r %s/test-requirements.txt' % \
          (TEMPEST_DIR, HEAT_DIR)
    task_utils.safe_run(cmd, 'install heat requirements')
Ejemplo n.º 8
0
def install_fwaas_tempest(protocol, fwaas_repo, fwaas_branch):
    # Get fwaas plugin
    if os.path.exists(NEUTRON_FWAAS_DIR):
        LOG.info('neutron-fwaas already exists, skip cloning.')
    else:
        LOG.info('Clone neutron-fwaas from repository.')
        clone_url = '%s://%s' % (protocol, fwaas_repo)
        task_utils.safe_run(
            '%s -b %s %s' % (GIT_CLONE, fwaas_branch, clone_url),
            'Clone neutron-fwaas')

    # To do: testscenarios is not installed, which is needed for fwaas
    cmd = './%s/tools/with_venv.sh pip --no-cache-dir install ' \
          'testscenarios' % TEMPEST_DIR
    task_utils.safe_run(cmd, 'install testscenarios')
    LOG.info('Install neutron-fwaas.')
    cmd = './%s/tools/with_venv.sh pip --no-cache-dir install -e %s' % \
          (TEMPEST_DIR, NEUTRON_FWAAS_DIR)
    task_utils.safe_run(cmd, 'install neutron-fwaas')