diff --git a/wrapanapi/systems/openstack.py b/wrapanapi/systems/openstack.py index b702a836..1415ff5f 100644 --- a/wrapanapi/systems/openstack.py +++ b/wrapanapi/systems/openstack.py @@ -793,10 +793,10 @@ def _generic_paginator(self, f): break return lists - def list_vms(self, filter_tenants=True): - call = partial(self.api.servers.list, True, {'all_tenants': True}) + def list_vms(self, filter_tenants=True, all_tenants=True): + call = partial(self.api.servers.list, True, {'all_tenants': all_tenants}) instances = self._generic_paginator(call) - if filter_tenants: + if filter_tenants and all_tenants: # Filter instances based on their tenant ID # needed for CFME 5.3 and higher tenants = self._get_tenants() @@ -804,7 +804,7 @@ def list_vms(self, filter_tenants=True): instances = [i for i in instances if i.tenant_id in ids] return [OpenstackInstance(system=self, uuid=i.id, raw=i) for i in instances] - def find_vms(self, name=None, id=None, ip=None): + def find_vms(self, name=None, id=None, ip=None, all_tenants=True): """ Find VM based on name OR IP OR ID @@ -826,7 +826,7 @@ def find_vms(self, name=None, id=None, ip=None): if not any((name, ip, id)): raise ValueError("Any of these parameters must be specified: name, ip, or id") matches = [] - instances = self.list_vms() + instances = self.list_vms(all_tenants=all_tenants) for instance in instances: # Use 'instance.raw' below so we don't refresh the properties, since we # *just* pulled down this list of VMs and stored the raw data in list_vms() @@ -840,7 +840,7 @@ def find_vms(self, name=None, id=None, ip=None): matches.append(instance) return matches - def get_vm(self, name=None, id=None, ip=None): + def get_vm(self, name=None, id=None, ip=None, all_tenants=True): """ Get a VM based on name, or ID, or IP @@ -862,7 +862,7 @@ def get_vm(self, name=None, id=None, ip=None): kwargs = {'name': name, 'id': id, 'ip': ip} kwargs = {key: val for key, val in kwargs.items() if val is not None} - matches = self.find_vms(**kwargs) + matches = self.find_vms(**kwargs, all_tenants=all_tenants) if not matches: raise VMInstanceNotFound('match criteria: {}'.format(kwargs)) elif len(matches) > 1: