def main(): logger.info("Generating OpenStack snapshot...") nova_client = os_utils.get_nova_client() neutron_client = os_utils.get_neutron_client() keystone_client = os_utils.get_keystone_client() cinder_client = os_utils.get_cinder_client() if not os_utils.check_credentials(): logger.error("Please source the openrc credentials and run the" + "script again.") exit(-1) snapshot = {} snapshot.update(get_instances(nova_client)) snapshot.update(get_images(nova_client)) snapshot.update(get_volumes(cinder_client)) snapshot.update(get_networks(neutron_client)) snapshot.update(get_routers(neutron_client)) snapshot.update(get_security_groups(neutron_client)) snapshot.update(get_floatinips(nova_client)) snapshot.update(get_users(keystone_client)) snapshot.update(get_tenants(keystone_client)) with open(OS_SNAPSHOT_FILE, 'w+') as yaml_file: yaml_file.write(yaml.safe_dump(snapshot, default_flow_style=False)) yaml_file.seek(0) logger.debug("Openstack Snapshot found in the deployment:\n%s" % yaml_file.read()) logger.debug("NOTE: These objects will NOT be deleted after " + "running the test.")
def main(): logging.basicConfig() logger.info("Cleaning OpenStack resources...") nova_client = os_utils.get_nova_client() neutron_client = os_utils.get_neutron_client() keystone_client = os_utils.get_keystone_client() cinder_client = os_utils.get_cinder_client() glance_client = os_utils.get_glance_client() try: with open(OS_SNAPSHOT_FILE) as f: snapshot_yaml = yaml.safe_load(f) except Exception: logger.info("The file %s does not exist. The OpenStack snapshot must" " be created first. Aborting cleanup." % OS_SNAPSHOT_FILE) return 0 default_images = snapshot_yaml.get('images') default_instances = snapshot_yaml.get('instances') default_volumes = snapshot_yaml.get('volumes') default_networks = snapshot_yaml.get('networks') default_routers = snapshot_yaml.get('routers') default_security_groups = snapshot_yaml.get('secgroups') default_floatingips = snapshot_yaml.get('floatingips') default_users = snapshot_yaml.get('users') default_tenants = snapshot_yaml.get('tenants') if not os_utils.check_credentials(): logger.error("Please source the openrc credentials and run " "the script again.") return -1 remove_instances(nova_client, default_instances) separator() remove_images(glance_client, default_images) separator() remove_volumes(cinder_client, default_volumes) separator() remove_floatingips(neutron_client, default_floatingips) separator() remove_networks(neutron_client, default_networks, default_routers) separator() remove_security_groups(neutron_client, default_security_groups) separator() remove_users(keystone_client, default_users) separator() remove_tenants(keystone_client, default_tenants) separator() return 0
def main(): creds_nova = os_utils.get_credentials("nova") nova_client = novaclient.Client('2', **creds_nova) creds_neutron = os_utils.get_credentials("neutron") neutron_client = neutronclient.Client(**creds_neutron) creds_keystone = os_utils.get_credentials("keystone") keystone_client = keystoneclient.Client(**creds_keystone) creds_cinder = os_utils.get_credentials("cinder") cinder_client = cinderclient.Client('1', creds_cinder['username'], creds_cinder['api_key'], creds_cinder['project_id'], creds_cinder['auth_url'], service_type="volume") if not os_utils.check_credentials(): logger.error("Please source the openrc credentials and run the" + "script again.") exit(-1) defaults = {} defaults.update(get_instances(nova_client)) defaults.update(get_images(nova_client)) defaults.update(get_volumes(cinder_client)) defaults.update(get_networks(neutron_client)) defaults.update(get_routers(neutron_client)) defaults.update(get_security_groups(neutron_client)) defaults.update(get_floatinips(nova_client)) defaults.update(get_users(keystone_client)) defaults.update(get_tenants(keystone_client)) with open(DEFAULTS_FILE, 'w+') as yaml_file: yaml_file.write(yaml.safe_dump(defaults, default_flow_style=False)) yaml_file.seek(0) logger.info("Openstack Defaults found in the deployment:\n%s" % yaml_file.read()) logger.debug("NOTE: These objects will NOT be deleted after " + "running the tests.")
def main(): creds_nova = os_utils.get_credentials("nova") nova_client = novaclient.Client('2', **creds_nova) creds_neutron = os_utils.get_credentials("neutron") neutron_client = neutronclient.Client(**creds_neutron) creds_keystone = os_utils.get_credentials("keystone") keystone_client = keystoneclient.Client(**creds_keystone) creds_cinder = os_utils.get_credentials("cinder") cinder_client = cinderclient.Client('1', creds_cinder['username'], creds_cinder['api_key'], creds_cinder['project_id'], creds_cinder['auth_url'], service_type="volume") if not os_utils.check_credentials(): logger.error("Please source the openrc credentials and run the" + "script again.") exit(-1) snapshot = {} snapshot.update(get_instances(nova_client)) snapshot.update(get_images(nova_client)) snapshot.update(get_volumes(cinder_client)) snapshot.update(get_networks(neutron_client)) snapshot.update(get_routers(neutron_client)) snapshot.update(get_security_groups(neutron_client)) snapshot.update(get_floatinips(nova_client)) snapshot.update(get_users(keystone_client)) snapshot.update(get_tenants(keystone_client)) with open(OS_SNAPSHOT_FILE, 'w+') as yaml_file: yaml_file.write(yaml.safe_dump(snapshot, default_flow_style=False)) yaml_file.seek(0) logger.debug("Openstack Snapshot found in the deployment:\n%s" % yaml_file.read()) logger.debug("NOTE: These objects will NOT be deleted after " + "running the test.")
def main(): logger.info("Cleaning OpenStack resources...") nova_client = os_utils.get_nova_client() neutron_client = os_utils.get_neutron_client() keystone_client = os_utils.get_keystone_client() cinder_client = os_utils.get_cinder_client() tacker_client = os_tacker.get_tacker_client() try: with open(OS_SNAPSHOT_FILE) as f: snapshot_yaml = yaml.safe_load(f) except Exception: logger.info("The file %s does not exist. The OpenStack snapshot must" " be created first. Aborting cleanup." % OS_SNAPSHOT_FILE) exit(0) default_images = snapshot_yaml.get('images') default_instances = snapshot_yaml.get('instances') default_volumes = snapshot_yaml.get('volumes') default_networks = snapshot_yaml.get('networks') default_routers = snapshot_yaml.get('routers') default_security_groups = snapshot_yaml.get('secgroups') default_floatingips = snapshot_yaml.get('floatingips') default_users = snapshot_yaml.get('users') default_tenants = snapshot_yaml.get('tenants') default_vnfds = snapshot_yaml.get('vnfds') default_vnfs = snapshot_yaml.get('vnfs') default_sfcs = snapshot_yaml.get('sfcs') default_sfc_classifiers = snapshot_yaml.get('sfc_classifiers') if not os_utils.check_credentials(): logger.error("Please source the openrc credentials and run " "the script again.") exit(-1) remove_instances(nova_client, default_instances) separator() remove_images(nova_client, default_images) separator() remove_volumes(cinder_client, default_volumes) separator() remove_floatingips(nova_client, default_floatingips) separator() remove_networks(neutron_client, default_networks, default_routers) separator() remove_security_groups(neutron_client, default_security_groups) separator() remove_users(keystone_client, default_users) separator() remove_tenants(keystone_client, default_tenants) separator() # Note: Delete in this order # 1. Classifiers, 2. SFCs, 3. VNFs, 4. VNFDs remove_tacker_sfc_classifiers(tacker_client, default_sfc_classifiers) separator() remove_tacker_sfcs(tacker_client, default_sfcs) separator() remove_tacker_vnfs(tacker_client, default_vnfs) separator() remove_tacker_vnfds(tacker_client, default_vnfds) separator()
def main(): logger.info("+++++++++++++++++++++++++++++++") logger.info("Cleaning OpenStack resources...") logger.info("+++++++++++++++++++++++++++++++") try: with open(OS_SNAPSHOT_FILE) as f: snapshot_yaml = yaml.safe_load(f) except Exception: logger.info("The file %s does not exist. The OpenStack snapshot must" " be created first. Aborting cleanup." % OS_SNAPSHOT_FILE) exit(0) default_images = snapshot_yaml.get('images') default_instances = snapshot_yaml.get('instances') default_volumes = snapshot_yaml.get('volumes') default_networks = snapshot_yaml.get('networks') default_routers = snapshot_yaml.get('routers') default_security_groups = snapshot_yaml.get('secgroups') default_floatingips = snapshot_yaml.get('floatingips') default_users = snapshot_yaml.get('users') default_tenants = snapshot_yaml.get('tenants') creds_nova = os_utils.get_credentials("nova") nova_client = novaclient.Client('2', **creds_nova) creds_neutron = os_utils.get_credentials("neutron") neutron_client = neutronclient.Client(**creds_neutron) creds_keystone = os_utils.get_credentials("keystone") keystone_client = keystoneclient.Client(**creds_keystone) creds_cinder = os_utils.get_credentials("cinder") # cinder_client = cinderclient.Client(**creds_cinder) cinder_client = cinderclient.Client('1', creds_cinder['username'], creds_cinder['api_key'], creds_cinder['project_id'], creds_cinder['auth_url'], service_type="volume") if not os_utils.check_credentials(): logger.error("Please source the openrc credentials and run " "the script again.") exit(-1) remove_instances(nova_client, default_instances) separator() remove_images(nova_client, default_images) separator() remove_volumes(cinder_client, default_volumes) separator() remove_floatingips(nova_client, default_floatingips) separator() remove_networks(neutron_client, default_networks, default_routers) separator() remove_security_groups(neutron_client, default_security_groups) separator() remove_users(keystone_client, default_users) separator() remove_tenants(keystone_client, default_tenants) separator()
def main(): logger.info("+++++++++++++++++++++++++++++++") logger.info("Cleaning OpenStack resources...") logger.info("+++++++++++++++++++++++++++++++") try: with open(DEFAULTS_FILE) as f: defaults_yaml = yaml.safe_load(f) except Exception: logger.info("The file %s does not exist. The OpenStack snapshot must" " be created first. Aborting cleanup." % DEFAULTS_FILE) exit(0) default_images = defaults_yaml.get('images') default_instances = defaults_yaml.get('instances') default_volumes = defaults_yaml.get('volumes') default_networks = defaults_yaml.get('networks') default_routers = defaults_yaml.get('routers') default_security_groups = defaults_yaml.get('secgroups') default_floatingips = defaults_yaml.get('floatingips') default_users = defaults_yaml.get('users') default_tenants = defaults_yaml.get('tenants') creds_nova = os_utils.get_credentials("nova") nova_client = novaclient.Client('2', **creds_nova) creds_neutron = os_utils.get_credentials("neutron") neutron_client = neutronclient.Client(**creds_neutron) creds_keystone = os_utils.get_credentials("keystone") keystone_client = keystoneclient.Client(**creds_keystone) creds_cinder = os_utils.get_credentials("cinder") # cinder_client = cinderclient.Client(**creds_cinder) cinder_client = cinderclient.Client('1', creds_cinder['username'], creds_cinder['api_key'], creds_cinder['project_id'], creds_cinder['auth_url'], service_type="volume") if not os_utils.check_credentials(): logger.error("Please source the openrc credentials and run " "the script again.") exit(-1) remove_instances(nova_client, default_instances) separator() remove_images(nova_client, default_images) separator() remove_volumes(cinder_client, default_volumes) separator() remove_floatingips(nova_client, default_floatingips) separator() remove_networks(neutron_client, default_networks, default_routers) separator() remove_security_groups(neutron_client, default_security_groups) separator() remove_users(keystone_client, default_users) separator() remove_tenants(keystone_client, default_tenants) separator()