summaryrefslogtreecommitdiffstats
path: root/vio/pub/vim
diff options
context:
space:
mode:
Diffstat (limited to 'vio/pub/vim')
-rw-r--r--vio/pub/vim/__init__.py13
-rw-r--r--vio/pub/vim/__init__.pycbin0 -> 123 bytes
-rw-r--r--vio/pub/vim/const.py25
-rw-r--r--vio/pub/vim/drivers/__init__.py0
-rw-r--r--vio/pub/vim/drivers/__init__.pycbin0 -> 131 bytes
-rw-r--r--vio/pub/vim/drivers/base.py22
-rw-r--r--vio/pub/vim/drivers/base.pycbin0 -> 611 bytes
-rw-r--r--vio/pub/vim/drivers/openstacksdk/__init__.py16
-rw-r--r--vio/pub/vim/drivers/openstacksdk/__init__.pycbin0 -> 265 bytes
-rw-r--r--vio/pub/vim/drivers/openstacksdk/keystone_v3.py39
-rw-r--r--vio/pub/vim/drivers/openstacksdk/keystone_v3.pycbin0 -> 1501 bytes
-rw-r--r--vio/pub/vim/drivers/openstacksdk/sdk.py124
-rw-r--r--vio/pub/vim/drivers/openstacksdk/sdk.pycbin0 -> 3086 bytes
-rw-r--r--vio/pub/vim/drivers/vimdriver.py25
-rw-r--r--vio/pub/vim/drivers/vimdriver.pycbin0 -> 689 bytes
-rw-r--r--vio/pub/vim/swagger.json1067
-rw-r--r--vio/pub/vim/urls.py31
-rw-r--r--vio/pub/vim/urls.pycbin0 -> 920 bytes
-rw-r--r--vio/pub/vim/views.py110
-rw-r--r--vio/pub/vim/views.pycbin0 -> 3625 bytes
-rw-r--r--vio/pub/vim/vimadaptor.py117
-rw-r--r--vio/pub/vim/vimapi/__init__.py0
-rw-r--r--vio/pub/vim/vimapi/__init__.pycbin0 -> 130 bytes
-rw-r--r--vio/pub/vim/vimapi/baseclient.py85
-rw-r--r--vio/pub/vim/vimapi/baseclient.pycbin0 -> 3048 bytes
-rw-r--r--vio/pub/vim/vimapi/compute/OperatorInstance.py46
-rw-r--r--vio/pub/vim/vimapi/compute/__init__.py0
-rw-r--r--vio/pub/vim/vimapi/glance/OperateImage.py52
-rw-r--r--vio/pub/vim/vimapi/glance/OperateImage.pycbin0 -> 1769 bytes
-rw-r--r--vio/pub/vim/vimapi/glance/__init__.py0
-rw-r--r--vio/pub/vim/vimapi/glance/__init__.pycbin0 -> 137 bytes
-rw-r--r--vio/pub/vim/vimapi/keystone/OperateTenant.py38
-rw-r--r--vio/pub/vim/vimapi/keystone/OperateTenant.pycbin0 -> 1036 bytes
-rw-r--r--vio/pub/vim/vimapi/keystone/__init__.py0
-rw-r--r--vio/pub/vim/vimapi/keystone/__init__.pycbin0 -> 139 bytes
-rw-r--r--vio/pub/vim/vimapi/keystone/auth.py27
-rw-r--r--vio/pub/vim/vimapi/neutron/__init__.py0
37 files changed, 1837 insertions, 0 deletions
diff --git a/vio/pub/vim/__init__.py b/vio/pub/vim/__init__.py
new file mode 100644
index 0000000..5580cc3
--- /dev/null
+++ b/vio/pub/vim/__init__.py
@@ -0,0 +1,13 @@
+# Copyright 2016 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
diff --git a/vio/pub/vim/__init__.pyc b/vio/pub/vim/__init__.pyc
new file mode 100644
index 0000000..74dde2d
--- /dev/null
+++ b/vio/pub/vim/__init__.pyc
Binary files differ
diff --git a/vio/pub/vim/const.py b/vio/pub/vim/const.py
new file mode 100644
index 0000000..d151fb4
--- /dev/null
+++ b/vio/pub/vim/const.py
@@ -0,0 +1,25 @@
+# Copyright 2016 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+VIM_OPENSTACK = "openstack"
+RES_TYPE_KEY = "res_type"
+RES_TYPE_NEW = 1
+RES_TYPE_EXIST = 0
+SHARED_NET = 1
+SUPPORT_VLAN_TRANSPARENT = 1
+DEFAULT_MTU = 1500
+IPV4 = 4
+IPV6 = 6
+ENABLE_DHCP = 1
diff --git a/vio/pub/vim/drivers/__init__.py b/vio/pub/vim/drivers/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vio/pub/vim/drivers/__init__.py
diff --git a/vio/pub/vim/drivers/__init__.pyc b/vio/pub/vim/drivers/__init__.pyc
new file mode 100644
index 0000000..c62f8eb
--- /dev/null
+++ b/vio/pub/vim/drivers/__init__.pyc
Binary files differ
diff --git a/vio/pub/vim/drivers/base.py b/vio/pub/vim/drivers/base.py
new file mode 100644
index 0000000..a1c68a6
--- /dev/null
+++ b/vio/pub/vim/drivers/base.py
@@ -0,0 +1,22 @@
+# Copyright (c) 2017 VMware, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+import copy
+
+
+
+class DriverBase(object):
+ '''Base class for all drivers.'''
+
+ def __init__(self, params):
+ self.conn_params = copy.deepcopy(params)
+
diff --git a/vio/pub/vim/drivers/base.pyc b/vio/pub/vim/drivers/base.pyc
new file mode 100644
index 0000000..b8ba13c
--- /dev/null
+++ b/vio/pub/vim/drivers/base.pyc
Binary files differ
diff --git a/vio/pub/vim/drivers/openstacksdk/__init__.py b/vio/pub/vim/drivers/openstacksdk/__init__.py
new file mode 100644
index 0000000..073a03d
--- /dev/null
+++ b/vio/pub/vim/drivers/openstacksdk/__init__.py
@@ -0,0 +1,16 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from vio.pub.vim.drivers.openstacksdk import keystone_v3
+
+
+identity = keystone_v3.KeystoneClient
diff --git a/vio/pub/vim/drivers/openstacksdk/__init__.pyc b/vio/pub/vim/drivers/openstacksdk/__init__.pyc
new file mode 100644
index 0000000..d0030da
--- /dev/null
+++ b/vio/pub/vim/drivers/openstacksdk/__init__.pyc
Binary files differ
diff --git a/vio/pub/vim/drivers/openstacksdk/keystone_v3.py b/vio/pub/vim/drivers/openstacksdk/keystone_v3.py
new file mode 100644
index 0000000..2ca57e4
--- /dev/null
+++ b/vio/pub/vim/drivers/openstacksdk/keystone_v3.py
@@ -0,0 +1,39 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from oslo_config import cfg
+import logging
+
+from vio.pub.vim.drivers import base
+from vio.pub.vim.drivers.openstacksdk import sdk
+
+LOG = logging.getLogger(__name__)
+CONF = cfg.CONF
+
+
+class KeystoneClient(base.DriverBase):
+ '''Keystone V3 driver.'''
+
+ def __init__(self, params):
+ super(KeystoneClient, self).__init__(params)
+ self.conn = sdk.create_connection(params)
+ self.session = self.conn.session
+
+ @sdk.translate_exception
+ def project_list(self):
+ projects = self.conn.identity.projects()
+ return projects
+
+ @sdk.translate_exception
+ def trust_list(self, **query):
+ trusts = [t for t in self.conn.identity.trusts(**query)]
+ return trusts
diff --git a/vio/pub/vim/drivers/openstacksdk/keystone_v3.pyc b/vio/pub/vim/drivers/openstacksdk/keystone_v3.pyc
new file mode 100644
index 0000000..4b279fb
--- /dev/null
+++ b/vio/pub/vim/drivers/openstacksdk/keystone_v3.pyc
Binary files differ
diff --git a/vio/pub/vim/drivers/openstacksdk/sdk.py b/vio/pub/vim/drivers/openstacksdk/sdk.py
new file mode 100644
index 0000000..1dbed47
--- /dev/null
+++ b/vio/pub/vim/drivers/openstacksdk/sdk.py
@@ -0,0 +1,124 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+'''
+SDK Client
+'''
+import functools
+import logging
+
+from openstack import connection
+from openstack import exceptions as sdk_exc
+from openstack import profile
+from requests import exceptions as req_exc
+
+
+USER_AGENT = 'vimdriver-vio'
+exc = sdk_exc
+LOG = logging.getLogger(__name__)
+
+
+def parse_exception(ex):
+ '''Parse exception code and yield useful information.'''
+ code = 500
+
+ if isinstance(ex, sdk_exc.HttpException):
+ # some exceptions don't contain status_code
+ if ex.http_status is not None:
+ code = ex.http_status
+ message = ex.message
+ data = {}
+ if ex.details is None:
+ data = ex.response.json()
+ else:
+ try:
+ data = jsonutils.loads(ex.details)
+ except Exception:
+ # Some exceptions don't have details record or
+ # are not in JSON format
+ pass
+
+ # try dig more into the exception record
+ # usually 'data' has two types of format :
+ # type1: {"forbidden": {"message": "error message", "code": 403}
+ # type2: {"code": 404, "error": { "message": "not found"}}
+ if data:
+ code = data.get('code', code)
+ message = data.get('message', message)
+ error = data.get('error', None)
+ if error:
+ code = data.get('code', code)
+ message = data['error'].get('message', message)
+ else:
+ for value in data.values():
+ code = value.get('code', code)
+ message = value.get('message', message)
+
+ elif isinstance(ex, sdk_exc.SDKException):
+ # Besides HttpException there are some other exceptions like
+ # ResourceTimeout can be raised from SDK, handle them here.
+ message = ex.message
+ elif isinstance(ex, req_exc.RequestException):
+ # Exceptions that are not captured by SDK
+ code = ex.errno
+ message = six.text_type(ex)
+ else:
+ # This could be a generic exception or something we don't understand
+ message = six.text_type(ex)
+
+ raise senlin_exc.InternalError(code=code, message=message)
+
+
+def translate_exception(func):
+ """Decorator for exception translation."""
+
+ @functools.wraps(func)
+ def invoke_with_catch(driver, *args, **kwargs):
+ try:
+ return func(driver, *args, **kwargs)
+ except Exception as ex:
+ LOG.exception(ex)
+ raise parse_exception(ex)
+
+ return invoke_with_catch
+
+
+def create_connection(params=None):
+ if params is None:
+ params = {}
+
+ auth_plugin = 'password'
+
+ prof = profile.Profile()
+ prof.set_version('identity', 'v3')
+ prof.set_version('image', 'v1')
+
+ try:
+ conn = connection.Connection(profile=prof, verify=False, user_agent=USER_AGENT,
+ auth_plugin=auth_plugin, **params)
+ except Exception as ex:
+ raise parse_exception(ex)
+
+ return conn
+
+
+def authenticate(**kwargs):
+ '''Authenticate using openstack sdk based on user credential'''
+
+ conn = create_connection(kwargs)
+ access_info = {
+ 'token': conn.session.get_token(),
+ 'user_id': conn.session.get_user_id(),
+ 'project_id': conn.session.get_project_id()
+ }
+
+ return access_info
diff --git a/vio/pub/vim/drivers/openstacksdk/sdk.pyc b/vio/pub/vim/drivers/openstacksdk/sdk.pyc
new file mode 100644
index 0000000..3daec03
--- /dev/null
+++ b/vio/pub/vim/drivers/openstacksdk/sdk.pyc
Binary files differ
diff --git a/vio/pub/vim/drivers/vimdriver.py b/vio/pub/vim/drivers/vimdriver.py
new file mode 100644
index 0000000..770a017
--- /dev/null
+++ b/vio/pub/vim/drivers/vimdriver.py
@@ -0,0 +1,25 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import copy
+
+
+from vio.pub.vim.drivers import openstacksdk
+
+
+
+class VimDriver(object):
+ '''Generic driver class'''
+
+ def __init__(self):
+
+ self.identity = openstacksdk.keystone_v3.KeystoneClient
diff --git a/vio/pub/vim/drivers/vimdriver.pyc b/vio/pub/vim/drivers/vimdriver.pyc
new file mode 100644
index 0000000..69ecf31
--- /dev/null
+++ b/vio/pub/vim/drivers/vimdriver.pyc
Binary files differ
diff --git a/vio/pub/vim/swagger.json b/vio/pub/vim/swagger.json
new file mode 100644
index 0000000..59140e6
--- /dev/null
+++ b/vio/pub/vim/swagger.json
@@ -0,0 +1,1067 @@
+{
+ "swagger": "2.0",
+ "info": {
+ "version": "1.0.0",
+ "title": "VimDriver vio Service rest API"
+ },
+ "basePath": "/openoapi/multivim-vio/v1",
+ "tags": [
+ {
+ "name": "vim Resource"
+ }
+ ],
+ "paths": {
+ "/{vimid}/images": {
+ "post": {
+ "tags": [
+ "image Resource"
+ ],
+ "summary": "Create a image resource",
+ "description": "Create a image resource",
+ "operationId": "CreateImage",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "body",
+ "name": "body",
+ "description": "The request params to create a VNF instance",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/CreateVnfRequest"
+ }
+ }
+ ],
+ "responses": {
+ "201": {
+ "description": "A VNF Instance identifier was created successfully.",
+ "schema": {
+ "$ref": "#/definitions/CreateVnfResponse"
+ }
+ },
+ "401": {
+ "description": "Unauthorized."
+ },
+ "500": {
+ "description": "Failed to process the request",
+ "schema": {
+ "$ref": "#/definitions/Error"
+ }
+ }
+ }
+ },
+ "get": {
+ "tags": [
+ "lcm Resource"
+ ],
+ "summary": "Query multiple VNF instances",
+ "description": "Query multiple VNF instances",
+ "operationId": "QueryMultipleVnf",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [],
+ "responses": {
+ "200": {
+ "description": "The request has succeeded.",
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/VnfInstanceInfo"
+ }
+ }
+ },
+ "401": {
+ "description": "Unauthorized."
+ },
+ "500": {
+ "description": "Failed to process the request",
+ "schema": {
+ "$ref": "#/definitions/Error"
+ }
+ }
+ }
+ }
+ },
+ "/vnf_instances/{vnfInstanceId}": {
+ "delete": {
+ "tags": [
+ "lcm Resource"
+ ],
+ "summary": "Delete a VNF instance resource",
+ "description": "Delete a VNF instance resource",
+ "operationId": "DeleteVnf",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "path",
+ "name": "vnfInstanceId",
+ "description": "Identifier of the VNF instance.",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "204": {
+ "description": "The VNF instance resource and the associated VNF identifier were deleted successfully."
+ },
+ "401": {
+ "description": "Unauthorized."
+ },
+ "404": {
+ "description": "The VNF instance resource does not exist."
+ },
+ "500": {
+ "description": "Failed to process the request",
+ "schema": {
+ "$ref": "#/definitions/Error"
+ }
+ }
+ }
+ },
+ "get": {
+ "tags": [
+ "lcm Resource"
+ ],
+ "summary": "Query a VNF instance",
+ "description": "Query a VNF instance",
+ "operationId": "QuerySingleVnfs",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "path",
+ "name": "vnfInstanceId",
+ "description": "Identifier of the VNF instance.",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "The request has succeeded.",
+ "schema": {
+ "$ref": "#/definitions/VnfInstanceInfo"
+ }
+ },
+ "401": {
+ "description": "Unauthorized."
+ },
+ "404": {
+ "description": "The VNF instance resource does not exist."
+ },
+ "500": {
+ "description": "Failed to process the request",
+ "schema": {
+ "$ref": "#/definitions/Error"
+ }
+ }
+ }
+ }
+ },
+ "/vnf_instances/{vnfInstanceId}/instantiate": {
+ "post": {
+ "tags": [
+ "lcm Resource"
+ ],
+ "summary": "Instantiate a VNF",
+ "description": "Instantiate a VNF",
+ "operationId": "InstantiateVnf",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "path",
+ "name": "vnfInstanceId",
+ "description": "Identifier of the VNF instance.",
+ "required": true,
+ "type": "string"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "The request params to instantiate a VNF",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/InstantiateVnfRequest"
+ }
+ }
+ ],
+ "responses": {
+ "202": {
+ "description": "The request is accepted for processing, but the processing has not been completed.",
+ "schema": {
+ "$ref": "#/definitions/VnfLcOpIdResponse"
+ }
+ },
+ "401": {
+ "description": "Unauthorized."
+ },
+ "404": {
+ "description": "The VNF instance resource does not exist."
+ },
+ "500": {
+ "description": "Failed to process the request",
+ "schema": {
+ "$ref": "#/definitions/Error"
+ }
+ }
+ }
+ }
+ },
+ "/vnf_instances/{vnfInstanceId}/terminate": {
+ "post": {
+ "tags": [
+ "lcm Resource"
+ ],
+ "summary": "Terminate a VNF",
+ "description": "Terminate a VNF",
+ "operationId": "TerminateVnf",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "in": "path",
+ "name": "vnfInstanceId",
+ "description": "Identifier of the VNF instance.",
+ "required": true,
+ "type": "string"
+ },
+ {
+ "in": "body",
+ "name": "body",
+ "description": "The request params to terminate a VNF",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/TerminateVnfRequest"
+ }
+ }
+ ],
+ "responses": {
+ "202": {
+ "description": "The request is accepted for processing, but the processing has not been completed.",
+ "schema": {
+ "$ref": "#/definitions/VnfLcOpIdResponse"
+ }
+ },
+ "401": {
+ "description": "Unauthorized."
+ },
+ "404": {
+ "description": "The VNF instance resource does not exist."
+ },
+ "500": {
+ "description": "Failed to process the request",
+ "schema": {
+ "$ref": "#/definitions/Error"
+ }
+ }
+ }
+ }
+ },
+ "/vnf_lc_ops/{vnfLcOpId}&responseId={responseId}": {
+ "get": {
+ "tags": [
+ "lcm Resource"
+ ],
+ "summary": "Get VNF operational status",
+ "description": "VNF operational status",
+ "operationId": "QuerySingleVnfLcOp",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "parameters": [
+ {
+ "name": "vnfLcOpId",
+ "in": "path",
+ "description": "Identifier of a VNF lifecycle operation occurrence",
+ "required": true,
+ "type": "string"
+ },
+ {
+ "name": "responseId",
+ "in": "path",
+ "description": "Response Identifier",
+ "required": true,
+ "type": "string"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "The request has succeeded.",
+ "schema": {
+ "$ref": "#/definitions/VnfLcOpOcc"
+ }
+ },
+ "401": {
+ "description": "Unauthorized."
+ },
+ "404": {
+ "description": "The VNF lifecycle operation occurrence does not exist."
+ },
+ "500": {
+ "description": "Failed to process the request",
+ "schema": {
+ "$ref": "#/definitions/Error"
+ }
+ }
+ }
+ }
+ }
+ },
+ "definitions": {
+ "CreateVnfRequest": {
+ "type": "object",
+ "required": [
+ "vnfdId",
+ "vnfInstanceName"
+ ],
+ "properties": {
+ "vnfdId": {
+ "type": "string",
+ "description": "Identifier that identifies the VNFD which defines the VNF instance to be created."
+ },
+ "vnfInstanceName": {
+ "type": "string",
+ "description": "Human-readable name of the VNF instance to be created."
+ },
+ "vnfInstanceDescription": {
+ "type": "string",
+ "description": "Human-readable description of the VNF instance to be created."
+ }
+ }
+ },
+ "CreateVnfResponse": {
+ "type": "object",
+ "required": [
+ "vnfInstanceId"
+ ],
+ "properties": {
+ "vnfInstanceId": {
+ "type": "string",
+ "description": "VNF instance identifier just created."
+ }
+ }
+ },
+ "InstantiateVnfRequest": {
+ "type": "object",
+ "required": [
+ "flavourId"
+ ],
+ "properties": {
+ "flavourId": {
+ "type": "string",
+ "description": "Identifier of the VNF deployment flavour to be instantiated."
+ },
+ "instantiationLevelId": {
+ "type": "string",
+ "description": "Identifier of the instantiation level of the deployment flavour to be instantiated. If not present, the default instantiation level as declared in the VNFD is instantiated."
+ },
+ "extVirtualLinks": {
+ "items": {
+ "$ref": "#/definitions/ExtVirtualLinkData"
+ },
+ "description": "Information about external VLs to connect the VNF to."
+ },
+ "localizationLanguage": {
+ "type": "string",
+ "description": "Localization language of the VNF to be instantiated can be declared in the VNFD. The value shall comply with the format defined in IETF RFC 5646 [6]. "
+ },
+ "additionalParams": {
+ "type": "object",
+ "description": "Additional input parameters for the instantiation process, specific to the VNF being instantiated."
+ }
+ }
+ },
+ "TerminateVnfRequest": {
+ "type": "object",
+ "required": [
+ "terminationType"
+ ],
+ "properties": {
+ "terminationType": {
+ "type": "string",
+ "description": "Indicates whether forceful or graceful termination is requested.",
+ "enum": [
+ "FORCEFUL",
+ "GRACEFUL"
+ ]
+ },
+ "gracefulTerminationTimeout": {
+ "type": "integer",
+ "format": "int32",
+ "minimum": "1",
+ "description": "This attribute is only applicable in case of graceful termination. It defines the time to wait for the VNF to be taken out of service before shutting down the VNF and releasing the resources. The unit is seconds. If not given and the \"terminationType\" attribute is set to \"GRACEFUL\", it is expected that the VNFM waits for the successful taking out of service of the VNF, no matter how long it takes, before shutting down the VNF and releasing the resources."
+ }
+ }
+ },
+ "VnfLcOpIdResponse": {
+ "type": "object",
+ "description": "VNF lifecycle operation occurrence identifier response",
+ "required": [
+ "vnfLcOpId"
+ ],
+ "properties": {
+ "vnfLcOpId": {
+ "type": "string",
+ "description": "Identifier of a VNF lifecycle operation occurrence"
+ }
+ }
+ },
+ "ExtVirtualLinkData": {
+ "type": "object",
+ "required": [
+ "resourceId",
+ "extCps"
+ ],
+ "properties": {
+ "extVirtualLinkId": {
+ "type": "string",
+ "description": "Identifier of the VL instance."
+ },
+ "vim": {
+ "$ref": "#/definitions/VimInfo",
+ "description": "Information about the VIM that manages this resource. This attribute shall be supported and present if VNF-related resource management in direct mode is applicable."
+ },
+ "resourceId": {
+ "type": "string",
+ "description": "The network UUID of VIM"
+ },
+ "extCps": {
+ "type": "array",
+ "description": "External CPs of the VNF to be connected to this external VL.",
+ "items": {
+ "$ref": "#/definitions/VnfExtCpData"
+ }
+ }
+ }
+ },
+ "VimInfo": {
+ "type": "object",
+ "required": [
+ "vimInfoId",
+ "vimId",
+ "interfaceInfo",
+ "accessInfo",
+ "interfaceEndpoint"
+ ],
+ "properties": {
+ "vimInfoId": {
+ "type": "string",
+ "description": "The identifier of this VimInfo instance, for the purpose of referencing it from other information elements."
+ },
+ "vimId": {
+ "type": "string",
+ "description": "The identifier of the VIM."
+ },
+ "interfaceInfo": {
+ "$ref": "#/definitions/InterfaceInfo",
+ "description": "Information about the interface to the VIM, including VIM provider type, API version, and protocol type."
+ },
+ "accessInfo": {
+ "$ref": "#/definitions/AccessInfo",
+ "description": "Authentication credentials for accessing the VIM. Examples may include those to support different authentication schemes, e.g., OAuth, Token, etc. "
+ },
+ "interfaceEndpoint": {
+ "type": "string",
+ "description": "Information about the interface endpoint. An example is a URL."
+ }
+ }
+ },
+ "InterfaceInfo": {
+ "type": "object",
+ "required": [
+ "vimType",
+ "apiVersion",
+ "protocolType"
+ ],
+ "properties": {
+ "vimType": {
+ "type": "string",
+ "description": "The type of the VIM."
+ },
+ "apiVersion": {
+ "type": "string",
+ "description": "The Version of the api of the VIM."
+ },
+ "protocolType": {
+ "type": "string",
+ "enum": [
+ "http",
+ "https"
+ ]
+ }
+ }
+ },
+ "AccessInfo": {
+ "type": "object",
+ "required": [
+ "tenant",
+ "username",
+ "password"
+ ],
+ "properties": {
+ "tenant": {
+ "type": "string",
+ "description": "Tenant Name of tenant"
+ },
+ "username": {
+ "type": "string",
+ "description": "Username for login"
+ },
+ "password": {
+ "type": "string",
+ "description": "Password of login user"
+ }
+ }
+ },
+ "VnfExtCpData": {
+ "type": "object",
+ "required": [
+ "cpdId"
+ ],
+ "properties": {
+ "cpdId": {
+ "type": "string",
+ "description": "The identifier of the CPD in the VNFD."
+ },
+ "addresses": {
+ "type": "array",
+ "description": "List of (fixed) network addresses that need to be configured on the CP. This attribute shall be present if fixed addresses need to be configured.",
+ "items": {
+ "$ref": "#/definitions/NetworkAddress"
+ }
+ },
+ "numDynamicAddresses": {
+ "type": "integer",
+ "format": "int32",
+ "description": "Number of network addresses to be assigned dynamically. This attribute shall be present if dynamic addresses need to be configured."
+ }
+ }
+ },
+ "NetworkAddress": {
+ "type": "object",
+ "required": [
+ "addressType"
+ ],
+ "properties": {
+ "addressType": {
+ "type": "string",
+ "description": "Describes the type of the address to be assigned to the CP instantiated from the parent CPD.",
+ "enum": [
+ "MAC",
+ "IP"
+ ]
+ },
+ "l2AddressData": {
+ "type": "string",
+ "description": "Provides the information on the MAC addresses to be assigned to the CP(s) instantiated from the parent CPD. Shall be present when the addressType is MAC address."
+ },
+ "l3AddressData": {
+ "$ref": "#/definitions/L3AddressData",
+ "description": "Provides the information on the IP addresses to be assigned to the CP instantiated from the parent CPD. Shall be present when the addressType is IP address."
+ }
+ }
+ },
+ "L3AddressData": {
+ "type": "object",
+ "required": [
+ "iPAddressType",
+ "iPAddress"
+ ],
+ "properties": {
+ "iPAddressType": {
+ "type": "string",
+ "description": "IP address type",
+ "enum": [
+ "IPv4",
+ "IPv6"
+ ]
+ },
+ "iPAddress": {
+ "type": "string",
+ "description": "IP address"
+ }
+ }
+ },
+ "VnfInstanceInfo": {
+ "type": "object",
+ "required": [
+ "vnfInstanceId",
+ "vnfInstanceName",
+ "vnfInstanceDescription",
+ "onboardedVnfPkgInfoId",
+ "vnfdId",
+ "vnfdVersion",
+ "vnfSoftwareVersion",
+ "vnfProvider",
+ "vnfProductName",
+ "instantiationState"
+ ],
+ "properties": {
+ "vnfInstanceId": {
+ "type": "string",
+ "description": "VNF instance identifier."
+ },
+ "vnfInstanceName": {
+ "type": "string",
+ "description": "VNF instance name."
+ },
+ "vnfInstanceDescription": {
+ "type": "string",
+ "description": "Human-readable description of the VNF instance."
+ },
+ "onboardedVnfPkgInfoId": {
+ "type": "string",
+ "description": "Identifier of information held by the NFVO about the specific VNF Package on which the VNF is based. This identifier was allocated by the NFVO."
+ },
+ "vnfdId": {
+ "type": "string",
+ "description": "Identifier of the VNFD on which the VNF instance is based."
+ },
+ "vnfdVersion": {
+ "type": "string",
+ "description": "Identifies the version of the VNFD. The value is copied from the VNFD."
+ },
+ "vnfSoftwareVersion": {
+ "type": "string",
+ "description": "Software version of the VNF. The value is copied from the VNFD."
+ },
+ "vnfProvider": {
+ "type": "string",
+ "description": "Name of the person or company providing the VNF. The value is copied from the VNFD."
+ },
+ "vnfProductName": {
+ "type": "string",
+ "description": "Name to identify the VNF Product. Such as VNF Application Type. The value is copied from the VNFD."
+ },
+ "instantiationState": {
+ "type": "string",
+ "description": "The instantiation state of the VNF.",
+ "enum": [
+ "NOT_INSTANTIATED",
+ "INSTANTIATED"
+ ]
+ },
+ "vnfConfigurableProperties": {
+ "type": "object",
+ "description": "Current values of the configurable properties of the VNF instance. Configurable properties as declared in the VNFD."
+ },
+ "metadata": {
+ "type": "object",
+ "description": "Additional metadata describing the VNF instance. This attribute can be modified with the Modify VNF information operation."
+ },
+ "extensions": {
+ "type": "object",
+ "description": "VNF-specific attributes. This attribute can be modified with the Modify VNF information operation."
+ },
+ "instantiatedVnfInfo": {
+ "$ref": "#/definitions/InstantiatedVnfInfo",
+ "description": "Information specific to an instantiated VNF instance. This attribute shall be present if the instantiateState attribute value is INSTANTIATED."
+ }
+ }
+ },
+ "InstantiatedVnfInfo": {
+ "type": "object",
+ "required": [
+ "flavourId",
+ "vnfState"
+ ],
+ "properties": {
+ "flavourId": {
+ "type": "string",
+ "description": "Identifier of the VNF deployment flavour to be instantiated."
+ },
+ "vnfState": {
+ "type": "string",
+ "description": "State of the VNF instance",
+ "enum": [
+ "STARTED",
+ "STOPPED"
+ ]
+ },
+ "scaleStatus": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ScaleInfo"
+ },
+ "description": "Scale status of the VNF, one entry per aspect. Represents for every scaling aspect how \"big\" the VNF has been scaled w.r.t. that aspect. This attribute shall be present if the VNF supports scaling."
+ },
+ "extCpInfo": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/CpInfo"
+ },
+ "description": "Information about the external CPs exposed by the VNF instance."
+ },
+ "extVirtualLink": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/ExtVirtualLinkInfo"
+ },
+ "description": "Information about the external VLs the VNF instance is connected to."
+ },
+ "monitoringParameters": {
+ "type": "object",
+ "description": "Active monitoring parameters."
+ },
+ "localizationLanguage": {
+ "type": "string",
+ "description": "Localization language of the VNF to be instantiated."
+ },
+ "vimInfo": {
+ "type": "array",
+ "description": "Information about VIM(s) managing resources for the VNF instance. This attribute shall be supported and present if VNF-related resource management in direct mode is applicable.",
+ "items": {
+ "$ref": "#/definitions/VimInfo"
+ }
+ },
+ "vnfcResourceInfo": {
+ "type": "array",
+ "description": "Information about the virtualised compute and storage resource(s) used by the VNFCs of the VNF instance. This attribute shall be supported and present if VNF-related resource management in direct mode is applicable.",
+ "items": {
+ "$ref": "#/definitions/VnfcResourceInfo"
+ }
+ },
+ "virtualLinkResourceInfo": {
+ "type": "array",
+ "description": "Information about the virtualised network resource(s) used by the VLs of the VNF instance. This attribute shall be supported and present if VNF-related resource management in direct mode is applicable. ",
+ "items": {
+ "$ref": "#/definitions/VirtualLinkResourceInfo"
+ }
+ },
+ "virtualStorageResourceInfo": {
+ "type": "array",
+ "description": "Information about the virtualised storage resource(s) used as storage for the VNF instance. This attribute shall be supported and present if VNF-related resource management in direct mode is applicable.",
+ "items": {
+ "$ref": "#/definitions/VirtualStorageResourceInfo"
+ }
+ }
+ }
+ },
+ "ScaleInfo": {
+ "type": "object",
+ "required": [
+ "aspectId",
+ "scaleLevel"
+ ],
+ "properties": {
+ "aspectId": {
+ "type": "string",
+ "description": "Identifier of the scaling aspect."
+ },
+ "scaleLevel": {
+ "type": "integer",
+ "format": "int32",
+ "description": "Indicates the scale level. The minimum value shall be 0 and the maximum value shall be <= maxScaleLevel as described in the VNFD."
+ }
+ }
+ },
+ "CpInfo": {
+ "type": "object",
+ "required": [
+ "cpInstanceId",
+ "cpdId"
+ ],
+ "properties": {
+ "cpInstanceId": {
+ "type": "string",
+ "description": "Identifier of the CP instance."
+ },
+ "cpdId": {
+ "type": "string",
+ "description": "Identifier of the CPD, in the VNFD."
+ },
+ "addresses": {
+ "type": "array",
+ "description": "List of network addresses that have been configured on the CP.",
+ "items": {
+ "$ref": "#/definitions/NetworkAddress"
+ }
+ }
+ }
+ },
+ "ExtVirtualLinkInfo": {
+ "type": "object",
+ "required": [
+ "extVirtualLinkId",
+ "resourceHandle"
+ ],
+ "properties": {
+ "extVirtualLinkId": {
+ "type": "string",
+ "description": "Identifier of the external VL."
+ },
+ "resourceHandle": {
+ "$ref": "#/definitions/ResourceHandle",
+ "description": "Identifier of the resource realizing this VL."
+ },
+ "linkPorts": {
+ "type": "array",
+ "description": "Link ports of this VL.",
+ "items": {
+ "$ref": "#/definitions/VnfLinkPort"
+ }
+ }
+ }
+ },
+ "ResourceHandle": {
+ "type": "object",
+ "required": [
+ "resourceId"
+ ],
+ "properties": {
+ "vimId": {
+ "type": "string",
+ "description": "Identifier of the VimInfo information element defining the VIM who manages the resource. This attribute shall be present if VNF-related resource management in direct mode is applicable. The value refers to a vimInfo item in the VnfInstance."
+ },
+ "resourceProviderId": {
+ "type": "string",
+ "description": "Identifier of the entity responsible for the management of the resource. This attribute shall be present when VNF-related resource management in indirect mode is applicable. "
+ },
+ "resourceId": {
+ "type": "string",
+ "description": "Identifier of the resource in the scope of the VIM or the resource provider."
+ }
+ }
+ },
+ "VnfcResourceInfo": {
+ "type": "object",
+ "required": [
+ "vnfcInstanceId",
+ "vduId",
+ "computeResource",
+ "storageResourceIds"
+ ],
+ "properties": {
+ "vnfcInstanceId": {
+ "type": "string",
+ "description": "Identifier of this VNFC instance."
+ },
+ "vduId": {
+ "type": "string",
+ "description": "Reference to the applicable VDU information element in the VNFD."
+ },
+ "computeResource": {
+ "$ref": "#/definitions/ResourceHandle",
+ "description": "Reference to the VirtualCompute resource."
+ },
+ "storageResourceIds": {
+ "type": "array",
+ "description": "Reference(s) to the VirtualStorage resource(s).",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "VirtualStorageResourceInfo": {
+ "type": "object",
+ "required": [
+ "virtualStorageInstanceId",
+ "virtualStorageDescId",
+ "storageResource"
+ ],
+ "properties": {
+ "virtualStorageInstanceId": {
+ "type": "string",
+ "description": "Identifier of this virtual storage resource instance."
+ },
+ "virtualStorageDescId": {
+ "type": "string",
+ "description": "Identifier of the VirtualStorageDesc in the VNFD."
+ },
+ "storageResource": {
+ "$ref": "#/definitions/ResourceHandle",
+ "description": "Reference to the VirtualStorage resource."
+ }
+ }
+ },
+ "VirtualLinkResourceInfo": {
+ "type": "object",
+ "required": [
+ "virtualLinkInstanceId",
+ "virtualLinkDescId",
+ "networkResource"
+ ],
+ "properties": {
+ "virtualLinkInstanceId": {
+ "type": "string",
+ "description": "Identifier of this VL instance."
+ },
+ "virtualLinkDescId": {
+ "type": "string",
+ "description": "Identifier of the Virtual Link Descriptor (VLD) in the VNFD."
+ },
+ "networkResource": {
+ "$ref": "#/definitions/ResourceHandle",
+ "description": "Reference to the VirtualNetwork resource."
+ }
+ }
+ },
+ "VnfLcOpOcc": {
+ "type": "object",
+ "description": "VNF lifecycle operation response",
+ "required": [
+ "vnfLcOpId",
+ "vnfInstanceId",
+ "lcmOperationType",
+ "startTime",
+ "responseDescriptor"
+ ],
+ "properties": {
+ "vnfLcOpId": {
+ "type": "string",
+ "description": "Identifier of a VNF lifecycle operation occurrence"
+ },
+ "vnfInstanceId": {
+ "type": "string",
+ "description": "Identifier of the VNF instance to which the operation applies"
+ },
+ "lcmOperationType": {
+ "type": "string",
+ "description": "Type of the actual LCM operation represented by this lcm operation occurrence.",
+ "enum": [
+ "INSTANTIATE",
+ "SCALE",
+ "SCALE_TO_LEVEL",
+ "CHANGE_FLAVOUR",
+ "TERMINATE",
+ "HEAL",
+ "OPERATE"
+ ]
+ },
+ "startTime": {
+ "type": "string",
+ "description": "Date-time of the start of the operation. Representation: String formatted according to RFC 3339 [13]."
+ },
+ "responseDescriptor": {
+ "type": "#/definitions/VnfLcOpResponseDescriptor",
+ "description": "Including:responseId,progress,statusstatusDescription,errorCode,responseHistoryList"
+ }
+ }
+ },
+ "VnfLcOpResponseDescriptor": {
+ "type": "object",
+ "description": "VNF lifecycle operation response",
+ "required": [
+ "responseId",
+ "progress",
+ "lcmOperationStatus",
+ "statusDescription",
+ "responseHistoryList"
+ ],
+ "properties": {
+ "responseId": {
+ "type": "integer",
+ "description": "Response Identifier."
+ },
+ "progress": {
+ "type": "integer",
+ "description": "progress (1-100)."
+ },
+ "lcmOperationStatus": {
+ "type": "string",
+ "description": "Vnf lifecycle operation Status.",
+ "enum": [
+ "STARTING",
+ "PROCESSING",
+ "COMPLETED",
+ "FAILED"
+ ]
+ },
+ "statusDescription": {
+ "type": "string",
+ "description": "Status Description of a VNF lifecycle operation occurrence"
+ },
+ "errorCode": {
+ "type": "integer",
+ "description": "Error code."
+ },
+ "responseHistoryList": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/VnfLcOpDetail"
+ }
+ }
+ }
+ },
+ "VnfLcOpDetail": {
+ "type": "object",
+ "description": "The Detail of VNF lifecycle operation",
+ "required": [
+ "responseId",
+ "progress",
+ "lcmOperationStatus",
+ "statusDescription"
+ ],
+ "properties": {
+ "responseId": {
+ "type": "integer",
+ "description": "Response Identifier."
+ },
+ "progress": {
+ "type": "integer",
+ "description": "progress (1-100)."
+ },
+ "lcmOperationStatus": {
+ "type": "string",
+ "description": "Vnf lifecycle operation Status.",
+ "enum": [
+ "STARTING",
+ "PROCESSING",
+ "COMPLETED",
+ "FAILED"
+ ]
+ },
+ "statusDescription": {
+ "type": "string",
+ "description": "Status Description of a VNF lifecycle operation occurrence"
+ },
+ "errorCode": {
+ "type": "integer",
+ "description": "Error code."
+ }
+ }
+ },
+ "Error": {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "format": "int32"
+ },
+ "message": {
+ "type": "string"
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/vio/pub/vim/urls.py b/vio/pub/vim/urls.py
new file mode 100644
index 0000000..b47ffe9
--- /dev/null
+++ b/vio/pub/vim/urls.py
@@ -0,0 +1,31 @@
+# Copyright 2016 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+from django.conf.urls import patterns, url
+from rest_framework.urlpatterns import format_suffix_patterns
+
+from vio.pub.vim.views import SwaggerJsonView
+from vio.pub.vim.views import CreateListImagesView
+from vio.pub.vim.views import GetDeleteImageView
+from vio.pub.vim.views import ListTenantsView
+
+urlpatterns = patterns('',
+ url(r'^openoapi/multivim-vio/v1/(?P<vimid>[0-9a-zA-Z_-]+)/images$', CreateListImagesView.as_view()),
+ url(r'^openoapi/multivim-vio/v1/(?P<vimid>[0-9a-zA-Z_-]+)/images/(?P<image_id>[0-9a-zA-Z_-]+)$',
+ GetDeleteImageView.as_view()),
+ url(r'^openoapi/multivim-vio/v1/swagger.json$', SwaggerJsonView.as_view()),
+
+ url(r'^openoapi/multivim-vio/v1/(?P<vimid>[0-9a-zA-Z_-]+)/tenants$', ListTenantsView.as_view()),
+ )
+
+urlpatterns = format_suffix_patterns(urlpatterns)
diff --git a/vio/pub/vim/urls.pyc b/vio/pub/vim/urls.pyc
new file mode 100644
index 0000000..24ccd98
--- /dev/null
+++ b/vio/pub/vim/urls.pyc
Binary files differ
diff --git a/vio/pub/vim/views.py b/vio/pub/vim/views.py
new file mode 100644
index 0000000..f4dddd9
--- /dev/null
+++ b/vio/pub/vim/views.py
@@ -0,0 +1,110 @@
+# Copyright 2016 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import json
+import logging
+import os
+from rest_framework import status
+from rest_framework.response import Response
+from rest_framework.views import APIView
+
+from vio.pub.msapi import extsys
+from vio.pub.vim.vimapi.glance import OperateImage
+from vio.pub.vim.vimapi.keystone import OperateTenant
+
+
+logger = logging.getLogger(__name__)
+
+
+class ListTenantsView(APIView):
+ def get(self, request, vimid):
+ vim_info = extsys.get_vim_by_id(vimid)
+
+ data = {}
+ data['vimid'] = vim_info['vimId']
+ data['vimName'] = vim_info['name']
+ data['username'] = vim_info['userName']
+ data['password'] = vim_info['password']
+ data['url'] = vim_info['url']
+ data['project_name'] = vim_info['tenant']
+
+ tenant_instance = OperateTenant.OperateTenant()
+ projects = tenant_instance.get_projects(data)
+
+ rsp = {}
+ rsp['vimid'] = vim_info['vimId']
+ rsp['vimName'] = vim_info['name']
+ rsp['tenants'] = []
+
+ for project in projects:
+ tenant = {}
+ tenant['id'] = project['id']
+ tenant['name'] = project['name']
+ rsp['tenants'].append(tenant)
+ return Response(data=rsp, status=status.HTTP_200_OK)
+
+
+class CreateListImagesView(APIView):
+ def post(self, request):
+ data = {
+ 'imageName' : request.data['imageName'],
+ 'imagePath' : request.data['imagePath'],
+ 'imageType' : request.data['imageType'],
+ 'containerFormat' : request.data['containerFormat']
+ }
+ rsp = OperateImage.create_image(data)
+ return Response(data=rsp, status=status.HTTP_200_OK)
+
+ def get(self, request):
+ data = {
+ 'imageName' : request.data['imageName'],
+ 'imagePath' : request.data['imagePath'],
+ 'imageType' : request.data['imageType'],
+ 'containerFormat' : request.data['containerFormat']
+ }
+ rsp = OperateImage.list_images(data)
+ return Response(data=rsp, status=status.HTTP_200_OK)
+
+class GetDeleteImageView(APIView):
+ def post(self, request):
+ data = {
+ 'imageName' : request.data['imageName'],
+ 'imagePath' : request.data['imagePath'],
+ 'imageType' : request.data['imageType'],
+ 'containerFormat' : request.data['containerFormat']
+ }
+ rsp = OperateImage.delete_image(data)
+ return Response(data=rsp, status=status.HTTP_200_OK)
+
+ def get(self, request):
+ data = {
+ 'imageName' : request.data['imageName'],
+ 'imagePath' : request.data['imagePath'],
+ 'imageType' : request.data['imageType'],
+ 'containerFormat' : request.data['containerFormat']
+ }
+ rsp = OperateImage.get_image(data)
+ return Response(data=rsp, status=status.HTTP_200_OK)
+
+class SwaggerJsonView(APIView):
+ def get(self, request):
+ json_file = os.path.join(os.path.dirname(__file__), 'swagger.json')
+ f = open(json_file)
+ json_data = json.JSONDecoder().decode(f.read())
+ f.close()
+ return Response(json_data)
+
+
+
diff --git a/vio/pub/vim/views.pyc b/vio/pub/vim/views.pyc
new file mode 100644
index 0000000..beb2dfc
--- /dev/null
+++ b/vio/pub/vim/views.pyc
Binary files differ
diff --git a/vio/pub/vim/vimadaptor.py b/vio/pub/vim/vimadaptor.py
new file mode 100644
index 0000000..1af3e05
--- /dev/null
+++ b/vio/pub/vim/vimadaptor.py
@@ -0,0 +1,117 @@
+# Copyright 2016 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import logging
+import sys
+import traceback
+
+from requests import RequestException
+
+from vio.pub.utils.syscomm import fun_name
+from vio.pub.vim import const
+from vio.pub.exceptions import VimDriverVioException
+
+logger = logging.getLogger(__name__)
+
+
+class VimAdaptor:
+ def __init__(self, connectInfo):
+ logger.info("[VimAdaptor]connectInfo=%s" % connectInfo)
+ self.apiImpl, self.authInfo = None, [1, "No auth info"]
+ self.create_api(connectInfo)
+ self.force_login(connectInfo)
+
+ def create_api(self, connectInfo):
+ vimtype = connectInfo['vimtype'] if 'vimtype' in connectInfo else None
+ logger.info("call %s, vimtype=%s" % (fun_name(), vimtype))
+ if vimtype == const.VIM_OPENSTACK:
+ from vio.pub.nfvi.vim.api.openstack.api import OpenstackApi
+ self.apiImpl = OpenstackApi()
+ else:
+ self.authInfo = [1, "Unsupported vimtype(%s)" % vimtype]
+
+ def api_call(self, funname, fun, *args):
+ logger.info("call %s%s" % (funname, str(args)))
+ ret = None
+ try:
+ ret = fun(self.authInfo[1], *args) if self.authInfo[0] == 0 else self.authInfo
+ except VimException as e:
+ ret = [1, e.message]
+ except RequestException as e:
+ logger.error("request=%s, url=%s" % (e.request.headers._store, e.request.url))
+ logger.error(traceback.format_exc())
+ ret = [1, e.message if e.message else str(sys.exc_info())]
+ except Exception as ex:
+ logger.error(traceback.format_exc())
+ ret = [1, ex.message if ex.message else str(sys.exc_info())]
+ except:
+ logger.error(traceback.format_exc())
+ ret = [1, str(sys.exc_info())]
+ logger.info("[%s]ret=%s" % (funname, ret))
+ return ret
+
+ def force_login(self, connectInfo):
+ if self.apiImpl:
+ logger.info("call %s(%s)" % (fun_name(), connectInfo))
+ try:
+ self.authInfo = self.apiImpl.login(connectInfo)
+ except VimException as e:
+ self.authInfo = [1, e.message]
+ except Exception as ex:
+ logger.error(traceback.format_exc())
+ logger.error(str(sys.exc_info()))
+ self.authInfo = [1, ex.message if ex.message else str(sys.exc_info())]
+ except:
+ logger.error(traceback.format_exc())
+ self.authInfo = [1, str(sys.exc_info())]
+ logger.info("self.authInfo=%s" % self.authInfo)
+
+ def query_net(self, net_id):
+ return self.api_call(fun_name(), self.apiImpl.query_net, net_id)
+
+ def query_nets(self):
+ return self.api_call(fun_name(), self.apiImpl.query_nets)
+
+ def query_subnet(self, subnet_id):
+ return self.api_call(fun_name(), self.apiImpl.query_subnet, subnet_id)
+
+ def query_port(self, port_id):
+ return self.api_call(fun_name(), self.apiImpl.query_port, port_id)
+
+ def create_image(self, data):
+ return self.api_call(fun_name(), self.apiImpl.create_image, data)
+
+ def get_image(self, image_id):
+ return self.api_call(fun_name(), self.apiImpl.get_image, image_id)
+
+ def get_images(self):
+ return self.api_call(fun_name(), self.apiImpl.get_images)
+
+ def delete_image(self, image_id):
+ return self.api_call(fun_name(), self.apiImpl.delete_image, image_id)
+
+ def create_network(self, data):
+ return self.api_call(fun_name(), self.apiImpl.create_network, data)
+
+ def delete_network(self, network_id):
+ return self.api_call(fun_name(), self.apiImpl.delete_network, network_id)
+
+ def delete_subnet(self, subnet_id):
+ return self.api_call(fun_name(), self.apiImpl.delete_subnet, subnet_id)
+
+ def create_port(self, data):
+ return self.api_call(fun_name(), self.apiImpl.create_port, data)
+
+ def delete_port(self, port_id):
+ return self.api_call(fun_name(), self.apiImpl.delete_port, port_id)
diff --git a/vio/pub/vim/vimapi/__init__.py b/vio/pub/vim/vimapi/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vio/pub/vim/vimapi/__init__.py
diff --git a/vio/pub/vim/vimapi/__init__.pyc b/vio/pub/vim/vimapi/__init__.pyc
new file mode 100644
index 0000000..d7d4d7e
--- /dev/null
+++ b/vio/pub/vim/vimapi/__init__.pyc
Binary files differ
diff --git a/vio/pub/vim/vimapi/baseclient.py b/vio/pub/vim/vimapi/baseclient.py
new file mode 100644
index 0000000..902e887
--- /dev/null
+++ b/vio/pub/vim/vimapi/baseclient.py
@@ -0,0 +1,85 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import copy
+
+import logging
+
+from vio.pub.vim.drivers import vimdriver as driver_base
+
+LOG = logging.getLogger(__name__)
+
+
+class baseclient(object):
+
+
+ def __init__(self, **kwargs):
+
+ # initialize clients
+ self._computeclient = None
+ self._networkclient = None
+ self._orchestrationclient = None
+ self._identityclient = None
+
+
+ def identity(self, data):
+ '''Construct compute client based on object.
+
+ :param obj: Object for which the client is created. It is expected to
+ be None when retrieving an existing client. When creating
+ a client, it contains the user and project to be used.
+ '''
+
+ if self._identityclient is not None:
+ return self._identityclient
+ self._identityclient = driver_base.VimDriver().identity(data)
+ return self._identityclient
+
+ def compute(self, data):
+ '''Construct compute client based on object.
+
+ :param obj: Object for which the client is created. It is expected to
+ be None when retrieving an existing client. When creating
+ a client, it contains the user and project to be used.
+ '''
+
+ if self._computeclient is not None:
+ return self._computeclient
+ self._computeclient = driver_base.VimDriver().compute(data)
+ return self._computeclient
+
+ def network(self, obj):
+ """Construct network client based on object.
+
+ :param obj: Object for which the client is created. It is expected to
+ be None when retrieving an existing client. When creating
+ a client, it contains the user and project to be used.
+ """
+ if self._networkclient is not None:
+ return self._networkclient
+ params = self._build_conn_params(obj.user, obj.project)
+ self._networkclient = driver_base.VimDriver().network(params)
+ return self._networkclient
+
+ def orchestration(self, obj):
+ """Construct orchestration client based on object.
+
+ :param obj: Object for which the client is created. It is expected to
+ be None when retrieving an existing client. When creating
+ a client, it contains the user and project to be used.
+ """
+ if self._orchestrationclient is not None:
+ return self._orchestrationclient
+ params = self._build_conn_params(obj.user, obj.project)
+ oc = driver_base.VimDriver().orchestration(params)
+ self._orchestrationclient = oc
+ return oc
diff --git a/vio/pub/vim/vimapi/baseclient.pyc b/vio/pub/vim/vimapi/baseclient.pyc
new file mode 100644
index 0000000..6baced3
--- /dev/null
+++ b/vio/pub/vim/vimapi/baseclient.pyc
Binary files differ
diff --git a/vio/pub/vim/vimapi/compute/OperatorInstance.py b/vio/pub/vim/vimapi/compute/OperatorInstance.py
new file mode 100644
index 0000000..c1c0a80
--- /dev/null
+++ b/vio/pub/vim/vimapi/compute/OperatorInstance.py
@@ -0,0 +1,46 @@
+# Copyright 2016 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import logging
+
+
+from vio.pub.msapi import extsys
+from vio.pub.vim.vimapi.baseclient import baseclient
+
+logger = logging.getLogger(__name__)
+
+
+class OperatorInstance(baseclient):
+ def __init__(self, data):
+ self._novaclient = None
+
+ def create_image(self, data):
+ pass
+
+ def list_images(self, data):
+ pass
+
+ def delete_image(self, data):
+ pass
+
+ def get_image(self, data):
+ kwargs = {}
+ image = self.compute(obj).image_find(name_or_id)
+
+ # wait for new version of openstacksdk to fix this
+ kwargs.pop(self.IMAGE)
+ kwargs['imageRef'] = image.id
+
+
diff --git a/vio/pub/vim/vimapi/compute/__init__.py b/vio/pub/vim/vimapi/compute/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vio/pub/vim/vimapi/compute/__init__.py
diff --git a/vio/pub/vim/vimapi/glance/OperateImage.py b/vio/pub/vim/vimapi/glance/OperateImage.py
new file mode 100644
index 0000000..34787b3
--- /dev/null
+++ b/vio/pub/vim/vimapi/glance/OperateImage.py
@@ -0,0 +1,52 @@
+# Copyright 2016 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import logging
+
+
+from vio.pub.msapi import extsys
+
+logger = logging.getLogger(__name__)
+
+
+class OperatorImage(object):
+ def __init__(self, data):
+ self.ns_model_data = data["ns_model_data"]
+ self.fp_inst_id = data["fpinstid"]
+ self.flow_classifiers_model = get_fp_model_by_fp_inst_id(data["ns_model_data"], self.fp_inst_id)["properties"][
+ "policy"]
+ self.sdnControllerId = ""
+ self.url = ""
+ self.dscp = ""
+ self.ip_proto = ""
+ self.source_port_range = ""
+ self.dest_port_range = ""
+ self.source_ip_range = ""
+ self.dest_ip_range = ""
+ self.flow_classfier_id = ""
+
+
+ def create_image(self, data):
+ pass
+
+ def list_images(self, data):
+ pass
+
+ def delete_image(self, data):
+ pass
+
+ def get_image(self, data):
+ pass
+
diff --git a/vio/pub/vim/vimapi/glance/OperateImage.pyc b/vio/pub/vim/vimapi/glance/OperateImage.pyc
new file mode 100644
index 0000000..9de7e08
--- /dev/null
+++ b/vio/pub/vim/vimapi/glance/OperateImage.pyc
Binary files differ
diff --git a/vio/pub/vim/vimapi/glance/__init__.py b/vio/pub/vim/vimapi/glance/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vio/pub/vim/vimapi/glance/__init__.py
diff --git a/vio/pub/vim/vimapi/glance/__init__.pyc b/vio/pub/vim/vimapi/glance/__init__.pyc
new file mode 100644
index 0000000..9c9d4f6
--- /dev/null
+++ b/vio/pub/vim/vimapi/glance/__init__.pyc
Binary files differ
diff --git a/vio/pub/vim/vimapi/keystone/OperateTenant.py b/vio/pub/vim/vimapi/keystone/OperateTenant.py
new file mode 100644
index 0000000..31e1752
--- /dev/null
+++ b/vio/pub/vim/vimapi/keystone/OperateTenant.py
@@ -0,0 +1,38 @@
+# Copyright 2016 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import logging
+
+
+from vio.pub.msapi import extsys
+from vio.pub.vim.vimapi.baseclient import baseclient
+
+logger = logging.getLogger(__name__)
+
+
+
+class OperateTenant(baseclient):
+
+ def get_projects(self, data):
+ param = {}
+ param['username'] = data['username']
+ param['user_domain_name'] = 'default'
+ param['project_domain_name'] = 'default'
+ param['password'] = data['password']
+ param['auth_url'] = data['url']
+ param['project_name'] = data['project_name']
+ projects = self.identity(param).project_list()
+ return projects
+
diff --git a/vio/pub/vim/vimapi/keystone/OperateTenant.pyc b/vio/pub/vim/vimapi/keystone/OperateTenant.pyc
new file mode 100644
index 0000000..9196c81
--- /dev/null
+++ b/vio/pub/vim/vimapi/keystone/OperateTenant.pyc
Binary files differ
diff --git a/vio/pub/vim/vimapi/keystone/__init__.py b/vio/pub/vim/vimapi/keystone/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vio/pub/vim/vimapi/keystone/__init__.py
diff --git a/vio/pub/vim/vimapi/keystone/__init__.pyc b/vio/pub/vim/vimapi/keystone/__init__.pyc
new file mode 100644
index 0000000..8077715
--- /dev/null
+++ b/vio/pub/vim/vimapi/keystone/__init__.pyc
Binary files differ
diff --git a/vio/pub/vim/vimapi/keystone/auth.py b/vio/pub/vim/vimapi/keystone/auth.py
new file mode 100644
index 0000000..86f03c2
--- /dev/null
+++ b/vio/pub/vim/vimapi/keystone/auth.py
@@ -0,0 +1,27 @@
+# Copyright 2016 ZTE Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import logging
+
+
+from vio.pub.msapi import extsys
+from vio.pub.vim.drivers import base
+
+logger = logging.getLogger(__name__)
+
+def login(data):
+
+ print data
+
diff --git a/vio/pub/vim/vimapi/neutron/__init__.py b/vio/pub/vim/vimapi/neutron/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vio/pub/vim/vimapi/neutron/__init__.py