}
return nslcmop
+ def _get_enabled_vims(self, session):
+ """
+ Retrieve and return VIM accounts that are accessible by current user and has state ENABLE
+ :param session: current session with user information
+ """
+ db_filter = self._get_project_filter(session)
+ db_filter["_admin.operationalState"] = "ENABLED"
+ vims = self.db.get_list("vim_accounts", db_filter)
+ vimAccounts = []
+ for vim in vims:
+ vimAccounts.append(vim['_id'])
+ return vimAccounts
+
def new(self, rollback, session, indata=None, kwargs=None, headers=None, slice_object=False):
"""
Performs a new operation over a ns
nslcmop_desc = self._create_nslcmop(nsInstanceId, operation, indata)
_id = nslcmop_desc["_id"]
self.format_on_new(nslcmop_desc, session["project_id"], make_public=session["public"])
+ if indata.get("placement-engine"):
+ # Save valid vim accounts in lcm operation descriptor
+ nslcmop_desc['operationParams']['validVimAccounts'] = self._get_enabled_vims(session)
self.db.create("nslcmops", nslcmop_desc)
rollback.append({"topic": "nslcmops", "_id": _id})
if not slice_object:
rollback = []
headers = {}
- nslcmop_id, _ = self.nslcmop_topic.new(rollback, session, indata=indata, kwargs=None, headers=headers)
+ nslcmop_id, _ = self.nslcmop_topic.new(rollback, session, indata=deepcopy(indata), kwargs=None, headers=headers)
# check nslcmop is created at database
self.assertEqual(self.db.create.call_count, 1, "database create not called, or called more than once")
"nsdId": id_schema,
"vimAccountId": id_schema,
"wimAccountId": {"OneOf": [id_schema, bool_schema, null_schema]},
+ "placement-engine": string_schema,
+ "placement-constraints": object_schema,
"additionalParamsForNs": object_schema,
"additionalParamsForVnf": additional_params_for_vnf,
"ssh_keys": {"type": "array", "items": {"type": "string"}},