diff --git a/library/Vmwarephp/Service.php b/library/Vmwarephp/Service.php index 52030ed..76d349c 100644 --- a/library/Vmwarephp/Service.php +++ b/library/Vmwarephp/Service.php @@ -42,6 +42,15 @@ function findManagedObjectByName($objectType, $name, $propertiesToCollect = arra }); return empty($objects) ? null : end($objects); } + + function findManagedObjectByInstanceUuid($objectType, $uuid, $propertiesToCollect = array()) { + $propertiesToCollect = array_merge($propertiesToCollect, ['config']); + $allObjects = $this->findAllManagedObjects($objectType, $propertiesToCollect); + $objects = array_filter($allObjects, function ($object) use ($uuid) { + return $object->config->instanceUuid == $uuid; + }); + return empty($objects) ? null : end($objects); + } function connect() { if ($this->session) {