def get(environment, driver_id, config, pwd, inf_type, output_format): """Get VIM driver""" vim_mgmt_driver = get_vim_driver_mgmt_driver(environment, config, pwd) if driver_id is None: if inf_type is None: click.echo('Error: Must specify driver-id argument or type option') exit(1) with clirunners.lm_driver_safety(): vim_driver = vim_mgmt_driver.get_vim_driver_by_type(inf_type) else: with clirunners.lm_driver_safety(): vim_driver = vim_mgmt_driver.get_vim_driver(driver_id) click.echo(format_vim_driver(output_format, vim_driver))
def delete(environment, name, config, pwd): ik_driver = get_ik_driver(environment, config, pwd) with clirunners.lm_driver_safety(): ik = ik_driver.get_infrastructure_key_by_name(name) if ik is None: click.echo('Error: No infrastructure key with name: {0}'.format(name), err=True) exit(1) ik_name = ik['name'] click.echo('Deleting infrastructure key: {0}...'.format(ik_name)) with clirunners.lm_driver_safety(): ik_driver.delete_infrastructure_key(ik_name) click.echo('Deleted infrastructure key: {0}'.format(ik_name))
def delete(environment, name, config, pwd): dl_driver = get_dl_driver(environment, config, pwd) with clirunners.lm_driver_safety(): dl_list = dl_driver.get_locations_by_name(name) if len(dl_list) == 0: click.echo('Error: No deployment location with name: {0}'.format(name), err=True) exit(1) matched_dl = dl_list[0] dl_id = matched_dl['id'] click.echo('Deleting deployment location: {0}...'.format(dl_id)) with clirunners.lm_driver_safety(): dl_driver.delete_location(dl_id) click.echo('Deleted deployment location: {0}'.format(dl_id))
def delete(environment, driver_id, config, pwd, inf_type): """Remove a VIM driver by ID or type""" vim_mgmt_driver = get_vim_driver_mgmt_driver(environment, config, pwd) if driver_id is None: if inf_type is None: click.echo('Error: Must specify driver-id argument or type option') exit(1) with clirunners.lm_driver_safety(): vim_driver = vim_mgmt_driver.get_vim_driver_by_type(inf_type) driver_id = vim_driver['id'] click.echo('Found VIM driver matching type \'{0}\'. Id: {1}'.format( inf_type, driver_id)) click.echo('Deleting VIM driver: {0}...'.format(driver_id)) with clirunners.lm_driver_safety(): vim_mgmt_driver.delete_vim_driver(driver_id) click.echo('Deleted VIM driver: {0}'.format(driver_id))
def get(environment, driver_id, config, pwd, driver_type, output_format): """Get resource driver""" resource_mgmt_driver = get_resource_driver_mgmt_driver( environment, config, pwd) if driver_id is None: if driver_type is None: click.echo('Error: Must specify driver-id argument or type option') exit(1) with clirunners.lm_driver_safety(): resource_driver = resource_mgmt_driver.get_resource_driver_by_type( driver_type) else: with clirunners.lm_driver_safety(): resource_driver = resource_mgmt_driver.get_resource_driver( driver_id) click.echo(format_resource_driver(output_format, resource_driver))
def get(environment, name, config, pwd, output_format): dl_driver = get_dl_driver(environment, config, pwd) with clirunners.lm_driver_safety(): dl_list = dl_driver.get_locations_by_name(name) if len(dl_list) == 0: click.echo('Error: No deployment location with name: {0}'.format(name), err=True) exit(1) matched_dl = dl_list[0] click.echo(format_dl(output_format, matched_dl))
def get(environment, name, config, pwd, output_format): """Get infrastructure key""" infrastructure_keys = get_ik_driver(environment, config, pwd) with clirunners.lm_driver_safety(): infrastructure_key = infrastructure_keys.get_infrastructure_key_by_name( name) if infrastructure_key is None: click.echo('Error: No infrastructure key with name: {0}'.format(name), err=True) exit(1) else: click.echo(format_ik(output_format, infrastructure_key))
def add(environment, config, pwd, inf_type, url, certificate, output_format): """Add a VIM driver""" vim_mgmt_driver = get_vim_driver_mgmt_driver(environment, config, pwd) new_vim_driver = {'infrastructureType': inf_type, 'baseUri': url} if certificate is not None: try: new_vim_driver['certificate'] = read_certificate_file(certificate) except IOError as e: click.echo('Error: reading certificate: {0}'.format(str(e)), err=True) exit(1) with clirunners.lm_driver_safety(): vim_driver = vim_mgmt_driver.add_vim_driver(new_vim_driver) click.echo(format_vim_driver(output_format, vim_driver))
def add(environment, name, config, pwd, rm, infrastructure_type, description, properties, output_format): dl_driver = get_dl_driver(environment, config, pwd) new_dl = { 'name': name, 'description': description, 'resourceManager': rm, 'infrastructureType': infrastructure_type } if properties is not None: loaded_properties = load_properties_file(properties) new_dl['infrastructureSpecificProperties'] = loaded_properties else: new_dl['infrastructureSpecificProperties'] = {} with clirunners.lm_driver_safety(): new_dl = dl_driver.add_location(new_dl) click.echo(format_dl(output_format, new_dl))
def add(environment, config, pwd, driver_type, url, certificate, output_format): """Add a resource driver""" resource_mgmt_driver = get_resource_driver_mgmt_driver( environment, config, pwd) new_resource_driver = {'type': driver_type, 'baseUri': url} if certificate is not None: try: new_resource_driver['certificate'] = read_certificate_file( certificate) except IOError as e: click.echo('Error: reading certificate: {0}'.format(str(e)), err=True) exit(1) with clirunners.lm_driver_safety(): resource_driver = resource_mgmt_driver.add_resource_driver( new_resource_driver) click.echo(format_resource_driver(output_format, resource_driver))
def add(environment, name, config, pwd, public_key, private_key, description, output_format): ik_driver = get_ik_driver(environment, config, pwd) new_ik = { 'name': name, } if description is not None: new_ik['description'] = description if public_key is not None: loaded_public = load_key_file(public_key, 'public') new_ik['publicKey'] = loaded_public if private_key is not None: loaded_private = load_key_file(private_key, 'private') new_ik['privateKey'] = loaded_private with clirunners.lm_driver_safety(): new_ik = ik_driver.add_infrastructure_key(new_ik) click.echo(format_ik(output_format, new_ik))
def list_keys(environment, config, pwd, output_format): ik_driver = get_ik_driver(environment, config, pwd) with clirunners.lm_driver_safety(): ik_list = ik_driver.get_infrastructure_keys() result = format_ik_list(output_format, ik_list) click.echo(result)
def list_locations(environment, config, pwd, output_format): dl_driver = get_dl_driver(environment, config, pwd) with clirunners.lm_driver_safety(): dl_list = dl_driver.get_locations() result = format_dl_list(output_format, dl_list) click.echo(result)