def get_net_name(self, net_id): _net = self.neutronclient.list_networks(id=net_id, all_tenants=True)['networks'] if _net: return _net[0]['name'] raise test_exceptions.NotFound('Network with id "%s" was not found' % net_id)
def get_sg_id(self, sg): _sg = self.neutronclient.list_security_groups( name=sg, all_tenants=True)['security_groups'] if _sg: return _sg[0]['id'] raise test_exceptions.NotFound('Security group with name "%s" was not' ' found' % sg)
def get_net_id(self, net): _net = self.neutronclient.list_networks(name=net, all_tenants=True)['networks'] if _net: return _net[0]['id'] raise test_exceptions.NotFound('Network with name "%s" was not found' % net)
def get_volume_snapshot_id(self, snapshot_name): snapshots = self.cinderclient.volume_snapshots.list( search_opts={'all_tenants': 1}) for snapshot in snapshots: if snapshot.display_name == snapshot_name: return snapshot.id raise test_exceptions.NotFound( 'Snapshot with name "%s" was not found' % snapshot_name)
def get_volume_id(self, volume_name): volumes = self.cinderclient.volumes.list( search_opts={'all_tenants': 1}) for volume in volumes: if volume.display_name == volume_name: return volume.id raise test_exceptions.NotFound('Volume with name "%s" was not found' % volume_name)
def _get_image_id(self, image_name): for image in self.glanceclient.images.list(): if image.name == image_name: return image.id raise test_exceptions.NotFound('Image with name "%s" was not found' % image_name)
def get_server_group_id(self, server_group_name): for server_group in self.get_all_server_groups(): if server_group.name == server_group_name: return server_group.id msg = 'Server group with name "%s" was not found' raise test_exceptions.NotFound(msg % server_group_name)
def get_role_id(self, role_name): for role in self.keystoneclient.roles.list(): if role.name == role_name: return role.id raise test_exceptions.NotFound('Role with name "%s" was not found' % role_name)
def get_vm_id(self, vm_name): for vm in self.novaclient.servers.list(search_opts={'all_tenants': 1}): if vm.name == vm_name: return vm.id raise test_exceptions.NotFound('VM with name "%s" was not found' % vm_name)
def get_flavor_id(self, flavor_name): for flavor in self.novaclient.flavors.list(): if flavor.name == flavor_name: return flavor.id raise test_exceptions.NotFound('Flavor with name "%s" was not found' % flavor_name)
def get_router_id(self, router): _router = self.neutronclient.list_routers(name=router)['routers'] if _router: return _router[0]['id'] raise test_exceptions.NotFound('Router with name "%s" was not found' % router)
def get_user_id(self, user_name): for user in self.keystoneclient.users.list(): if user.name == user_name: return user.id raise test_exceptions.NotFound('User with name "%s" was not found' % user_name)
def get_tenant_name(self, tenant_id): for tenant in self.keystoneclient.tenants.list(): if tenant.id == tenant_id: return tenant.name raise test_exceptions.NotFound('Tenant with id "%s" was not found' % tenant_id)