-
- if 'result' not in self._ro_http.delete_cmd('openmano/datacenters/{}'
- .format(vim_name)):
- raise ClientException("failed to delete vim {}".format(vim_name))
-
- def list(self):
- resp = self._http.get_cmd('v1/api/operational/datacenters')
- if not resp or 'rw-launchpad:datacenters' not in resp:
- return list()
-
- datacenters = resp['rw-launchpad:datacenters']
-
- vim_accounts = list()
- if 'ro-accounts' not in datacenters:
+ resp = self._ro_http.delete_cmd('openmano/datacenters/{}'
+ .format(vim_name))
+ if 'result' not in resp:
+ raise ClientException("failed to delete vim {} - {}".format(vim_name, resp))
+ self._update_ro_accounts()
+
+ def list(self, ro_update):
+ if ro_update:
+ self._update_ro_accounts()
+ # the ro_update needs to be made synchronous, for now this works around the issue
+ # and waits a resonable amount of time for the update to finish
+ time.sleep(2)
+
+ if self._client._so_version == 'v3':
+ resp = self._http.get_cmd('v1/api/operational/{}ro-account-state'
+ .format(self._client.so_rbac_project_path))
+ datacenters = []
+ if not resp or 'rw-ro-account:ro-account-state' not in resp:
+ return list()
+
+ ro_accounts = resp['rw-ro-account:ro-account-state']
+ for ro_account in ro_accounts['account']:
+ if 'datacenters' not in ro_account:
+ continue
+ if 'datacenters' not in ro_account['datacenters']:
+ continue
+ for datacenter in ro_account['datacenters']['datacenters']:
+ datacenters.append({"name": datacenter['name'], "uuid": datacenter['uuid']
+ if 'uuid' in datacenter else None})
+
+ vim_accounts = datacenters