def create(lab_name, allowed_drivers=None, is_mgm_only=False, is_interactive=False): import validators from lab.laboratory import Laboratory from lab.mercury.nodes import MercuryMgm if not validators.ipv4(lab_name): if lab_name not in WithMercury.KNOWN_PODS_DIC: raise ValueError('"{}" unknown, possible names are {}'.format(lab_name, WithMercury.KNOWN_PODS_DIC.keys())) else: ip = WithMercury.KNOWN_PODS_DIC[lab_name]['mgm_ip'] else: ip = lab_name mgm, status, setup_data_dic, release_tag, gerrit_tag = MercuryMgm.create_from_actual(ip=ip, password=WithMercury.COMMON_PASSWORD) if not is_interactive and '| ORCHESTRATION | Success |' not in status: raise RuntimeError('{} is not properly installed: {}'.format(lab_name, status)) driver = setup_data_dic['MECHANISM_DRIVERS'] if allowed_drivers: assert driver.lower() in allowed_drivers, 'driver {} not in {}'.format(driver, allowed_drivers) pod = Laboratory(name=lab_name, driver=driver, release_tag=release_tag, gerrit_tag=gerrit_tag, setup_data_dic=setup_data_dic) if is_mgm_only: return mgm WithMercury.create_from_setup_data(pod=pod, mgm=mgm, is_interactive=is_interactive) if pod.driver == WithMercury.VTS: pod.driver_version = pod.vtc.r_vtc_get_version() else: pod.driver_version = 'vpp XXXX' return pod
def create(lab_name, allowed_drivers=None, is_mgm_only=False, is_interactive=False): import validators import yaml from lab.laboratory import Laboratory if not validators.ipv4(lab_name): if lab_name not in WithMercury.KNOWN_PODS_DIC: raise ValueError('"{}" unknown, possible names are {}'.format( lab_name, WithMercury.KNOWN_PODS_DIC.keys())) else: ip = WithMercury.KNOWN_PODS_DIC[lab_name]['mgm_ip'] else: ip = lab_name mgm = WithMercury.check_mgm_node(ip=ip) separator = 'separator' cmds = [ 'ciscovim install-status', 'cat setup_data.yaml', 'hostname', 'grep -E "image_tag|RELEASE_TAG" defaults.yaml' ] cmd = ' && echo {} && '.format(separator).join(cmds) a = mgm.exe(cmd, is_warn_only=True) if not is_interactive and '| ORCHESTRATION | Success |' not in a: raise RuntimeError('{} is not properly installed'.format(lab_name)) _, setup_data_text, hostname, grep = a.split(separator) setup_data_dic = yaml.load(setup_data_text) driver = setup_data_dic['MECHANISM_DRIVERS'] if allowed_drivers: assert driver.lower( ) in allowed_drivers, 'driver {} not in {}'.format( driver, allowed_drivers) pod = Laboratory( name=lab_name, driver=driver, release_tag=grep.split('\n')[1].split(':')[-1].strip(), gerrit_tag=grep.split('\n')[2].split(':')[-1].strip(), setup_data_dic=setup_data_dic) if is_mgm_only: return mgm WithMercury.create_from_setup_data(pod=pod, mgm=mgm, is_interactive=is_interactive) if pod.driver == WithMercury.VTS: pod.driver_version = pod.vtc.r_vtc_get_version() else: pod.driver_version = 'vpp XXXX' return pod
def create(lab_name, allowed_drivers=None, is_mgm_only=False, is_interactive=False): import validators from lab.laboratory import Laboratory from lab.mercury.nodes import MercuryMgm if not validators.ipv4(lab_name): if lab_name not in WithMercury.KNOWN_PODS_DIC: raise ValueError('"{}" unknown, possible names are {}'.format( lab_name, WithMercury.KNOWN_PODS_DIC.keys())) else: ip = WithMercury.KNOWN_PODS_DIC[lab_name]['mgm_ip'] else: ip = lab_name mgm, status, setup_data_dic, release_tag, gerrit_tag = MercuryMgm.create_from_actual( ip=ip, password=WithMercury.COMMON_PASSWORD) if not is_interactive and '| ORCHESTRATION | Success |' not in status: raise RuntimeError('{} is not properly installed: {}'.format( lab_name, status)) driver = setup_data_dic['MECHANISM_DRIVERS'] if allowed_drivers: assert driver.lower( ) in allowed_drivers, 'driver {} not in {}'.format( driver, allowed_drivers) pod = Laboratory(name=lab_name, driver=driver, release_tag=release_tag, gerrit_tag=gerrit_tag, setup_data_dic=setup_data_dic) if is_mgm_only: return mgm WithMercury.create_from_setup_data(pod=pod, mgm=mgm, is_interactive=is_interactive) if pod.driver == WithMercury.VTS: pod.driver_version = pod.vtc.r_vtc_get_version() else: pod.driver_version = 'vpp XXXX' return pod