def __init__(self, authdata, port, address, instance, user, password, tenant, auth_url, project, user_domain, project_domain, cache_status, os_cloud): super(OpenStackBmc, self).__init__(authdata, port=port, address=address) if os_client_config: if user: # NOTE(bnemec): This is deprecated. clouds.yaml is a much # more robust way to specify auth details. kwargs = dict(os_username=user, os_password=password, os_project_name=tenant, os_auth_url=auth_url, os_user_domain=user_domain, os_project_domain=project_domain) self.novaclient = os_client_config.make_client('compute', **kwargs) else: self.novaclient = os_client_config.make_client('compute', cloud=os_cloud) else: # NOTE(bnemec): This path was deprecated 2017-7-17 self.log(NO_OCC_DEPRECATION) if '/v3' not in auth_url: # novaclient 7+ is backwards-incompatible :-( if int(nc.__version__[0]) <= 6: self.novaclient = novaclient.Client(2, user, password, tenant, auth_url) else: self.novaclient = novaclient.Client(2, user, password, auth_url=auth_url, project_name=tenant) else: self.novaclient = novaclient.Client( 2, user, password, auth_url=auth_url, project_name=project, user_domain_name=user_domain, project_domain_name=project_domain ) self.instance = None self.cache_status = cache_status self.cached_status = None self.target_status = None # At times the bmc service is started before important things like # networking have fully initialized. Keep trying to find the # instance indefinitely, since there's no point in continuing if # we don't have an instance. while True: try: self.instance = self._find_instance(instance) if self.instance is not None: name = self.novaclient.servers.get(self.instance).name self.log('Managing instance: %s UUID: %s' % (name, self.instance)) break except Exception as e: self.log('Exception finding instance "%s": %s' % (instance, e)) time.sleep(1)
def authenticate(self, username, password, tenant, region, domain_id, project_name): """ Authenticate to openstack env `username` username to authenticate to openstack `password` password to send `tenant` tenant to authenticate under `region` region to authenticate under """ self.__heat_client = os_client_config.make_client( 'orchestration', auth_url=self.identity_url, username=username, password=password, project_id=tenant, region_name=region, domain_id=domain_id, project_name=project_name) self.__nova_client = os_client_config.make_client( 'compute', auth_url=self.identity_url, username=username, password=password, project_id=tenant, region_name=region, domain_id=domain_id, project_name=project_name) self.__cinder_client = os_client_config.make_client( 'volume', auth_url=self.identity_url, username=username, password=password, project_id=tenant, region_name=region, domain_id=domain_id, project_name=project_name) self.__glance_client = os_client_config.make_client( 'image', auth_url=self.identity_url, username=username, password=password, project_id=tenant, region_name=region, domain_id=domain_id, project_name=project_name) self.__neutron_client = os_client_config.make_client( 'network', auth_url=self.identity_url, username=username, password=password, project_id=tenant, region_name=region, domain_id=domain_id, project_name=project_name) # this next line is needed because for v2 apis that are after a certain release stopped providing version info in keytone url but rackspace did not self.__neutron_client.action_prefix = "" self.__auth_resp = True
def _get_clients(): cloud = os.environ.get('OS_CLOUD') if cloud: import os_client_config nova = os_client_config.make_client('compute', cloud=cloud) neutron = os_client_config.make_client('network', cloud=cloud) glance = os_client_config.make_client('image', cloud=cloud) else: auth_data = auth._create_auth_parameters() username = auth_data['os_user'] password = auth_data['os_password'] tenant = auth_data['os_tenant'] auth_url = auth_data['os_auth_url'] project = auth_data['os_project'] user_domain = auth_data['os_user_domain'] project_domain = auth_data['os_project_domain'] if '/v3' not in auth_url: # novaclient 7+ is backwards-incompatible :-( if int(nc.__version__[0]) <= 6: nova = novaclient.Client(2, username, password, tenant, auth_url) else: nova = novaclient.Client(2, username, password, auth_url=auth_url, project_name=tenant) neutron = neutronclient.Client(username=username, password=password, tenant_name=tenant, auth_url=auth_url) else: nova = novaclient.Client(2, username, password, auth_url=auth_url, project_name=project, user_domain_name=user_domain, project_domain_name=project_domain) sess = auth._get_keystone_session(auth_data) neutron = neutronclient.Client(session=sess) token, glance_endpoint = auth._get_token_and_endpoint('glance') glance = glanceclient.Client('2', token=token, endpoint=glance_endpoint) return nova, neutron, glance
def main(var): """Main function to start and monitor the VM""" vm = None var = getEnvironmentVars(var) result = runCmd("/opt/moab/bin/checkjob --xml " + var['pbs-jobid']) moabVars = getMoabVars(result) logger.info("Connecting to OpenStack ...") nova = os_client_config.make_client('compute', auth_url=var['os-auth-url'], username=var['os-username'], password=var['os-password'], project_name=var['os-project-name'], region_name=var['os-region-name'], user_domain_name='Default', project_domain_name='Default', timeout=600.0, connection_pool=True) logger.info("Get nova vm by id=%s", moabVars['VM-ID']) vm = nova.servers.get(moabVars['VM-ID']) logger.info("Terminating VM...") deleteVM(nova, vm) logger.info("Job finished!") return
def __init__(self, params): super(Volume, self).__init__(params) self.cinderclient = os_client_config.make_client( 'volume', **self.nova_credential) self.volume_back = self.cinderclient.backups self.volume_type = self.cinderclient.volume_types
def __init__(self, authdata, port, address, instance, cache_status, os_cloud): super(OpenStackBmc, self).__init__(authdata, port=port, address=address) self.novaclient = os_client_config.make_client('compute', cloud=os_cloud) self.instance = None self.cache_status = cache_status self.cached_status = None self.cached_task = None self.target_status = None # At times the bmc service is started before important things like # networking have fully initialized. Keep trying to find the # instance indefinitely, since there's no point in continuing if # we don't have an instance. while True: try: self.instance = self._find_instance(instance) if self.instance is not None: name = self.novaclient.servers.get(self.instance).name self.log('Managing instance: %s UUID: %s' % (name, self.instance)) break except Exception as e: self.log('Exception finding instance "%s": %s' % (instance, e)) time.sleep(1)
def _get_heat_client(): cloud = os.environ.get('OS_CLOUD') if cloud: import os_client_config return os_client_config.make_client('orchestration', cloud=cloud) else: username = os.environ.get('OS_USERNAME') password = os.environ.get('OS_PASSWORD') tenant = os.environ.get('OS_TENANT_NAME') auth_url = os.environ.get('OS_AUTH_URL') if not username or not password or not tenant or not auth_url: print('Source an appropriate rc file first') sys.exit(1) # Get token for Heat to use kclient = keystone_client.Client(username=username, password=password, tenant_name=tenant, auth_url=auth_url) token_data = kclient.get_raw_token_from_identity_service( username=username, password=password, tenant_name=tenant, auth_url=auth_url) token_id = token_data['token']['id'] # Get Heat endpoint for endpoint in token_data['serviceCatalog']: if endpoint['name'] == 'heat': # TODO: What if there's more than one endpoint? heat_endpoint = endpoint['endpoints'][0]['publicURL'] return heat_client.Client('1', endpoint=heat_endpoint, token=token_id)
def get_client(self): """Creates a keystoneclient instance to run functional tests The client is instantiated via os-client-config either based on a clouds.yaml config file or from the environment variables. First, look for a 'functional_admin' cloud, as this is a cloud that the user may have defined for functional testing with admin credentials. If that is not found, check for the 'devstack-admin' cloud. Finally, fall back to looking for environment variables. """ IDENTITY_CLIENT = "identity" OPENSTACK_CLOUDS = ("functional_admin", "devstack-admin", "envvars") for cloud in OPENSTACK_CLOUDS: try: return os_client_config.make_client( IDENTITY_CLIENT, client.Client, cloud=cloud, identity_api_version=self.version ) except os_client_config.exceptions.OpenStackConfigException: pass raise Exception( "Could not find any cloud definition for clouds named" " functional_admin or devstack-admin. Check your" " clouds.yaml file or your envvars and try again." )
def get_client(self): """Creates a keystoneclient instance to run functional tests The client is instantiated via os-client-config either based on a clouds.yaml config file or from the environment variables. First, look for a 'functional_admin' cloud, as this is a cloud that the user may have defined for functional testing with admin credentials. If that is not found, check for the 'devstack-admin' cloud. Finally, fall back to looking for environment variables. """ IDENTITY_CLIENT = 'identity' OPENSTACK_CLOUDS = ('functional_admin', 'devstack-admin', 'envvars') for cloud in OPENSTACK_CLOUDS: try: return os_client_config.make_client( IDENTITY_CLIENT, client.Client, cloud=cloud, identity_api_version=self.version) except os_client_config.exceptions.OpenStackConfigException: pass raise Exception("Could not find any cloud definition for clouds named" " functional_admin or devstack-admin. Check your" " clouds.yaml file or your envvars and try again.")
def __init__(self, params): super(Ceilometer, self).__init__(params) self.ceilometerclient = os_client_config.make_client( 'metering', **self.ceilometer_credential) self.alarm_utils = self.ceilometerclient.alarms self.query_alarms_utils = self.ceilometerclient.query_alarms self.query_alarm_history_utils = self.ceilometerclient.query_alarm_history
def make_keystone_client(): legacy_client = os_client_config.make_client('identity', auth_url=auth_url, username=username, password=password, project_name=project_name, region_name=region_name) return legacy_client
def make_nova_client(): legacy_client = os_client_config.make_client('compute', auth_url=auth_url, username=username, password=password, project_name=project_name, region_name=region_name) return legacy_client
def make_glance_client(): legacy_client = os_client_config.make_client('image', auth_url=auth_url, username=username, password=password, project_name=project_name, region_name=region_name) return legacy_client
def make_neutron_client(): legacy_client = os_client_config.make_client('network', auth_url=auth_url, username=username, password=password, project_name=project_name, region_name=region_name) return legacy_client
def _get_heat_client(): cloud = os.environ.get('OS_CLOUD') if cloud: import os_client_config return os_client_config.make_client('orchestration', cloud=cloud) else: token_id, heat_endpoint = auth._get_token_and_endpoint('heat') return heat_client.Client('1', endpoint=heat_endpoint, token=token_id)
def get_client(self, client_type, project_name, region_name): return os_client_config.make_client(client_type, auth_url='http://' + self.ip + ':5000/v2.0', username=self.username, password=self.password, project_name=project_name, region_name=region_name)
def sessions(): return os_client_config.make_client( 'compute', auth_url=os.environ['OS_AUTH_URL'], username=os.environ['OS_USERNAME'], password=os.environ['OS_PASSWORD'], project_name=os.environ['OS_TENANT_NAME'], region_name=os.environ['OS_REGION_NAME'], )
def get_client(service, cloud=False): """get openstack service client connection :param service: service name (str) :param cloud: clouds.yaml cloud name (optional) :return: service client connection """ if cloud: try: return os_client_config.make_client(service, cloud=cloud) except OpenStackConfigException: print('cloud config for %s not found' % cloud) return False else: try: return os_client_config.make_client(service) except (OpenStackConfigException, MissingRequiredOptions): print('%s client connection failed' % service) return False
def _new_client(self): self.__connected = False return os_client_config.make_client( 'compute', auth_url=self.os_auth_url, username=self.os_username, password=self.os_password, project_name=self.os_tenant_name, region_name=self.os_region_name, )
def _new_clients(self): self.__connected = False for kind in ['compute', 'image', 'network']: yield os_client_config.make_client( kind, auth_url=self.os_auth_url, username=self.os_username, password=self.os_password, project_name=self.os_tenant_name, region_name=self.os_region_name, )
def __init__(self, region): try: os_cfg = cfg['openstack'] credentials = { "version": os_cfg['OS_COMPUTE_API_VERSION'], "auth_url": os_cfg['OS_AUTH_URL'], "username": os_cfg['OS_USERNAME'], "password": os_cfg['OS_PASSWORD'], "project_name": os_cfg['OS_PROJECT_NAME'], "region_name": region } self.nova = os_client_config.make_client('compute', **credentials) self.glance = os_client_config.make_client('image', **credentials) self.neutron = os_client_config.make_client( 'network', **credentials) except FileNotFoundError: click.secho('OpenStack configuration not found.', fg='red') exit()
def _get_clients(): cloud = os.environ.get('OS_CLOUD') if cloud: import os_client_config nova = os_client_config.make_client('compute', cloud=cloud) neutron = os_client_config.make_client('network', cloud=cloud) else: username = os.environ.get('OS_USERNAME') password = os.environ.get('OS_PASSWORD') tenant = os.environ.get('OS_TENANT_NAME') auth_url = os.environ.get('OS_AUTH_URL') if not username or not password or not tenant or not auth_url: print('Source an appropriate rc file first') sys.exit(1) nova = novaclient.Client(2, username, password, tenant, auth_url) neutron = neutronclient.Client(username=username, password=password, tenant_name=tenant, auth_url=auth_url) return nova, neutron
def random_evict(src, dest): s = None nova = os_client_config.make_client('compute', cloud='devstack-admin') for server in nova.servers.list(): dd = server.to_dict() if dd['OS-EXT-SRV-ATTR:host'] == src: s = server break if s == None: logging.error('No instance to move on {}'.format(src)) return logging.info('Migrating {} to {}'.format(s.human_id, dest)) s.live_migrate(host=dest, block_migration=True)
def main(): parser = argparse.ArgumentParser( description='Migrate a random instance from host x to host y.') parser.add_argument( '--dest', dest='host_to_move_to', default='capstone1', help='hostname destination to move to (default: capstone1') parser.add_argument('--source', dest='host_to_move_from', default='capstone0', help='hostname source (default: capstone0') args = parser.parse_args() host_to_move_to = args.host_to_move_to host_to_move_from = args.host_to_move_from #create a connection object for the given cloud - devstack (found in clouds.yaml) # so we're creating with user admin conn = connection.from_config(cloud_name='devstack-admin') nova = os_client_config.make_client('compute', cloud='devstack-admin') # finding the server to move ----------------- server_to_move = None for server in nova.servers.list(): # check that the hostname is the same dd = server.to_dict() if (dd['OS-EXT-SRV-ATTR:host'] == host_to_move_from): server_to_move = server break # other variables --------------------------- # flavor id. we're using "tiny" by default fid = '1' #image id (cirros): there's only one iid = conn.compute.images().next().id # destination host logic ------------------- if server_to_move == None: print "There are no servers on " + host_to_move_from sys.exit() print("now migrating " + server_to_move.human_id + " to: " + host_to_move_to) print("that's id: " + str(server_to_move.id)) server_to_move.live_migrate(host=host_to_move_to, block_migration=True)
def main(): global module global compute_client global network_client compute_client = os_client_config.make_client("compute") network_client = os_client_config.make_client("network") fields = { "server": {"required": True, "type": "str"}, "fixed_address": {"type": "str"}, "state": { "default": "present", "choices": ["present", "absent"], "type": "str" }, "network": {"required": True, "type": "str"}, "reuse": { "default": True, "type": "bool" } } module = AnsibleModule(argument_spec=fields) server = module.params["server"] fixed_address = module.params["fixed_address"] lock_file = open("/tmp/hos_lock", 'w') fcntl.flock(lock_file.fileno(), fcntl.LOCK_EX) if not fixed_address: fixed_address = nova_get_server_fixed_address(server) network = module.params["network"] reuse = module.params["reuse"] state = module.params["state"] curr_ips = neutron_list_floating_ips() fl = [ r for r in curr_ips if r["fixed_ip_address"] == fixed_address ] if state == "absent": ensure_not_linked(fl) else: available_ips = [ r for r in curr_ips if not r["fixed_ip_address"] ] ensure_linked(fl, available_ips, fixed_address, network, reuse) lock_file.close()
def _get_clients(): cloud = os.environ.get('OS_CLOUD') if cloud: import os_client_config nova = os_client_config.make_client('compute', cloud=cloud) neutron = os_client_config.make_client('network', cloud=cloud) else: username = os.environ.get('OS_USERNAME') password = os.environ.get('OS_PASSWORD') tenant = os.environ.get('OS_TENANT_NAME') auth_url = os.environ.get('OS_AUTH_URL') if not username or not password or not tenant or not auth_url: print('Source an appropriate rc file first') sys.exit(1) nova = novaclient.Client(2, username, password, tenant, auth_url) neutron = neutronclient.Client( username=username, password=password, tenant_name=tenant, auth_url=auth_url ) return nova, neutron
def __init__(self, version, username, password, project_name, auth_url, insecure=False): self.nova_api = os_client_config.make_client('compute', version=version, username=username, password=password, project_name=project_name, auth_url=auth_url, insecure=str(insecure))
def __init__(self, auth_url=None, username=None, password=None, identity_api_version=None, project_name=None, project_domain_name=None, user_domain_name=None): try: self.keystone_client = os_client_config.make_client('identity', auth_url=auth_url, username=username, password=password, identity_api_version=identity_api_version, project_name=project_name, project_domain_name=project_domain_name, user_domain_name=user_domain_name) self.tacker_client = TackerClient(api_version='1.0', session=self.keystone_client.session) except Exception as e: LOG.exception(e) raise TackerEmAdapterError('Unable to create %s instance - %s' % (self.__class__.__name__, e))
def do(self): nova = os_client_config.make_client('compute', cloud='envvars') for server in nova.servers.list(): print("[%s]" % server.name) print(server.networks['ctlplane'][0]) print("[%s:vars]" % server.name) print("ipa_realm=AYOUNG.DELLT1700.TEST") if server.name == 'ipa': print("cloud_user=centos") else: print("cloud_user=heat-admin") print("ipa_server_password=FreeIPA4All") print("ipa_domain=ayoung.dellt1700.test") print("ipa_forwarder=192.168.122.1") print("ipa_admin_user_password=FreeIPA4All") print("ipa_nova_join=False") print("nameserver=192.168.52.4") print("")
def __init__(self, params): super(Compute, self).__init__(params) self.novaclient = os_client_config.make_client('compute', **self.nova_credential) self.network_utils = network.Network(params) self.image_client = self.novaclient.images self.server_client = self.novaclient.servers self.flavor_client = self.novaclient.flavors self.volume_client = self.novaclient.volumes self.volume_utils = volume.Volume(params) self.hosts_client = self.novaclient.hosts self.keypairs_client = self.novaclient.keypairs self.server_group_client = self.novaclient.server_groups self.hypervisor_client = self.novaclient.hypervisors self.quotas_client = self.novaclient.quotas self.usage_client = self.novaclient.usage self.limits_client = self.novaclient.limits
def getVMnet(var): logger.info("Converting VM Name to VM IP") pos = re.search("\d", var['vm-name']) vm_ip = var['vm-name'].replace('-', '.')[pos.start():] logger.info("VM IP is set to: %s", vm_ip) neutron = os_client_config.make_client('network', auth_url=var['os-auth-url'], username=var['os-username'], password=var['os-password'], project_name=var['os-project-name'], region_name=var['os-region-name'], user_domain_name='Default', project_domain_name='Default', timeout=600.0, connection_pool=True) network = neutron.list_networks(tenant_id=var['os-project-id']) network_id = network['networks'][0]['id'] logger.info("Neutron Network ID is: %s", network_id) return [{'net-id': network_id, 'v4-fixed-ip': vm_ip}]
def __init__(self, **kwargs): self.kind = 'openstack' super(OpenStackInput, self).__init__(**kwargs) try: self.name = kwargs['name'] except KeyError: raise ValueError('Missing parameter name') self.scope = kwargs['scope'] self.region = kwargs.get('region', 'RegionOne') self.identity_api = os_client_config.make_client('identity', cloud=self.name) self.compute_api = os_client_config.make_client('compute', cloud=self.name) self.network_api = os_client_config.make_client('network', cloud=self.name) self.orch_api = os_client_config.make_client('orchestration', cloud=self.name) self.image_api = os_client_config.make_client('image', cloud=self.name) self.volume_api = os_client_config.make_client('volume', cloud=self.name)
def get_hypervisor_id(hostname): # construct legancy client, using OS_ environment variables nova = os_client_config.make_client('compute') h = nova.hypervisors.find(hypervisor_hostname = hostname) return h.id
def neutron_client_factory(resolver, name=None): neutron = os_client_config.make_client('network') neutron.format = 'json' return neutron
def nova_client_factory(resolver, name=None): nova_client = os_client_config.make_client('compute') return nova_client
def glance_client_factory(resolver, name=None): glance_client = os_client_config.make_client('image') return glance_client
def client(url=None, username=None, password=None, tenant=None): return os_client_config.make_client('compute', auth_url=url, username=username, password=password, project_name=tenant)
# a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import os import sys import keystoneauth1 import os_client_config import shade import yaml CLOUDNAME = 'service' cloud = shade.operator_cloud(cloud=CLOUDNAME) keystone = os_client_config.make_client('identity', cloud=CLOUDNAME) try: keystone.endpoint_filter.add_endpoint_group_to_project( endpoint_group=os.environ.get("ENDPOINT_GROUP"), project=os.environ.get("PROJECT") ) except keystoneauth1.exceptions.http.Conflict: pass
def send_mail(to, payload): result = requests.post( MAILGUNAPI, auth=("api", MAILGUNKEY), data={"from": MAILGUNFROM, "to": to, "subject": payload["subject"], "text": payload["body"]}) print(result.text) # preparations cloud = shade.openstack_cloud(cloud=CLOUDNAME) cinder = os_client_config.make_client("volume", cloud=CLOUDNAME) glance = os_client_config.make_client("image", cloud=CLOUDNAME) nova = os_client_config.make_client("compute", cloud=CLOUDNAME) result = cloud.get_domain(name_or_id=DOMAINNAME) domain_id = result.id result = cloud.get_project(PROJECTNAME, domain_id=domain_id) project_id = result.id utc = pytz.UTC now = utc.localize(datetime.now()) # floating ips result = cloud.list_floating_ips(filters={"project_id": project_id})
def get_fixed_ip(vm): for net in vm.addresses: addr = vm.addresses[net] for ip in addr: if ip['OS-EXT-IPS:type'] == 'fixed': return ip['addr'] def get_float_ip(vm): for net in vm.addresses: addr = vm.addresses[net] for ip in addr: if ip['OS-EXT-IPS:type'] == 'floating': return ip['addr'] nova = os_client_config.make_client('compute', cloud='amt') m_flavor_id = nova.flavors.find(name='m1.medium') a_flavor_id = nova.flavors.find(name='m1.large') for image in nova.images.list(): if node_distr.lower() in image.name.lower(): image_id = image.id #Create new key pairs ans save private key in file for key in nova.keypairs.list(): if 'dcos_key' == key.id: nova.keypairs.delete(key) new_key = nova.keypairs.create(name='dcos_key') key_id = new_key.id key_file = 'dcos_key.key'
import os_client_config cloud = "devstack" cloud_config = os_client_config.OpenStackConfig().get_one_cloud(cloud) keystone_session = os_client_config.make_client('identity', cloud=cloud)
) attach = True if attach: cloud.add_router_interface(router, subnet_id=subnet.id) # load configurations with open("etc/quotaclasses.yml", "r") as fp: quotaclasses = yaml.load(fp) # get connections cloud = openstack.connect(cloud=CLOUDNAME) neutron = os_client_config.make_client("network", cloud=CLOUDNAME) # check existence of project project = cloud.get_project(PROJECT) if not project: logging.error("project %s does not exist" % PROJECT) sys.exit(1) if project.domain_id == "default": logging.error("projects in the default domain are not managed") sys.exit(1) # prepare project logging.info("prepare project %s (%s)" % (project.name, project.id))
if not CONF.password: password = "".join(random.choice(string.ascii_letters + string.digits) for x in range(16)) else: password = CONF.password # FIXME(berendt): use get_domain domain = conn.identity.find_domain(CONF.domain) # FIXME(berendt): use get_project project = conn.identity.find_project(name, domain_id=domain.id) if not project: project = conn.create_project(name=name, domain_id=domain.id) # FIXME(berendt): use openstacksdk keystone = os_client_config.make_client('identity', cloud=CONF.cloud) keystone.projects.update(project=project.id, quotaclass=CONF.quotaclass) keystone.projects.update(project=project.id, quotamultiplier=CONF.quotamultiplier) if CONF.quotamultiplier_compute: keystone.projects.update(project=project.id, quotamultiplier_compute=CONF.quotamultiplier_compute) if CONF.quotamultiplier_network: keystone.projects.update(project=project.id, quotamultiplier_network=CONF.quotamultiplier_network) if CONF.quotamultiplier_storage: keystone.projects.update(project=project.id, quotamultiplier_storage=CONF.quotamultiplier_storage) keystone.projects.update(project=project.id, has_domain_network="False") keystone.projects.update(project=project.id, has_public_network="True") keystone.projects.update(project=project.id, owner=CONF.owner)
if hasattr(resource, "id"): resource_id = resource.id else: resource_id = resource.get("id") if project_id and project_id not in projects: print("%s - %s: %s (project: %s)" % (servicename, resourcename, resource_id, project_id)) if resourcename == "rbacpolicy" and resource.get("target_tenant") not in projects: print("%s - %s: %s (project: %s)" % (servicename, resourcename, resource_id, project_id)) if __name__ == '__main__': CONF(sys.argv[1:], project=PROJECT_NAME) keystone = os_client_config.make_client('identity', cloud=CONF.cloud) clients = { "cinder": os_client_config.make_client('volume', cloud=CONF.cloud), "glance": os_client_config.make_client('image', cloud=CONF.cloud), "neutron": os_client_config.make_client('network', cloud=CONF.cloud), "nova": os_client_config.make_client('compute', cloud=CONF.cloud), "heat": os_client_config.make_client('orchestration', cloud=CONF.cloud), } domains = [x for x in keystone.domains.list() if x.name != "heat_user_domain"] projects = [] for domain in domains: projects_in_domain = [x.id for x in keystone.projects.list(domain=domain.id)] projects = projects + projects_in_domain