Feature 10239: Distributed VCA
[osm/osmclient.git] / osmclient / sol005 / vim.py
index e5bf399..8b11c8d 100644 (file)
@@ -72,16 +72,26 @@ class Vim(object):
     def create(
         self, name, vim_access, sdn_controller=None, sdn_port_mapping=None, wait=False
     ):
+        vca_id = None
+
+        def get_vca_id(vca):
+            vca = self._client.vca.get(vca)
+            if vca is None:
+                raise NotFound("cannot find vca '{}'".format(vca))
+            return vca["_id"]
+
         self._logger.debug("")
         self._client.get_token()
+        if "vca" in vim_access:
+            vca_id = get_vca_id(vim_access["vca"])
         if "vim-type" not in vim_access:
             # 'openstack' not in vim_access['vim-type']):
             raise Exception("vim type not provided")
-
         vim_account = {}
         vim_account["name"] = name
         vim_account = self.update_vim_account_dict(vim_account, vim_access)
-
+        if vca_id:
+            vim_account["vca"] = vca_id
         vim_config = {}
         if "config" in vim_access and vim_access["config"] is not None:
             vim_config = yaml.safe_load(vim_access["config"])