- resp = self._http.get_cmd('v1/api/operational/datacenters')
- if not resp:
- return None
-
- if not resp or 'rw-launchpad:datacenters' not in resp:
- return None
- if 'ro-accounts' not in resp['rw-launchpad:datacenters']:
+ if self._client._so_version == 'v3':
+ resp = self._http.get_cmd('v1/api/operational/{}ro-account-state'
+ .format(self._client.so_rbac_project_path))
+ if not resp:
+ return None, None
+
+ if not resp or 'rw-ro-account:ro-account-state' not in resp:
+ return None, None
+
+ ro_accounts = resp['rw-ro-account:ro-account-state']
+ for ro_account in ro_accounts['account']:
+ for datacenter in ro_account['datacenters']['datacenters']:
+ if datacenter['name'] == name:
+ return datacenter, ro_account['name']
+ return None, None
+ else:
+ # Backwards Compatibility
+ resp = self._http.get_cmd('v1/api/operational/datacenters')
+ if not resp:
+ return None
+
+ if not resp or 'rw-launchpad:datacenters' not in resp:
+ return None
+ if 'ro-accounts' not in resp['rw-launchpad:datacenters']:
+ return None
+ for roaccount in resp['rw-launchpad:datacenters']['ro-accounts']:
+ if 'datacenters' not in roaccount:
+ continue
+ for datacenter in roaccount['datacenters']:
+ if datacenter['name'] == name:
+ return datacenter