mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
VMware: Fail when unable to find managed object (#53158)
Fixes: #52119 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
c948849d4d
commit
bf8ada0eb5
1 changed files with 6 additions and 1 deletions
|
@ -126,14 +126,19 @@ class VmwareTagManager(VmwareRestClient):
|
||||||
|
|
||||||
self.object_type = self.params.get('object_type')
|
self.object_type = self.params.get('object_type')
|
||||||
self.object_name = self.params.get('object_name')
|
self.object_name = self.params.get('object_name')
|
||||||
|
self.managed_object = None
|
||||||
|
|
||||||
if self.object_type == 'VirtualMachine':
|
if self.object_type == 'VirtualMachine':
|
||||||
self.managed_object = self.pyv.get_vm_or_template(self.object_name)
|
self.managed_object = self.pyv.get_vm_or_template(self.object_name)
|
||||||
self.dynamic_managed_object = DynamicID(type=self.object_type, id=self.managed_object._moId)
|
|
||||||
|
|
||||||
if self.managed_object is None:
|
if self.managed_object is None:
|
||||||
self.module.fail_json(msg="Failed to find the managed object for %s with type %s" % (self.object_name, self.object_type))
|
self.module.fail_json(msg="Failed to find the managed object for %s with type %s" % (self.object_name, self.object_type))
|
||||||
|
|
||||||
|
if not hasattr(self.managed_object, '_moId'):
|
||||||
|
self.module.fail_json(msg="Unable to find managed object id for %s managed object" % self.object_name)
|
||||||
|
|
||||||
|
self.dynamic_managed_object = DynamicID(type=self.object_type, id=self.managed_object._moId)
|
||||||
|
|
||||||
self.tag_service = Tag(self.connect)
|
self.tag_service = Tag(self.connect)
|
||||||
self.category_service = Category(self.connect)
|
self.category_service = Category(self.connect)
|
||||||
self.tag_association_svc = TagAssociation(self.connect)
|
self.tag_association_svc = TagAssociation(self.connect)
|
||||||
|
|
Loading…
Reference in a new issue