elif item == "nsrs":
pass
- elif item == "vims" or item == "sdns":
+ elif item == "vim_accounts" or item == "sdns":
if self.db.get_one(item, {"name": indata.get("name")}, fail_on_empty=False, fail_on_more=False):
raise EngineException("name '{}' already exist for {}".format(indata["name"], item),
HTTPStatus.CONFLICT)
indata["_admin"]["usageSate"] = "NOT_IN_USE"
if item == "nsrs":
indata["_admin"]["nsState"] = "NOT_INSTANTIATED"
- if item in ("vims", "sdns"):
+ if item in ("vim_accounts", "sdns"):
indata["_admin"]["operationalState"] = "PROCESSING"
def upload_content(self, session, item, _id, indata, kwargs, headers):
Creates a new entry into database. For nsds and vnfds it creates an almost empty DISABLED entry,
that must be completed with a call to method upload_content
:param session: contains the used login username and working project
- :param item: it can be: users, projects, vims, sdns, nsrs, nsds, vnfds
+ :param item: it can be: users, projects, vim_accounts, sdns, nsrs, nsds, vnfds
:param indata: data to be inserted
:param kwargs: used to override the indata descriptor
:param headers: http request headers
if item == "nsrs":
pass
# self.msg.write("ns", "created", _id) # sending just for information.
- elif item == "vims":
+ elif item == "vim_accounts":
msg_data = self.db.get_one(item, {"_id": _id})
msg_data.pop("_admin", None)
self.msg.write("vim_account", "create", msg_data)
:param item: it can be: users, projects, vnfds, nsds, ...
:param _id: server id of the item
:param force: indicates if deletion must be forced in case of conflict
- :return: dictionary, raise exception if not found.
+ :return: dictionary with deleted item _id. It raises exception if not found.
"""
# TODO add admin to filter, validate rights
# data = self.get_item(item, _id)
self.db.del_list("nslcmops", {"nsInstanceId": _id})
self.msg.write("ns", "deleted", {"_id": _id})
return v
- if item in ("vims", "sdns"):
+ if item in ("vim_accounts", "sdns"):
desc = self.db.get_one(item, filter)
desc["_admin"]["to_delete"] = True
self.db.replace(item, _id, desc) # TODO change to set_one
- if item == "vims":
+ if item == "vim_accounts":
self.msg.write("vim_account", "delete", {"_id": _id})
elif item == "sdns":
self.msg.write("sdn", "delete", {"_id": _id})
self._validate_new_data(session, item, content, id)
# self._format_new_data(session, item, content)
self.db.replace(item, id, content)
- if item in ("vims", "sdns"):
+ if item in ("vim_accounts", "sdns"):
indata.pop("_admin", None)
indata["_id"] = id
- if item == "vims":
+ if item == "vim_accounts":
self.msg.write("vim_account", "edit", indata)
elif item == "sdns":
self.msg.write("sdn", "edit", indata)
/<id> O O
/projects O O
/<id> O O
- /vims O O
+ /vims_accounts (also vims for compatibility) O O
/<id> O O O
/sdns O O
/<id> O O O
"vims": {"METHODS": ("GET", "POST"),
"<ID>": {"METHODS": ("GET", "DELETE")}
},
+ "vim_accounts": {"METHODS": ("GET", "POST"),
+ "<ID>": {"METHODS": ("GET", "DELETE")}
+ },
"sdns": {"METHODS": ("GET", "POST"),
"<ID>": {"METHODS": ("GET", "DELETE")}
},
if data is None:
if accept and "text/html" in accept:
return html.format(data, cherrypy.request, cherrypy.response, session)
- cherrypy.response.status = HTTPStatus.NO_CONTENT.value
+ # cherrypy.response.status = HTTPStatus.NO_CONTENT.value
return
elif hasattr(data, "read"): # file object
if _format:
engine_item = "nsrs"
if item == "ns_lcm_op_occs":
engine_item = "nslcmops"
+ if engine_item == "vims": # TODO this is for backward compatibility, it will remove in the future
+ engine_item = "vim_accounts"
if method == "GET":
if item2 in ("nsd_content", "package_content", "artifacts", "vnfd", "nsd"):
outdata = {"id": _id}
# TODO form NsdInfo when item in ("ns_descriptors", "vnf_packages")
cherrypy.response.status = HTTPStatus.CREATED.value
+
elif method == "DELETE":
if not _id:
outdata = self.engine.del_item_list(session, engine_item, kwargs)
+ cherrypy.response.status = HTTPStatus.OK.value
else: # len(args) > 1
if item == "ns_instances_content":
self.engine.ns_action(session, _id, "terminate", {"autoremove": True}, None)
+ cherrypy.response.status = HTTPStatus.ACCEPTED.value
else:
force = kwargs.get("FORCE")
self.engine.del_item(session, engine_item, _id, force)
- # TODO return 202 ACCEPTED for nsrs vims
- outdata = None
+ cherrypy.response.status = HTTPStatus.NO_CONTENT.value
+ if engine_item in ("vim_accounts", "sdns"):
+ cherrypy.response.status = HTTPStatus.ACCEPTED.value
+
elif method == "PUT":
if not indata and not kwargs:
raise NbiException("Nothing to update. Provide payload and/or query string",
completed = self.engine.upload_content(session, engine_item, _id, indata, kwargs, cherrypy.request.headers)
if not completed:
cherrypy.response.headers["Transaction-Id"] = id
+ cherrypy.response.status = HTTPStatus.NO_CONTENT.value
outdata = None
else:
outdata = {"id": self.engine.edit_item(session, engine_item, args[1], indata, kwargs)}
vim_bad.pop("name")
test_admin_list1 = (
- ("VIM1", "Create VIM", "POST", "/admin/v1/vims", headers_json, vim, (201, 204), {"Location": "/admin/v1/vims/", "Content-Type": "application/json"}, "json"),
- ("VIM2", "Create VIM bad schema", "POST", "/admin/v1/vims", headers_json, vim_bad, 422, None, headers_json),
- ("VIM2", "Create VIM name repeated", "POST", "/admin/v1/vims", headers_json, vim, 409, None, headers_json),
- ("VIM4", "Show VIMs", "GET", "/admin/v1/vims", headers_yaml, None, 200, r_header_yaml, "yaml"),
- ("VIM5", "Show VIM", "GET", "/admin/v1/vims/{VIM1}", headers_yaml, None, 200, r_header_yaml, "yaml"),
- ("VIM6", "Delete VIM", "DELETE", "/admin/v1/vims/{VIM1}", headers_yaml, None, 204, None, 0),
+ ("VIM1", "Create VIM", "POST", "/admin/v1/vim_accounts", headers_json, vim, (201, 204), {"Location": "/admin/v1/vim_accounts/", "Content-Type": "application/json"}, "json"),
+ ("VIM2", "Create VIM bad schema", "POST", "/admin/v1/vim_accounts", headers_json, vim_bad, 422, None, headers_json),
+ ("VIM2", "Create VIM name repeated", "POST", "/admin/v1/vim_accounts", headers_json, vim, 409, None, headers_json),
+ ("VIM4", "Show VIMs", "GET", "/admin/v1/vim_accounts", headers_yaml, None, 200, r_header_yaml, "yaml"),
+ ("VIM5", "Show VIM", "GET", "/admin/v1/vim_accounts/{VIM1}", headers_yaml, None, 200, r_header_yaml, "yaml"),
+ ("VIM6", "Delete VIM", "DELETE", "/admin/v1/vim_accounts/{VIM1}", headers_yaml, None, 202, None, 0),
)
class TestException(Exception):
schema_version = {"type": "string", "enum": ["1.0"]}
-schema_type = {"type": "string"}
-
-vim_new_schema = {
- "title": "vims new user input schema",
+vim_account_edit_schema = {
+ "title": "vim_account edit input schema",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
- "schema_version": schema_version,
- "schema_type": schema_type,
"name": name_schema,
"description": description_schema,
- "vim_type": {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws"]},
+ "type": nameshort_schema, # currently "openvim" or "openstack", can be enlarged with plugins
+ "vim": name_schema,
+ "datacenter": name_schema,
"vim_url": description_schema,
- # "vim_url_admin": description_schema,
- # "vim_tenant": name_schema,
+ "vim_url_admin": description_schema,
+ "vim_tenant": name_schema,
"vim_tenant_name": name_schema,
- "vim_user": nameshort_schema,
+ "vim_username": nameshort_schema,
"vim_password": nameshort_schema,
"config": {"type": "object"}
},
- "required": ["name", "vim_url", "vim_type", "vim_user", "vim_password", "vim_tenant_name"],
"additionalProperties": False
}
-vim_edit_schema = {
- "title": "datacenter edit nformation schema",
+schema_type = {"type": "string"}
+
+vim_account_new_schema = {
+ "title": "vim_account creation input schema",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
+ "schema_version": schema_version,
+ "schema_type": schema_type,
"name": name_schema,
"description": description_schema,
- "type": nameshort_schema, # currently "openvim" or "openstack", can be enlarged with plugins
+ "vim": name_schema,
+ "datacenter": name_schema,
+ "vim_type": {"enum": ["openstack", "openvim", "vmware", "opennebula", "aws"]},
"vim_url": description_schema,
- "vim_url_admin": description_schema,
- "vim_tenant": name_schema,
+ # "vim_url_admin": description_schema,
+ # "vim_tenant": name_schema,
"vim_tenant_name": name_schema,
- "vim_username": nameshort_schema,
+ "vim_user": nameshort_schema,
"vim_password": nameshort_schema,
"config": {"type": "object"}
},
+ "required": ["name", "vim_url", "vim_type", "vim_user", "vim_password", "vim_tenant_name"],
"additionalProperties": False
}
nbi_new_input_schemas = {
- "vims": vim_new_schema,
+ "vim_accounts": vim_account_new_schema,
"sdns": sdn_new_schema,
"ns_instantiate": ns_instantiate,
"ns_action": ns_action,
}
nbi_edit_input_schemas = {
- "vims": vim_edit_schema,
+ "vim_accounts": vim_account_edit_schema,
"sdns": sdn_edit_schema
}