X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fv1%2Fvim.py;h=849f6dc7975ef17f01fa8be4b737f326a0a0328f;hb=refs%2Fchanges%2F58%2F10358%2F1;hp=f9f8369ddd9f26396670e5ae5499a79c1be1f297;hpb=78c910f6851a6eb764af3ab3e02dde85dc325710;p=osm%2Fosmclient.git diff --git a/osmclient/v1/vim.py b/osmclient/v1/vim.py index f9f8369..849f6dc 100644 --- a/osmclient/v1/vim.py +++ b/osmclient/v1/vim.py @@ -20,7 +20,8 @@ OSM vim API handling from osmclient.common.exceptions import ClientException from osmclient.common.exceptions import NotFound -import json +import yaml +import time class Vim(object): @@ -44,8 +45,12 @@ class Vim(object): datacenter['uuid']), vim_account) def _detach(self, vim_name): + tenant_name = 'osm' + tenant = self._get_ro_tenant() + if tenant is None: + raise ClientException("tenant {} not found".format(tenant_name)) return self._ro_http.delete_cmd('openmano/{}/datacenters/{}' - .format('osm', vim_name)) + .format(tenant["uuid"], vim_name)) def create(self, name, vim_access): vim_account = {} @@ -60,19 +65,11 @@ class Vim(object): vim_account['datacenter']['type'] = vim_access['vim-type'] vim_config = {} - vim_config['use_floating_ip'] = False + if 'config' in vim_access and vim_access['config'] is not None: + vim_config = yaml.safe_load(vim_access['config']) - if ('floating_ip_pool' in vim_access and - vim_access['floating_ip_pool'] is not None): - vim_config['use_floating_ip'] = True - - if 'keypair' in vim_access and vim_access['keypair'] is not None: - vim_config['keypair'] = vim_access['keypair'] - elif 'config' in vim_access and vim_access['config'] is not None: - if any(var in vim_access['config'] for var in ["admin_password","admin_username","orgname","nsx_user","nsx_password","nsx_manager","vcenter_ip","vcenter_port","vcenter_user","vcenter_password"]): - vim_config = json.loads(vim_access['config']) - - vim_account['datacenter']['config'] = vim_config + if vim_config: + vim_account['datacenter']['config'] = vim_config vim_account = self.update_vim_account_dict(vim_account, vim_access, vim_config) @@ -151,7 +148,13 @@ class Vim(object): raise ClientException("failed to delete vim {} - {}".format(vim_name, resp)) self._update_ro_accounts() - def list(self): + 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))