diff options
Diffstat (limited to 'vio')
108 files changed, 3951 insertions, 2197 deletions
diff --git a/vio/.gitignore b/vio/.gitignore new file mode 100644 index 0000000..821f62a --- /dev/null +++ b/vio/.gitignore @@ -0,0 +1,2 @@ +logs/*.log +*.pyc
\ No newline at end of file diff --git a/vio/README.md b/vio/README.md new file mode 100644 index 0000000..f55799e --- /dev/null +++ b/vio/README.md @@ -0,0 +1,13 @@ +# 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. + +# Micro service of MultiVIM OpenStack VIO driver. diff --git a/vio/__init__.py b/vio/__init__.py deleted file mode 100644 index 05135e7..0000000 --- a/vio/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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/__init__.pyc b/vio/__init__.pyc Binary files differdeleted file mode 100644 index 8df9d95..0000000 --- a/vio/__init__.pyc +++ /dev/null diff --git a/vio/assembly.xml b/vio/assembly.xml new file mode 100644 index 0000000..c59ad59 --- /dev/null +++ b/vio/assembly.xml @@ -0,0 +1,55 @@ +<!-- + 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. +--> +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + <id>vio</id> + <formats> + <format>zip</format> + </formats> + <fileSets> + <fileSet> + <directory>vio</directory> + <outputDirectory>/vio</outputDirectory> + <includes> + <include>**/*.py</include> + <include>**/*.json</include> + <include>**/*.xml</include> + <include>**/*.wsdl</include> + <include>**/*.xsd</include> + <include>**/*.bpel</include> + </includes> + </fileSet> + <fileSet> + <directory>logs</directory> + <outputDirectory>/logs</outputDirectory> + <includes> + <include>*.txt</include> + </includes> + </fileSet> + <fileSet> + <directory>.</directory> + <outputDirectory>/</outputDirectory> + <includes> + <include>*.py</include> + <include>*.txt</include> + <include>*.sh</include> + <include>*.ini</include> + <include>*.md</include> + </includes> + </fileSet> + </fileSets> + <baseDirectory>vio</baseDirectory> + <!--baseDirectory>multivimdriver-openstack/vio</baseDirectory--> +</assembly> diff --git a/vio/initialize.sh b/vio/initialize.sh new file mode 100755 index 0000000..6e0a4c8 --- /dev/null +++ b/vio/initialize.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# 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. + +pip install -r requirements.txt diff --git a/vio/wsgi.py b/vio/manage.py index 139bcf8..f7789f2 100644 --- a/vio/wsgi.py +++ b/vio/manage.py @@ -1,22 +1,20 @@ -# Copyright 2016 ZTE Corporation. +# 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 +# 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 os - -from django.core.wsgi import get_wsgi_application +import sys os.environ.setdefault("DJANGO_SETTINGS_MODULE", "vio.settings") -application = get_wsgi_application() +if __name__ == "__main__": + from django.core.management import execute_from_command_line + execute_from_command_line(sys.argv) diff --git a/vio/pom.xml b/vio/pom.xml new file mode 100644 index 0000000..803c3f6 --- /dev/null +++ b/vio/pom.xml @@ -0,0 +1,50 @@ +<?xml version="1.0"?> +<!-- + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.openo.multivimdriver.vmware.vio</groupId> + <artifactId>multivimdriver-vmware-root</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openo.multivimdriver.vmware.vio</groupId> + <artifactId>multivimdriver-vio</artifactId> + <version>1.1.0-SNAPSHOT</version> + <packaging>pom</packaging> + <name>multivimdriver/vio/mitaka</name> + <description>multivimdriver for vio mitaka</description> + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <appendAssemblyId>false</appendAssemblyId> + <descriptors> + <descriptor>assembly.xml</descriptor> + </descriptors> + </configuration> + <executions> + <execution> + <id>make-assembly</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/vio/pub/__init__.py b/vio/pub/__init__.py deleted file mode 100644 index 4404c8b..0000000 --- a/vio/pub/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2017 VMware 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/__init__.pyc b/vio/pub/__init__.pyc Binary files differdeleted file mode 100644 index 3817a70..0000000 --- a/vio/pub/__init__.pyc +++ /dev/null diff --git a/vio/pub/config/__init__.py b/vio/pub/config/__init__.py deleted file mode 100644 index 4404c8b..0000000 --- a/vio/pub/config/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2017 VMware 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/config/__init__.pyc b/vio/pub/config/__init__.pyc Binary files differdeleted file mode 100644 index 6359646..0000000 --- a/vio/pub/config/__init__.pyc +++ /dev/null diff --git a/vio/pub/config/config.pyc b/vio/pub/config/config.pyc Binary files differdeleted file mode 100644 index 8688805..0000000 --- a/vio/pub/config/config.pyc +++ /dev/null diff --git a/vio/pub/database/__init__.py b/vio/pub/database/__init__.py deleted file mode 100644 index 4404c8b..0000000 --- a/vio/pub/database/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2017 VMware 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/database/__init__.pyc b/vio/pub/database/__init__.pyc Binary files differdeleted file mode 100644 index 343595a..0000000 --- a/vio/pub/database/__init__.pyc +++ /dev/null diff --git a/vio/pub/database/models.pyc b/vio/pub/database/models.pyc Binary files differdeleted file mode 100644 index a8fb076..0000000 --- a/vio/pub/database/models.pyc +++ /dev/null diff --git a/vio/pub/exceptions.py b/vio/pub/exceptions.py deleted file mode 100644 index 8a15b1a..0000000 --- a/vio/pub/exceptions.py +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2017 VMware 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.
-
-
-class VimDriverVioException(Exception):
- def __init__(self, message='', http_code=''):
- self.message = message
- self.http_code = http_code
-
diff --git a/vio/pub/exceptions.pyc b/vio/pub/exceptions.pyc Binary files differdeleted file mode 100644 index 9d2fb0a..0000000 --- a/vio/pub/exceptions.pyc +++ /dev/null diff --git a/vio/pub/msapi/__init__.pyc b/vio/pub/msapi/__init__.pyc Binary files differdeleted file mode 100644 index 64518ef..0000000 --- a/vio/pub/msapi/__init__.pyc +++ /dev/null diff --git a/vio/pub/msapi/extsys.pyc b/vio/pub/msapi/extsys.pyc Binary files differdeleted file mode 100644 index fd50bd2..0000000 --- a/vio/pub/msapi/extsys.pyc +++ /dev/null diff --git a/vio/pub/utils/__init__.py b/vio/pub/utils/__init__.py deleted file mode 100644 index 05135e7..0000000 --- a/vio/pub/utils/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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/utils/__init__.pyc b/vio/pub/utils/__init__.pyc Binary files differdeleted file mode 100644 index fa8fbe8..0000000 --- a/vio/pub/utils/__init__.pyc +++ /dev/null diff --git a/vio/pub/utils/restcall.pyc b/vio/pub/utils/restcall.pyc Binary files differdeleted file mode 100644 index cf077be..0000000 --- a/vio/pub/utils/restcall.pyc +++ /dev/null diff --git a/vio/pub/vim/__init__.pyc b/vio/pub/vim/__init__.pyc Binary files differdeleted file mode 100644 index 74dde2d..0000000 --- a/vio/pub/vim/__init__.pyc +++ /dev/null diff --git a/vio/pub/vim/const.py b/vio/pub/vim/const.py deleted file mode 100644 index d151fb4..0000000 --- a/vio/pub/vim/const.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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 deleted file mode 100644 index e69de29..0000000 --- a/vio/pub/vim/drivers/__init__.py +++ /dev/null diff --git a/vio/pub/vim/drivers/__init__.pyc b/vio/pub/vim/drivers/__init__.pyc Binary files differdeleted file mode 100644 index c62f8eb..0000000 --- a/vio/pub/vim/drivers/__init__.pyc +++ /dev/null diff --git a/vio/pub/vim/drivers/base.pyc b/vio/pub/vim/drivers/base.pyc Binary files differdeleted file mode 100644 index b8ba13c..0000000 --- a/vio/pub/vim/drivers/base.pyc +++ /dev/null diff --git a/vio/pub/vim/drivers/openstacksdk/__init__.py b/vio/pub/vim/drivers/openstacksdk/__init__.py deleted file mode 100644 index 073a03d..0000000 --- a/vio/pub/vim/drivers/openstacksdk/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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 Binary files differdeleted file mode 100644 index d0030da..0000000 --- a/vio/pub/vim/drivers/openstacksdk/__init__.pyc +++ /dev/null diff --git a/vio/pub/vim/drivers/openstacksdk/keystone_v3.py b/vio/pub/vim/drivers/openstacksdk/keystone_v3.py deleted file mode 100644 index 2ca57e4..0000000 --- a/vio/pub/vim/drivers/openstacksdk/keystone_v3.py +++ /dev/null @@ -1,39 +0,0 @@ -# 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 Binary files differdeleted file mode 100644 index 4b279fb..0000000 --- a/vio/pub/vim/drivers/openstacksdk/keystone_v3.pyc +++ /dev/null diff --git a/vio/pub/vim/drivers/openstacksdk/sdk.py b/vio/pub/vim/drivers/openstacksdk/sdk.py deleted file mode 100644 index 1dbed47..0000000 --- a/vio/pub/vim/drivers/openstacksdk/sdk.py +++ /dev/null @@ -1,124 +0,0 @@ -# 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 Binary files differdeleted file mode 100644 index 3daec03..0000000 --- a/vio/pub/vim/drivers/openstacksdk/sdk.pyc +++ /dev/null diff --git a/vio/pub/vim/drivers/vimdriver.py b/vio/pub/vim/drivers/vimdriver.py deleted file mode 100644 index 770a017..0000000 --- a/vio/pub/vim/drivers/vimdriver.py +++ /dev/null @@ -1,25 +0,0 @@ -# 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 Binary files differdeleted file mode 100644 index 69ecf31..0000000 --- a/vio/pub/vim/drivers/vimdriver.pyc +++ /dev/null diff --git a/vio/pub/vim/swagger.json b/vio/pub/vim/swagger.json deleted file mode 100644 index 59140e6..0000000 --- a/vio/pub/vim/swagger.json +++ /dev/null @@ -1,1067 +0,0 @@ -{ - "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 deleted file mode 100644 index b47ffe9..0000000 --- a/vio/pub/vim/urls.py +++ /dev/null @@ -1,31 +0,0 @@ -# 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 Binary files differdeleted file mode 100644 index 24ccd98..0000000 --- a/vio/pub/vim/urls.pyc +++ /dev/null diff --git a/vio/pub/vim/views.py b/vio/pub/vim/views.py deleted file mode 100644 index f4dddd9..0000000 --- a/vio/pub/vim/views.py +++ /dev/null @@ -1,110 +0,0 @@ -# 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 Binary files differdeleted file mode 100644 index beb2dfc..0000000 --- a/vio/pub/vim/views.pyc +++ /dev/null diff --git a/vio/pub/vim/vimadaptor.py b/vio/pub/vim/vimadaptor.py deleted file mode 100644 index 1af3e05..0000000 --- a/vio/pub/vim/vimadaptor.py +++ /dev/null @@ -1,117 +0,0 @@ -# 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 deleted file mode 100644 index e69de29..0000000 --- a/vio/pub/vim/vimapi/__init__.py +++ /dev/null diff --git a/vio/pub/vim/vimapi/__init__.pyc b/vio/pub/vim/vimapi/__init__.pyc Binary files differdeleted file mode 100644 index d7d4d7e..0000000 --- a/vio/pub/vim/vimapi/__init__.pyc +++ /dev/null diff --git a/vio/pub/vim/vimapi/baseclient.py b/vio/pub/vim/vimapi/baseclient.py deleted file mode 100644 index 902e887..0000000 --- a/vio/pub/vim/vimapi/baseclient.py +++ /dev/null @@ -1,85 +0,0 @@ -# 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 Binary files differdeleted file mode 100644 index 6baced3..0000000 --- a/vio/pub/vim/vimapi/baseclient.pyc +++ /dev/null diff --git a/vio/pub/vim/vimapi/compute/OperatorInstance.py b/vio/pub/vim/vimapi/compute/OperatorInstance.py deleted file mode 100644 index c1c0a80..0000000 --- a/vio/pub/vim/vimapi/compute/OperatorInstance.py +++ /dev/null @@ -1,46 +0,0 @@ -# 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 deleted file mode 100644 index e69de29..0000000 --- a/vio/pub/vim/vimapi/compute/__init__.py +++ /dev/null diff --git a/vio/pub/vim/vimapi/glance/OperateImage.py b/vio/pub/vim/vimapi/glance/OperateImage.py deleted file mode 100644 index 34787b3..0000000 --- a/vio/pub/vim/vimapi/glance/OperateImage.py +++ /dev/null @@ -1,52 +0,0 @@ -# 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 Binary files differdeleted file mode 100644 index 9de7e08..0000000 --- a/vio/pub/vim/vimapi/glance/OperateImage.pyc +++ /dev/null diff --git a/vio/pub/vim/vimapi/glance/__init__.py b/vio/pub/vim/vimapi/glance/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/vio/pub/vim/vimapi/glance/__init__.py +++ /dev/null diff --git a/vio/pub/vim/vimapi/glance/__init__.pyc b/vio/pub/vim/vimapi/glance/__init__.pyc Binary files differdeleted file mode 100644 index 9c9d4f6..0000000 --- a/vio/pub/vim/vimapi/glance/__init__.pyc +++ /dev/null diff --git a/vio/pub/vim/vimapi/keystone/OperateTenant.py b/vio/pub/vim/vimapi/keystone/OperateTenant.py deleted file mode 100644 index 31e1752..0000000 --- a/vio/pub/vim/vimapi/keystone/OperateTenant.py +++ /dev/null @@ -1,38 +0,0 @@ -# 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 Binary files differdeleted file mode 100644 index 9196c81..0000000 --- a/vio/pub/vim/vimapi/keystone/OperateTenant.pyc +++ /dev/null diff --git a/vio/pub/vim/vimapi/keystone/__init__.py b/vio/pub/vim/vimapi/keystone/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/vio/pub/vim/vimapi/keystone/__init__.py +++ /dev/null diff --git a/vio/pub/vim/vimapi/keystone/__init__.pyc b/vio/pub/vim/vimapi/keystone/__init__.pyc Binary files differdeleted file mode 100644 index 8077715..0000000 --- a/vio/pub/vim/vimapi/keystone/__init__.pyc +++ /dev/null diff --git a/vio/pub/vim/vimapi/keystone/auth.py b/vio/pub/vim/vimapi/keystone/auth.py deleted file mode 100644 index 86f03c2..0000000 --- a/vio/pub/vim/vimapi/keystone/auth.py +++ /dev/null @@ -1,27 +0,0 @@ -# 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 deleted file mode 100644 index e69de29..0000000 --- a/vio/pub/vim/vimapi/neutron/__init__.py +++ /dev/null diff --git a/vio/requirements.txt b/vio/requirements.txt new file mode 100644 index 0000000..97f6b0b --- /dev/null +++ b/vio/requirements.txt @@ -0,0 +1,24 @@ +# rest framework +Django==1.9.6 +djangorestframework==3.3.3 + +# for access MySQL +MySQL-python==1.2.5 + +# redis cache +redis==2.10.5 + +# for access redis cache +redisco==0.1.4 +django-redis-cache==0.13.1 + +# for call rest api +httplib2==0.9.2 + +# for call openstack api +openstacksdk==0.8.1 + +# for unit test +coverage==4.2 +mock==2.0.0 +unittest_xml_reporting==1.12.0 diff --git a/vio/run.sh b/vio/run.sh new file mode 100755 index 0000000..aa2701f --- /dev/null +++ b/vio/run.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# 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. + +nohup python manage.py runserver 127.0.0.1:9004 > /dev/null & diff --git a/vio/samples/__init__.pyc b/vio/samples/__init__.pyc Binary files differdeleted file mode 100644 index 7329b4c..0000000 --- a/vio/samples/__init__.pyc +++ /dev/null diff --git a/vio/samples/urls.pyc b/vio/samples/urls.pyc Binary files differdeleted file mode 100644 index 931994b..0000000 --- a/vio/samples/urls.pyc +++ /dev/null diff --git a/vio/samples/views.pyc b/vio/samples/views.pyc Binary files differdeleted file mode 100644 index 0dd719e..0000000 --- a/vio/samples/views.pyc +++ /dev/null diff --git a/vio/settings.pyc b/vio/settings.pyc Binary files differdeleted file mode 100644 index 55d242d..0000000 --- a/vio/settings.pyc +++ /dev/null diff --git a/vio/stop.sh b/vio/stop.sh new file mode 100755 index 0000000..0196606 --- /dev/null +++ b/vio/stop.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# 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. + +ps auxww | grep 'manage.py runserver 127.0.0.1:9004' | awk '{print $2}' | xargs kill -9 diff --git a/vio/tox.ini b/vio/tox.ini new file mode 100644 index 0000000..cc9e5ad --- /dev/null +++ b/vio/tox.ini @@ -0,0 +1,10 @@ +[tox] +envlist = py27 +skipsdist = true + +[tox:jenkins] +downloadcache = ~/cache/pip + +[testenv] +deps = -r{toxinidir}/requirements.txt +commands = coverage run --branch manage.py test vio diff --git a/vio/urls.pyc b/vio/urls.pyc Binary files differdeleted file mode 100644 index 8f8eddb..0000000 --- a/vio/urls.pyc +++ /dev/null diff --git a/vio/pub/vim/__init__.py b/vio/vio/__init__.py index 5580cc3..a8fe66a 100644 --- a/vio/pub/vim/__init__.py +++ b/vio/vio/__init__.py @@ -1,13 +1,11 @@ -# Copyright 2016 ZTE Corporation. +# 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 +# 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/msapi/__init__.py b/vio/vio/pub/__init__.py index 54147e8..a8fe66a 100644 --- a/vio/pub/msapi/__init__.py +++ b/vio/vio/pub/__init__.py @@ -1,13 +1,11 @@ -# Copyright 2017 VMware Corporation. +# 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 +# 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/samples/__init__.py b/vio/vio/pub/config/__init__.py index 54147e8..a8fe66a 100644 --- a/vio/samples/__init__.py +++ b/vio/vio/pub/config/__init__.py @@ -1,13 +1,11 @@ -# Copyright 2017 VMware Corporation. +# 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 +# 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/config/config.py b/vio/vio/pub/config/config.py index 307e4e7..7b05698 100644 --- a/vio/pub/config/config.py +++ b/vio/vio/pub/config/config.py @@ -1,50 +1,48 @@ -# Copyright 2017 VMware 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 os
-
-# [MSB]
-MSB_SERVICE_IP = '172.17.0.2' -MSB_SERVICE_PORT = '80' -
-# [IMAGE LOCAL PATH]
-ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-IMAGE_ROOT_PATH = os.path.join(ROOT_PATH, "/VmNfvo/VnfProduct")
-
-# [REDIS]
-REDIS_HOST = '127.0.0.1'
-REDIS_PORT = '6379'
-REDIS_PASSWD = ''
-
-# [mysql]
-DB_IP = '172.17.0.4' +# 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 os + +# [MSB] +MSB_SERVICE_IP = '127.0.0.1' +MSB_SERVICE_PORT = '10080' + +# [IMAGE LOCAL PATH] +ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +# [REDIS] +REDIS_HOST = '127.0.0.1' +REDIS_PORT = '6379' +REDIS_PASSWD = '' + +# [mysql] +DB_IP = "127.0.0.1" DB_PORT = 3306 -DB_NAME = 'inventory' -DB_USER = 'inventory' -DB_PASSWD = 'inventory' -
-# [register]
-REG_TO_MSB_WHEN_START = True
-REG_TO_MSB_REG_URL = "/openoapi/microservices/v1/services"
-REG_TO_MSB_REG_PARAM = {
- "serviceName": "multivim-vio",
- "version": "v1",
- "url": "/openoapi/multivim-vio/v1",
- "protocol": "REST",
- "visualRange": "1",
- "nodes": [{
- "ip": "172.17.0.4",
- "port": "9004",
- "ttl": 0
- }]
-}
+DB_NAME = "multivimvio" +DB_USER = "root" +DB_PASSWD = "password" + +# [register] +REG_TO_MSB_WHEN_START = True +REG_TO_MSB_REG_URL = "/openoapi/microservices/v1/services" +REG_TO_MSB_REG_PARAM = { + "serviceName": "multivim-vio", + "version": "v1", + "url": "/openoapi/multivim-vio/v1", + "protocol": "REST", + "visualRange": "1", + "nodes": [{ + "ip": "127.0.0.1", + "port": "9004", + "ttl": 0 + }] +} diff --git a/vio/vio/pub/database/__init__.py b/vio/vio/pub/database/__init__.py new file mode 100644 index 0000000..a8fe66a --- /dev/null +++ b/vio/vio/pub/database/__init__.py @@ -0,0 +1,11 @@ +# 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. diff --git a/vio/pub/database/models.py b/vio/vio/pub/database/models.py index d9795fe..d07dd6d 100644 --- a/vio/pub/database/models.py +++ b/vio/vio/pub/database/models.py @@ -1,23 +1,21 @@ -# Copyright 2016 ZTE Corporation. +# 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 +# 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.db import models +from django.db import models class VimInstModel(models.Model): class Meta: db_table = 'vim_inst_type_mapping' vimid = models.CharField(db_column='VIMID', primary_key=True, max_length=200) - vimtype = models.CharField(db_column='VIMTYPE', max_length=200) - viminst_url = models.CharField(db_column='VIMINSTURL', max_length=200)
\ No newline at end of file + vimtype = models.CharField(db_column="VIMTYPE", max_length=200) + viminst_url = models.CharField(db_column="VIMINSTURL", max_length=200) diff --git a/vio/vio/pub/exceptions.py b/vio/vio/pub/exceptions.py new file mode 100644 index 0000000..7ebdcc6 --- /dev/null +++ b/vio/vio/pub/exceptions.py @@ -0,0 +1,15 @@ +# 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. + + +class VimDriverVioException(Exception): + pass diff --git a/vio/vio/pub/msapi/__init__.py b/vio/vio/pub/msapi/__init__.py new file mode 100644 index 0000000..a8fe66a --- /dev/null +++ b/vio/vio/pub/msapi/__init__.py @@ -0,0 +1,11 @@ +# 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. diff --git a/vio/pub/msapi/extsys.py b/vio/vio/pub/msapi/extsys.py index eadb965..263d910 100644 --- a/vio/pub/msapi/extsys.py +++ b/vio/vio/pub/msapi/extsys.py @@ -1,16 +1,14 @@ -# Copyright 2017 VMware Corporation. +# 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 +# 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 @@ -25,7 +23,7 @@ def get_vims(): ret = req_by_msb("/openoapi/extsys/v1/vims", "GET") if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) - raise VimDriverVioException("Failed to query vims from extsys.") + raise VimDriverVioException("Failed to query VIMs from extsys.") return json.JSONDecoder().decode(ret[1]) @@ -33,7 +31,5 @@ def get_vim_by_id(vim_id): ret = req_by_msb("/openoapi/extsys/v1/vims/%s" % vim_id, "GET") if ret[0] != 0: logger.error("Status code is %s, detail is %s.", ret[2], ret[1]) - raise VimDriverVioException("Failed to query vim(%s) from extsys." % vim_id) + raise VimDriverVioException("Failed to query VIM with id (%s) from extsys." % vim_id) return json.JSONDecoder().decode(ret[1]) - - diff --git a/vio/vio/pub/utils/__init__.py b/vio/vio/pub/utils/__init__.py new file mode 100644 index 0000000..a8fe66a --- /dev/null +++ b/vio/vio/pub/utils/__init__.py @@ -0,0 +1,11 @@ +# 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. diff --git a/vio/pub/utils/enumutil.py b/vio/vio/pub/utils/enumutil.py index a701e19..334eb0c 100644 --- a/vio/pub/utils/enumutil.py +++ b/vio/vio/pub/utils/enumutil.py @@ -1,16 +1,14 @@ -# Copyright 2017 VMware Corporation. +# 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 +# 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. def enum(**enums): diff --git a/vio/pub/utils/fileutil.py b/vio/vio/pub/utils/fileutil.py index 70a219d..e9ea4bb 100644 --- a/vio/pub/utils/fileutil.py +++ b/vio/vio/pub/utils/fileutil.py @@ -1,16 +1,14 @@ -# Copyright 2017 VMware Corporation. +# 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 +# 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 os import shutil import logging diff --git a/vio/pub/utils/idutil.py b/vio/vio/pub/utils/idutil.py index 4b02a81..95421b7 100644 --- a/vio/pub/utils/idutil.py +++ b/vio/vio/pub/utils/idutil.py @@ -1,16 +1,14 @@ -# Copyright 2017 VMware Corporation. +# 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 +# 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 redisco import containers as cont diff --git a/vio/pub/utils/restcall.py b/vio/vio/pub/utils/restcall.py index 6ad9955..67bf1f6 100644 --- a/vio/pub/utils/restcall.py +++ b/vio/vio/pub/utils/restcall.py @@ -1,95 +1,93 @@ -# Copyright 2017 VMware 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 sys
-import traceback
-import logging
-import urllib2
-import uuid
-import httplib2
-
-from vio.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT
-
-rest_no_auth, rest_oneway_auth, rest_bothway_auth = 0, 1, 2
-HTTP_200_OK, HTTP_201_CREATED, HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED = '200', '201', '204', '202'
-status_ok_list = [HTTP_200_OK, HTTP_201_CREATED, HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED]
-HTTP_404_NOTFOUND, HTTP_403_FORBIDDEN, HTTP_401_UNAUTHORIZED, HTTP_400_BADREQUEST = '404', '403', '401', '400'
-
-logger = logging.getLogger(__name__)
-
-
-def call_req(base_url, user, passwd, auth_type, resource, method, content=''):
- callid = str(uuid.uuid1())
- logger.debug("[%s]call_req('%s','%s','%s',%s,'%s','%s','%s')" % (
- callid, base_url, user, passwd, auth_type, resource, method, content))
- ret = None
- resp_status = ''
- try:
- full_url = combine_url(base_url, resource)
- headers = {'content-type': 'application/json', 'accept': 'application/json'}
- if user:
- headers['Authorization'] = 'Basic ' + ('%s:%s' % (user, passwd)).encode("base64")
- ca_certs = None
- for retry_times in range(3):
- http = httplib2.Http(ca_certs=ca_certs, disable_ssl_certificate_validation=(auth_type == rest_no_auth))
- http.follow_all_redirects = True
- try:
- resp, resp_content = http.request(full_url, method=method.upper(), body=content, headers=headers)
- resp_status, resp_body = resp['status'], resp_content.decode('UTF-8')
- logger.debug("[%s][%d]status=%s,resp_body=%s)" % (callid, retry_times, resp_status, resp_body))
- if resp_status in status_ok_list:
- ret = [0, resp_body, resp_status]
- else:
- ret = [1, resp_body, resp_status]
- break
- except Exception as ex:
- if 'httplib.ResponseNotReady' in str(sys.exc_info()):
- logger.debug("retry_times=%d", retry_times)
- logger.error(traceback.format_exc())
- ret = [1, "Unable to connect to %s" % full_url, resp_status]
- continue
- raise ex
- except urllib2.URLError as err:
- ret = [2, str(err), resp_status]
- except Exception as ex:
- logger.error(traceback.format_exc())
- logger.error("[%s]ret=%s" % (callid, str(sys.exc_info())))
- res_info = str(sys.exc_info())
- if 'httplib.ResponseNotReady' in res_info:
- res_info = "The URL[%s] request failed or is not responding." % full_url
- ret = [3, res_info, resp_status]
- except:
- logger.error(traceback.format_exc())
- ret = [4, str(sys.exc_info()), resp_status]
-
- logger.debug("[%s]ret=%s" % (callid, str(ret)))
- return ret
-
-
-def req_by_msb(resource, method, content=''):
- base_url = "http://%s:%s/" % (MSB_SERVICE_IP, MSB_SERVICE_PORT)
- return call_req(base_url, "", "", rest_no_auth, resource, method, content)
-
-
-def combine_url(base_url, resource):
- full_url = None
- if base_url.endswith('/') and resource.startswith('/'):
- full_url = base_url[:-1] + resource
- elif base_url.endswith('/') and not resource.startswith('/'):
- full_url = base_url + resource
- elif not base_url.endswith('/') and resource.startswith('/'):
- full_url = base_url + resource
- else:
- full_url = base_url + '/' + resource
- return full_url
+# 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 sys +import traceback +import logging +import urllib2 +import uuid +import httplib2 + +from vio.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT + +rest_no_auth, rest_oneway_auth, rest_bothway_auth = 0, 1, 2 +HTTP_200_OK, HTTP_201_CREATED, HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED = '200', '201', '204', '202' +status_ok_list = [HTTP_200_OK, HTTP_201_CREATED, HTTP_204_NO_CONTENT, HTTP_202_ACCEPTED] +HTTP_404_NOTFOUND, HTTP_403_FORBIDDEN, HTTP_401_UNAUTHORIZED, HTTP_400_BADREQUEST = '404', '403', '401', '400' + +logger = logging.getLogger(__name__) + + +def call_req(base_url, user, passwd, auth_type, resource, method, content=''): + callid = str(uuid.uuid1()) + logger.debug("[%s]call_req('%s','%s','%s',%s,'%s','%s','%s')" % ( + callid, base_url, user, passwd, auth_type, resource, method, content)) + ret = None + resp_status = '' + try: + full_url = combine_url(base_url, resource) + headers = {'content-type': 'application/json', 'accept': 'application/json'} + if user: + headers['Authorization'] = 'Basic ' + ('%s:%s' % (user, passwd)).encode("base64") + ca_certs = None + for retry_times in range(3): + http = httplib2.Http(ca_certs=ca_certs, disable_ssl_certificate_validation=(auth_type == rest_no_auth)) + http.follow_all_redirects = True + try: + resp, resp_content = http.request(full_url, method=method.upper(), body=content, headers=headers) + resp_status, resp_body = resp['status'], resp_content.decode('UTF-8') + logger.debug("[%s][%d]status=%s,resp_body=%s)" % (callid, retry_times, resp_status, resp_body)) + if resp_status in status_ok_list: + ret = [0, resp_body, resp_status] + else: + ret = [1, resp_body, resp_status] + break + except Exception as ex: + if 'httplib.ResponseNotReady' in str(sys.exc_info()): + logger.debug("retry_times=%d", retry_times) + logger.error(traceback.format_exc()) + ret = [1, "Unable to connect to %s" % full_url, resp_status] + continue + raise ex + except urllib2.URLError as err: + ret = [2, str(err), resp_status] + except Exception as ex: + logger.error(traceback.format_exc()) + logger.error("[%s]ret=%s" % (callid, str(sys.exc_info()))) + res_info = str(sys.exc_info()) + if 'httplib.ResponseNotReady' in res_info: + res_info = "The URL[%s] request failed or is not responding." % full_url + ret = [3, res_info, resp_status] + except: + logger.error(traceback.format_exc()) + ret = [4, str(sys.exc_info()), resp_status] + + logger.debug("[%s]ret=%s" % (callid, str(ret))) + return ret + + +def req_by_msb(resource, method, content=''): + base_url = "http://%s:%s/" % (MSB_SERVICE_IP, MSB_SERVICE_PORT) + return call_req(base_url, "", "", rest_no_auth, resource, method, content) + + +def combine_url(base_url, resource): + full_url = None + if base_url.endswith('/') and resource.startswith('/'): + full_url = base_url[:-1] + resource + elif base_url.endswith('/') and not resource.startswith('/'): + full_url = base_url + resource + elif not base_url.endswith('/') and resource.startswith('/'): + full_url = base_url + resource + else: + full_url = base_url + '/' + resource + return full_url diff --git a/vio/pub/utils/share_lock.py b/vio/vio/pub/utils/share_lock.py index ffdcdc4..bc541e7 100644..100755 --- a/vio/pub/utils/share_lock.py +++ b/vio/vio/pub/utils/share_lock.py @@ -1,18 +1,16 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright 2017 VMware Corporation. +# 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 +# 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 time diff --git a/vio/pub/utils/syscomm.py b/vio/vio/pub/utils/syscomm.py index 14289d9..f32af8b 100644 --- a/vio/pub/utils/syscomm.py +++ b/vio/vio/pub/utils/syscomm.py @@ -1,19 +1,17 @@ -# 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 inspect
-
-
-def fun_name():
- return inspect.stack()[1][3]
+# 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 inspect + + +def fun_name(): + return inspect.stack()[1][3] diff --git a/vio/pub/utils/timeutil.py b/vio/vio/pub/utils/timeutil.py index b703a3c..03efd97 100644 --- a/vio/pub/utils/timeutil.py +++ b/vio/vio/pub/utils/timeutil.py @@ -1,16 +1,14 @@ -# Copyright 2016 ZTE Corporation. +# 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 +# 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 datetime diff --git a/vio/pub/utils/toscautil.py b/vio/vio/pub/utils/toscautil.py index 0d9065d..0c5f7bb 100644 --- a/vio/pub/utils/toscautil.py +++ b/vio/vio/pub/utils/toscautil.py @@ -1,16 +1,14 @@ -# Copyright 2016 ZTE Corporation. +# 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 +# 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 diff --git a/vio/pub/utils/values.py b/vio/vio/pub/utils/values.py index d380421..f43f8de 100644 --- a/vio/pub/utils/values.py +++ b/vio/vio/pub/utils/values.py @@ -1,25 +1,23 @@ -# 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.
-
-
-def ignore_case_get(args, key, def_val=""):
- if not key:
- return def_val
- if key in args:
- return args[key]
- for old_key in args:
- if old_key.upper() == key.upper():
- return args[old_key]
- return def_val
-
+# 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. + + +def ignore_case_get(args, key, def_val=""): + if not key: + return def_val + if key in args: + return args[key] + for old_key in args: + if old_key.upper() == key.upper(): + return args[old_key] + return def_val + diff --git a/vio/vio/samples/__init__.py b/vio/vio/samples/__init__.py new file mode 100644 index 0000000..a8fe66a --- /dev/null +++ b/vio/vio/samples/__init__.py @@ -0,0 +1,11 @@ +# 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. diff --git a/vio/samples/tests.py b/vio/vio/samples/tests.py index 79301f1..a3dbf4b 100644 --- a/vio/samples/tests.py +++ b/vio/vio/samples/tests.py @@ -1,16 +1,14 @@ -# Copyright 2016 ZTE Corporation. +# 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 +# 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 unittest import json diff --git a/vio/samples/urls.py b/vio/vio/samples/urls.py index 92ad162..0e7ba4c 100644 --- a/vio/samples/urls.py +++ b/vio/vio/samples/urls.py @@ -1,16 +1,14 @@ -# Copyright 2016 ZTE Corporation. +# 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 +# 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 url from vio.samples import views diff --git a/vio/samples/views.py b/vio/vio/samples/views.py index f70090f..a2ba070 100644 --- a/vio/samples/views.py +++ b/vio/vio/samples/views.py @@ -1,16 +1,14 @@ -# Copyright 2016 ZTE Corporation. +# 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 +# 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 diff --git a/vio/settings.py b/vio/vio/settings.py index ff15a95..ba8c5a1 100644 --- a/vio/settings.py +++ b/vio/vio/settings.py @@ -1,16 +1,14 @@ -# Copyright 2016 ZTE Corporation. +# 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 +# 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 os import sys @@ -43,7 +41,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', - 'vio.pub.database' + 'vio.pub.database', ] MIDDLEWARE_CLASSES = [ diff --git a/vio/vio/swagger/__init__.py b/vio/vio/swagger/__init__.py new file mode 100644 index 0000000..a8fe66a --- /dev/null +++ b/vio/vio/swagger/__init__.py @@ -0,0 +1,11 @@ +# 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. diff --git a/vio/vio/swagger/multivim.flavor.swagger.json b/vio/vio/swagger/multivim.flavor.swagger.json new file mode 100644 index 0000000..60dc7d8 --- /dev/null +++ b/vio/vio/swagger/multivim.flavor.swagger.json @@ -0,0 +1,397 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "MultiVIM Service rest API" + }, + "basePath": "/openoapi/multivim/v1/", + "tags": [ + { + "name": "MultiVIM broker" + } + ], + "paths": { + "/{vimid}/{tenantid}/flavors": { + "post": { + "tags": [ + "vim flavors" + ], + "summary": "create a flavor", + "description": "create a flavor", + "operationId": "create_vim_flavor", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "create vim flavor request param", + "required": true, + "schema": { + "$ref": "#/definitions/CreateVimFlavor" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimFlavorInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim flavor is not accessable" + } + } + }, + "get": { + "tags": [ + "vim flavors" + ], + "summary": "query vim flavors list", + "description": "query vim flavors list", + "operationId": "query_vim_flavors", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "get a list of vim flavors request param", + "required": false, + "schema": { + "$ref": "#/definitions/ListVimFlavors" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimFlavorsInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim flavor is not accessable" + } + } + } + }, + "/{vimid}/{tenantid}/flavors/{flavorid}": { + "delete": { + "tags": [ + "vim flavors" + ], + "summary": "delete specific vim flavor", + "description": "delete specific vim flavor", + "operationId": "delete_vim_flavor", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "flavorid", + "in": "path", + "description": "vim flavor id", + "required": true, + "type": "string" + } + ], + "responses": { + "204": { + "description": "successful operation" + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim flavor is not accessable" + } + } + }, + "get": { + "tags": [ + "vim flavors" + ], + "summary": "query specific vim flavor", + "description": "query specific vim flavor", + "operationId": "query_vim_flavor", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "flavorid", + "in": "path", + "description": "vim flavor id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimFlavorInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim flavor is not accessable" + } + } + } + } + }, + "definitions": { + "CreateVimFlavor": { + "type": "object", + "required": [ + "vcpu", + "name", + "memory", + "disk" + ], + "properties": { + "name": { + "type": "string", + "description": "flavor name" + }, + "vcpu": { + "type": "integer", + "description": "virtual cpu number" + }, + "memory": { + "type": "integer", + "description": "memory size" + }, + "disk": { + "type": "integer", + "description": "The size of the root disk" + }, + "ephemeral": { + "type": "integer", + "description": "The size of the ephemeral disk" + }, + "swap": { + "type": "integer", + "description": "The size of the swap disk" + }, + "isPublic": { + "type": "boolean", + "description": "whether the flavor is public" + }, + "extraSpecs": { + "type": "array", + "description": "list of extra specs", + "items": { + "$ref": "#/definitions/VimFlavorExtraSpecInfo" + } + } + } + }, + "VimFlavorExtraSpecInfo": { + "type": "object", + "properties": { + "keyName": { + "type": "string", + "description": "extra spec key" + }, + "value": { + "type": "string", + "description": "extra spec value" + } + } + }, + "ListVimFlavors": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "flavor name to filter flavor list" + }, + "limit": { + "type": "integer", + "description": "Requests a page size of items" + }, + "marker": { + "type": "string", + "description": "flavor ID of the last-seen item" + } + } + }, + "VimFlavorsInfo": { + "type": "object", + "required": [ + "vimId", + "tenantId", + "flavors" + ], + "properties": { + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "flavors": { + "type": "array", + "description": "flavor list information", + "items": { + "$ref": "#/definitions/VimFlavorInfo" + } + } + } + }, + "VimFlavorInfo": { + "type": "object", + "required": [ + "name", + "id", + "vcpu", + "memory", + "disk", + "ephemeral", + "swap", + "isPublic" + ], + "properties": { + "name": { + "type": "string", + "description": "flavor name" + }, + "id": { + "type": "string", + "description": "flavor UUID" + }, + "vcpu": { + "type": "integer", + "description": "virtual cpu number" + }, + "memory": { + "type": "integer", + "description": "memory size" + }, + "disk": { + "type": "integer", + "description": "The size of the root disk" + }, + "ephemeral": { + "type": "integer", + "description": "The size of the ephemeral disk" + }, + "swap": { + "type": "integer", + "description": "The size of the swap disk" + }, + "isPublic": { + "type": "boolean", + "description": "whether the flavor is public" + }, + "extraSpecs": { + "type": "array", + "description": "list of extra specs", + "items": { + "$ref": "#/definitions/VimFlavorExtraSpecInfo" + } + }, + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "returnCode": { + "type": "integer", + "description": "0: Already exist 1: Newly created" + } + } + } + } +} diff --git a/vio/vio/swagger/multivim.host.swagger.json b/vio/vio/swagger/multivim.host.swagger.json new file mode 100644 index 0000000..db24a17 --- /dev/null +++ b/vio/vio/swagger/multivim.host.swagger.json @@ -0,0 +1,183 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "MultiVIM Service rest API" + }, + "basePath": "/openoapi/multivim/v1/", + "tags": [ + { + "name": "MultiVIM broker" + } + ], + "paths": { + "/{vimid}/{tenantid}/hosts": { + "get": { + "tags": [ + "vim hosts" + ], + "summary": "query vim hosts list", + "description": "query vim hosts list", + "operationId": "query_vim_hosts", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "get a list of vim hosts request param", + "required": false, + "schema": { + "$ref": "#/definitions/ListVimHosts" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimHostsInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim host is not accessable" + } + } + } + }, + "/{vimid}/{tenantid}/hosts/{hostname}": { + "get": { + "tags": [ + "vim hosts" + ], + "summary": "query specific vim host", + "description": "query specific vim host", + "operationId": "query_vim_host", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "hostname", + "in": "path", + "description": "vim host name", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimHostInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim host is not accessable" + } + } + } + } + }, + "definitions": { + "VimHostsInfo": { + "type": "object", + "required": [ + "vimId", + "tenantId", + "hosts" + ], + "properties": { + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "hosts": { + "type": "array", + "description": "list of host information", + "items": { + "$ref": "#/definitions/VimHostInfo" + } + } + } + }, + "VimHostInfo": { + "type": "object", + "required": [ + "name", + "service" + ], + "properties": { + "name": { + "type": "string", + "description": "host name" + }, + "service": { + "type": "string", + "description": "service name running on the host" + }, + "zone": { + "type": "string", + "description": "available zone name of the host" + }, + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + } + } + } + } +} diff --git a/vio/vio/swagger/multivim.image.swagger.json b/vio/vio/swagger/multivim.image.swagger.json new file mode 100644 index 0000000..b6102ec --- /dev/null +++ b/vio/vio/swagger/multivim.image.swagger.json @@ -0,0 +1,384 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "MultiVIM Service rest API" + }, + "basePath": "/openoapi/multivim/v1/", + "tags": [ + { + "name": "MultiVIM broker" + } + ], + "paths": { + "/{vimid}/{tenantid}/images": { + "post": { + "tags": [ + "vim images" + ], + "summary": "create a image", + "description": "create a image", + "operationId": "create_vim_image", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "create vim image request param", + "required": true, + "schema": { + "$ref": "#/definitions/CreateVimImage" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimImageInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim image is not accessable" + } + } + }, + "get": { + "tags": [ + "vim images" + ], + "summary": "query vim images list", + "description": "query vim images list", + "operationId": "query_vim_images", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "get a list of vim images request param", + "required": false, + "schema": { + "$ref": "#/definitions/ListVimImages" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimImagesInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim image is not accessable" + } + } + } + }, + "/{vimid}/{tenantid}/images/{imageid}": { + "delete": { + "tags": [ + "vim images" + ], + "summary": "delete specific vim image", + "description": "delete specific vim image", + "operationId": "delete_vim_image", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "imageid", + "in": "path", + "description": "vim image id", + "required": true, + "type": "string" + } + ], + "responses": { + "204": { + "description": "successful operation" + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim image is not accessable" + } + } + }, + "get": { + "tags": [ + "vim images" + ], + "summary": "query specific vim image", + "description": "query specific vim image", + "operationId": "query_vim_image", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "imageid", + "in": "path", + "description": "vim image id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimImageInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim image is not accessable" + } + } + } + } + }, + "definitions": { + "CreateVimImage": { + "type": "object", + "required": [ + "imagePath", + "name", + "imageType", + "containerFormat" + ], + "properties": { + "name": { + "type": "string", + "description": "image name" + }, + "imageType": { + "type": "string", + "description": "image type: ami, ari, aki, vhd, vhdx, vmdk, raw, qcow2, vdi, iso" + }, + "imagePath": { + "type": "string", + "description": "image url to catalog" + }, + "containerFormat": { + "type": "string", + "description": "image container format: ami, ari, aki, bare, ovf, ova, docker" + }, + "visibility": { + "type": "string", + "description": "public, private, shared, or community" + }, + "properties": { + "type": "array", + "description": "list of properties", + "items": { + "$ref": "#/definitions/VimImagePropertyInfo" + } + } + } + }, + "VimImagePropertyInfo": { + "type": "object", + "properties": { + "keyName": { + "type": "string", + "description": "property name" + }, + "value": { + "type": "string", + "description": "property value" + } + } + }, + "ListVimImages": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "image name to filter image list" + }, + "limit": { + "type": "string", + "description": "Requests a page size of items" + }, + "marker": { + "type": "string", + "description": "image ID of the last-seen item" + } + } + }, + "VimImagesInfo": { + "type": "object", + "required": [ + "vimId", + "tenantId", + "images" + ], + "properties": { + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "images": { + "type": "array", + "description": "image list information", + "items": { + "$ref": "#/definitions/VimImageInfo" + } + } + } + }, + "VimImageInfo": { + "type": "object", + "required": [ + "name", + "status", + "id" + ], + "properties": { + "name": { + "type": "string", + "description": "image name" + }, + "id": { + "type": "string", + "description": "image UUID" + }, + "imageType": { + "type": "string", + "description": "image type: ami, ari, aki, vhd, vhdx, vmdk, raw, qcow2, vdi, iso" + }, + "imagePath": { + "type": "string", + "description": "image url to catalog" + }, + "containerFormat": { + "type": "string", + "description": "image container format: ami, ari, aki, bare, ovf, ova, docker" + }, + "visibility": { + "type": "string", + "description": "public, private, shared, or community" + }, + "properties": { + "type": "array", + "description": "list of properties", + "items": { + "$ref": "#/definitions/VimImagePropertyInfo" + } + }, + "status": { + "type": "string", + "description": "image status" + }, + "size": { + "type": "string", + "description": "image size" + }, + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "returnCode": { + "type": "integer", + "description": "0: Already exist 1: Newly created" + } + } + } + } +} diff --git a/vio/vio/swagger/multivim.limit.swagger.json b/vio/vio/swagger/multivim.limit.swagger.json new file mode 100644 index 0000000..f5605b5 --- /dev/null +++ b/vio/vio/swagger/multivim.limit.swagger.json @@ -0,0 +1,158 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "MultiVIM Service rest API" + }, + "basePath": "/openoapi/multivim/v1/", + "tags": [ + { + "name": "MultiVIM broker" + } + ], + "paths": { + "/{vimid}/{tenantid}/limits": { + "get": { + "tags": [ + "vim limits" + ], + "summary": "query vim limits list", + "description": "query vim limits list", + "operationId": "query_vim_limits", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimLimitsInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim limits is not accessable" + } + } + } + } + }, + "definitions": { + "VimLimitsInfo": { + "type": "object", + "required": [ + "vimId", + "tenantId" + ], + "properties": { + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "maxPersonality": { + "type": "integer", + "description": "The number of allowed injected files for each tenant" + }, + "maxPersonalitySize": { + "type": "integer", + "description": "The number of allowed bytes of content for each injected file" + }, + "maxServerGroupMembers": { + "type": "integer", + "description": "The number of allowed members for each server group" + }, + "maxServerGroups": { + "type": "integer", + "description": "The number of allowed server groups for each tenant" + }, + "maxServerMeta": { + "type": "integer", + "description": "The number of allowed metadata items for each instance" + }, + "maxTotalCores": { + "type": "integer", + "description": "The number of allowed instance cores for each tenant" + }, + "maxTotalInstances": { + "type": "integer", + "description": "The number of allowed instances for each tenant" + }, + "maxTotalKeypairs": { + "type": "integer", + "description": "The number of allowed key pairs for each user" + }, + "maxTotalRAMSize": { + "type": "integer", + "description": "The amount of allowed instance RAM, in MB, for each tenant" + }, + "maxTotalVolumeGigabytes": { + "type": "integer", + "description": "The maximum total amount of volumes, in gibibytes (GiB)." + }, + "maxTotalVolumes": { + "type": "integer", + "description": "The maximum number of volumes" + }, + "totalGigabytesUsed": { + "type": "integer", + "description": "The total number of gibibytes (GiB) used" + }, + "network": { + "type": "integer", + "description": "The number of networks allowed for each project" + }, + "subnet": { + "type": "integer", + "description": "The number of subnets allowed for each project" + }, + "subnetpool": { + "type": "integer", + "description": "The number of subnet pools allowed for each project" + }, + "security_group_rule": { + "type": "integer", + "description": "The number of security group rules allowed for each project" + }, + "security_group": { + "type": "integer", + "description": "The number of security groups allowed for each project" + }, + "router": { + "type": "integer", + "description": "The number of routers allowed for each project" + }, + "port": { + "type": "integer", + "description": "The number of ports allowed for each project" + } + } + } + } +} diff --git a/vio/vio/swagger/multivim.network.swagger.json b/vio/vio/swagger/multivim.network.swagger.json new file mode 100644 index 0000000..fb120b2 --- /dev/null +++ b/vio/vio/swagger/multivim.network.swagger.json @@ -0,0 +1,360 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "MultiVIM Service rest API" + }, + "basePath": "/openoapi/multivim/v1/", + "tags": [ + { + "name": "MultiVIM broker" + } + ], + "paths": { + "/{vimid}/{tenantid}/networks": { + "post": { + "tags": [ + "vim networks" + ], + "summary": "create a network", + "description": "create a network", + "operationId": "create_vim_network", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "create vim network request param", + "required": true, + "schema": { + "$ref": "#/definitions/CreateVimNetwork" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimNetworkInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim network is not accessable" + } + } + }, + "get": { + "tags": [ + "vim networks" + ], + "summary": "query vim networks list", + "description": "query vim networks list", + "operationId": "query_vim_networks", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "get a list of vim networks request param", + "required": false, + "schema": { + "$ref": "#/definitions/ListVimNetworks" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimNetworksInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim network is not accessable" + } + } + } + }, + "/{vimid}/{tenantid}/networks/{networkid}": { + "delete": { + "tags": [ + "vim networks" + ], + "summary": "delete specific vim network", + "description": "delete specific vim network", + "operationId": "delete_vim_network", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "networkid", + "in": "path", + "description": "vim network id", + "required": true, + "type": "string" + } + ], + "responses": { + "204": { + "description": "successful operation" + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the network is not accessable" + } + } + }, + "get": { + "tags": [ + "vim networks" + ], + "summary": "query specific vim network", + "description": "query specific vim network", + "operationId": "query_vim_network", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "networkid", + "in": "path", + "description": "vim network id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimNetworkInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim network is not accessable" + } + } + } + } + }, + "definitions": { + "CreateVimNetwork": { + "type": "object", + "required": [ + "networkType", + "name", + "shared" + ], + "properties": { + "name": { + "type": "string", + "description": "network name" + }, + "networkType": { + "type": "string", + "description": "network type" + }, + "physicalNetwork": { + "type": "string", + "description": "physical network name" + }, + "segmentationId": { + "type": "integer", + "description": "segmentation ID of physical network" + }, + "vlanTransparent": { + "type": "boolean", + "description": "vlan transparent" + }, + "shared": { + "type": "boolean", + "description": "network is shared across tenants" + }, + "routerExternal": { + "type": "boolean", + "description": "network can provide floating IPs via a router" + } + } + }, + "ListVimNetworks": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "network name" + } + } + }, + "VimNetworksInfo": { + "type": "object", + "required": [ + "vimId", + "tenantId", + "networks" + ], + "properties": { + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "networks": { + "type": "array", + "description": "network information", + "items": { + "$ref": "#/definitions/VimNetworkInfo" + } + } + } + }, + "VimNetworkInfo": { + "type": "object", + "required": [ + "name", + "status", + "id" + ], + "properties": { + "name": { + "type": "string", + "description": "network name" + }, + "id": { + "type": "string", + "description": "network UUID" + }, + "status": { + "type": "string", + "description": "network status" + }, + "networkType": { + "type": "string", + "description": "network type" + }, + "physicalNetwork": { + "type": "string", + "description": "physical network name" + }, + "segmentationId": { + "type": "boolean", + "description": "segmentationId of physical network" + }, + "vlanTransparent": { + "type": "boolean", + "description": "vlan transparent" + }, + "shared": { + "type": "boolean", + "description": "network is shared across tenants" + }, + "routerExternal": { + "type": "boolean", + "description": "network can provide floating IPs via a router" + }, + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "returnCode": { + "type": "integer", + "description": "0: Already exist 1: Newly created" + } + } + } + } +} diff --git a/vio/vio/swagger/multivim.server.swagger.json b/vio/vio/swagger/multivim.server.swagger.json new file mode 100644 index 0000000..82de122 --- /dev/null +++ b/vio/vio/swagger/multivim.server.swagger.json @@ -0,0 +1,493 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "MultiVIM Service rest API" + }, + "basePath": "/openoapi/multivim/v1/", + "tags": [ + { + "name": "MultiVIM broker" + } + ], + "paths": { + "/{vimid}/{tenantid}/servers": { + "post": { + "tags": [ + "vim servers" + ], + "summary": "create a server", + "description": "create a server", + "operationId": "create_vim_server", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "create vim server request param", + "required": true, + "schema": { + "$ref": "#/definitions/CreateVimServer" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimServerInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim server is not accessable" + } + } + }, + "get": { + "tags": [ + "vim servers" + ], + "summary": "query vim servers list", + "description": "query vim servers list", + "operationId": "query_vim_servers", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "get a list of vim servers request param", + "required": false, + "schema": { + "$ref": "#/definitions/ListVimServers" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimServersInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim server is not accessable" + } + } + } + }, + "/{vimid}/{tenantid}/servers/{serverid}": { + "delete": { + "tags": [ + "vim servers" + ], + "summary": "delete specific vim server", + "description": "delete specific vim server", + "operationId": "delete_vim_server", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "serverid", + "in": "path", + "description": "vim server id", + "required": true, + "type": "string" + } + ], + "responses": { + "204": { + "description": "successful operation" + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim server is not accessable" + } + } + }, + "get": { + "tags": [ + "vim servers" + ], + "summary": "query specific vim server", + "description": "query specific vim server", + "operationId": "query_vim_server", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "serverid", + "in": "path", + "description": "vim server id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimServerInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim server is not accessable" + } + } + } + } + }, + "definitions": { + "CreateVimServer": { + "type": "object", + "required": [ + "name", + "boot", + "flavorId" + ], + "properties": { + "name": { + "type": "string", + "description": "server name" + }, + "boot": { + "type": "object", + "description": "Parameters to start a server", + "properties": { + "type": { + "type": "integer", + "description": "boot type: 1: boot from volume, 2: boot from image" + }, + "volumeId": { + "type": "string", + "description": "volume UUID to boot server" + }, + "imageId": { + "type": "string", + "description": "image UUID to boot server" + } + } + }, + "flavorId": { + "type": "string", + "description": "flavor uuid to start server" + }, + "contextArray": { + "type": "array", + "description": "list of injected files", + "items": { + "$ref": "#/definitions/VimServerContextInfo" + } + }, + "volumeArray": { + "type": "array", + "description": "list of volumes attached to a server", + "items": { + "$ref": "#/definitions/VimServerVolumeInfo" + } + }, + "nicArray": { + "type": "array", + "description": "list of volumes attached to a server", + "items": { + "$ref": "#/definitions/VimServerNicInfo" + } + }, + "availabilityZone": { + "type": "string", + "description": "The availability zone from which to launch the server." + }, + "metadata": { + "type": "array", + "description": "list of key-value pairs for metadata to start a server", + "items": { + "$ref": "#/definitions/VimServerKeyValuePair" + } + }, + "userdata": { + "type": "string", + "description": "user data to start a aserver" + }, + "securityGroups": { + "type": "array", + "description": "list of security groups for a server", + "items": { + "type": "string", + "description": "name of security group" + } + }, + "serverGroup": { + "type": "string", + "description": "server group" + } + } + }, + "VimServerKeyValuePair": { + "type": "object", + "properties": { + "keyName": { + "type": "string", + "description": "key name" + }, + "value": { + "type": "string", + "description": "value " + } + } + }, + "VimServerContextInfo": { + "type": "object", + "properties": { + "fileName": { + "type": "string", + "description": "Injected file name" + }, + "fileData": { + "type": "string", + "description": "Injected file content " + } + } + }, + "VimServerVolumeInfo": { + "type": "object", + "properties": { + "volumeId": { + "type": "string", + "description": "volume UUID" + } + } + }, + "VimServerNicInfo": { + "type": "object", + "properties": { + "portId": { + "type": "string", + "description": "virtual port UUID to boot a server" + } + } + }, + "ListVimServers": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "server name to filter server list" + }, + "limit": { + "type": "integer", + "description": "Requests a page size of items" + }, + "marker": { + "type": "string", + "description": "server ID of the last-seen item" + } + } + }, + "VimServersInfo": { + "type": "object", + "required": [ + "vimId", + "tenantId", + "servers" + ], + "properties": { + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "servers": { + "type": "array", + "description": "server list information", + "items": { + "$ref": "#/definitions/VimServerInfo" + } + } + } + }, + "VimServerInfo": { + "type": "object", + "required": [ + "name", + "status", + "id" + ], + "properties": { + "name": { + "type": "string", + "description": "server name" + }, + "id": { + "type": "string", + "description": "server UUID" + }, + "status": { + "type": "string", + "description": "server status,0:INACTIVE,1:ACTIVE,2:ERROR" + }, + "boot": { + "type": "object", + "description": "Parameters to start a server", + "properties": { + "type": { + "type": "integer", + "description": "boot type: 1: boot from volume, 2: boot from image" + }, + "volumeId": { + "type": "string", + "description": "volume UUID to boot server" + }, + "ImageId": { + "type": "string", + "description": "image UUID to boot server" + } + } + }, + "flavorId": { + "type": "string", + "description": "flavor uuid to start server" + }, + "volumeArray": { + "type": "array", + "description": "list of volumes attached to a server", + "items": { + "$ref": "#/definitions/VimServerVolumeInfo" + } + }, + "nicArray": { + "type": "array", + "description": "list of volumes attached to a server", + "items": { + "$ref": "#/definitions/VimServerNicInfo" + } + }, + "availabilityZone": { + "type": "string", + "description": "available zone for a server" + }, + "metadata": { + "type": "array", + "description": "list of key-value pairs for metadata to start a server", + "items": { + "$ref": "#/definitions/VimServerKeyValuePair" + } + }, + "securityGroups": { + "type": "array", + "description": "list of security groups for a server", + "items": { + "type": "string", + "description": "name of security group" + } + }, + "serverGroup": { + "type": "string", + "description": "server group" + }, + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "returnCode": { + "type": "integer", + "description": "0: Already exist 1: Newly created" + } + } + } + } +} diff --git a/vio/vio/swagger/multivim.subnet.swagger.json b/vio/vio/swagger/multivim.subnet.swagger.json new file mode 100644 index 0000000..d862a68 --- /dev/null +++ b/vio/vio/swagger/multivim.subnet.swagger.json @@ -0,0 +1,428 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "MultiVIM Service rest API" + }, + "basePath": "/openoapi/multivim/v1/", + "tags": [ + { + "name": "MultiVIM broker" + } + ], + "paths": { + "/{vimid}/{tenantid}/subnets": { + "post": { + "tags": [ + "vim subnets" + ], + "summary": "create a subnet", + "description": "create a subnet", + "operationId": "create_vim_subnet", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "create vim subnet request param", + "required": true, + "schema": { + "$ref": "#/definitions/CreateVimSubnet" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimSubnetInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim subnet is not accessable" + } + } + }, + "get": { + "tags": [ + "vim subnets" + ], + "summary": "query vim subnets list", + "description": "query vim subnets list", + "operationId": "query_vim_subnets", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "get a list of vim subnets request param", + "required": false, + "schema": { + "$ref": "#/definitions/ListVimSubnets" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimSubnetsInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim subnet is not accessable" + } + } + } + }, + "/{vimid}/{tenantid}/subnets/{subnetid}": { + "delete": { + "tags": [ + "vim subnets" + ], + "summary": "delete specific vim subnet", + "description": "delete specific vim subnet", + "operationId": "delete_vim_subnet", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "subnetid", + "in": "path", + "description": "vim subnet id", + "required": true, + "type": "string" + } + ], + "responses": { + "204": { + "description": "successful operation" + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the subnet is not accessable" + } + } + }, + "get": { + "tags": [ + "vim subnets" + ], + "summary": "query specific vim subnet", + "description": "query specific vim subnet", + "operationId": "query_vim_subnet", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "subnetid", + "in": "path", + "description": "vim subnet id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimSubnetInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim subnet id is invalid" + } + } + } + } + }, + "definitions": { + "CreateVimSubnet": { + "type": "object", + "required": [ + "networkId", + "name", + "cidr", + "ipVersion" + ], + "properties": { + "networkId": { + "type": "string", + "description": "network UUID" + }, + "name": { + "type": "string", + "description": "subnet name" + }, + "cidr": { + "type": "string", + "description": "subnet CIDR" + }, + "ipVersion": { + "type": "integer", + "description": "IP version: 4 for IPv4, 6 for IPv6" + }, + "enableDhcp": { + "type": "boolean", + "description": "Enable DHCP or not" + }, + "gatewayIp": { + "type": "string", + "description": "gateway IP address" + }, + "dnsNameservers": { + "type": "array", + "description": "DNS Nameservers", + "items": { + "type": "string" + } + }, + "hostRoutes": { + "type": "array", + "description": "Host route entries", + "items": { + "$ref": "#/definitions/VimHostRouteInfo" + } + }, + "allocationPools": { + "type": "array", + "description": "IP address allocation pools", + "items": { + "$ref": "#/definitions/VimIpAllocationPoolInfo" + } + } + } + }, + "VimHostRouteInfo": { + "type": "object", + "properties": { + "destination": { + "type": "string", + "description": "destination field of a route entry" + }, + "nexthop ": { + "type": "string", + "description": "next hop of a route entry" + } + } + }, + "VimIpAllocationPoolInfo": { + "type": "object", + "properties": { + "start": { + "type": "string", + "description": "start IP address of a pool" + }, + "end ": { + "type": "string", + "description": "end IP address of a pool" + } + } + }, + "ListVimSubnets": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "subnet name" + } + } + }, + "VimSubnetsInfo": { + "type": "object", + "required": [ + "vimId", + "tenantId", + "subnets" + ], + "properties": { + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "subnets": { + "type": "array", + "description": "subnets information", + "items": { + "$ref": "#/definitions/VimSubnetInfo" + } + } + } + }, + "VimSubnetInfo": { + "type": "object", + "required": [ + "name", + "status", + "id", + "networkId", + "cidr", + "ipVersion" + ], + "properties": { + "name": { + "type": "string", + "description": "subnet name" + }, + "id": { + "type": "string", + "description": "subnet UUID" + }, + "status": { + "type": "string", + "description": "subnet status" + }, + "networkId": { + "type": "string", + "description": "network UUID" + }, + "networkName": { + "type": "string", + "description": "network name" + }, + "cidr": { + "type": "string", + "description": "subnet CIDR" + }, + "ipVersion": { + "type": "integer", + "description": "IP version: 4 for IPv4, 6 for IPv6" + }, + "enableDhcp": { + "type": "boolean", + "description": "Enable DHCP or not" + }, + "gatewayIp": { + "type": "string", + "description": "gateway IP address" + }, + "dnsNameservers": { + "type": "array", + "description": "DNS Nameservers", + "items": { + "type": "string" + } + }, + "hostRoutes": { + "type": "array", + "description": "Host route entries", + "items": { + "$ref": "#/definitions/VimHostRouteInfo" + } + }, + "allocationPools": { + "type": "array", + "description": "IP address allocation pools", + "items": { + "$ref": "#/definitions/VimIpAllocationPoolInfo" + } + }, + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "returnCode": { + "type": "integer", + "description": "0: Already exist 1: Newly created" + } + } + } + } +} diff --git a/vio/vio/swagger/multivim.tenant.swagger.json b/vio/vio/swagger/multivim.tenant.swagger.json new file mode 100644 index 0000000..062a0bd --- /dev/null +++ b/vio/vio/swagger/multivim.tenant.swagger.json @@ -0,0 +1,119 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "MultiVIM Service rest API" + }, + "basePath": "/openoapi/multivim/v1/", + "tags": [ + { + "name": "MultiVIM broker" + } + ], + "paths": { + "/{vimid}/tenants": { + "get": { + "tags": [ + "vim tenants" + ], + "summary": "query vim tenants list", + "description": "query vim tenants list", + "operationId": "query_vim_tenants", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "get a list of vim tenants request param", + "required": false, + "schema": { + "$ref": "#/definitions/ListVimTenants" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimTenantsInfo" + } + }, + "404": { + "description": "the vim id is wrong" + }, + "500": { + "description": "the vim tenants is not accessable" + } + } + } + } + }, + "definitions": { + "ListVimTenants": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "tenant name to filter tenant list" + } + } + }, + "VimTenantsInfo": { + "type": "object", + "required": [ + "vimId", + "tenants" + ], + "properties": { + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenants": { + "type": "array", + "description": "tenant list information", + "items": { + "$ref": "#/definitions/VimTenantInfo" + } + } + } + }, + "VimTenantInfo": { + "type": "object", + "required": [ + "name", + "id" + ], + "properties": { + "name": { + "type": "string", + "description": "tenant name" + }, + "id": { + "type": "string", + "description": "tenant UUID" + }, + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + } + } + } + } +} diff --git a/vio/vio/swagger/multivim.volume.swagger.json b/vio/vio/swagger/multivim.volume.swagger.json new file mode 100644 index 0000000..5b26d8c --- /dev/null +++ b/vio/vio/swagger/multivim.volume.swagger.json @@ -0,0 +1,379 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "MultiVIM Service rest API" + }, + "basePath": "/openoapi/multivim/v1/", + "tags": [ + { + "name": "MultiVIM broker" + } + ], + "paths": { + "/{vimid}/{tenantid}/volumes": { + "post": { + "tags": [ + "vim volumes" + ], + "summary": "create a volume", + "description": "create a volume", + "operationId": "create_vim_volume", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "create vim volume request param", + "required": true, + "schema": { + "$ref": "#/definitions/CreateVimVolume" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimVolumeInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim volume is not accessable" + } + } + }, + "get": { + "tags": [ + "vim volumes" + ], + "summary": "query vim volumes list", + "description": "query vim volumes list", + "operationId": "query_vim_volumes", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "get a list of vim volumes request param", + "required": false, + "schema": { + "$ref": "#/definitions/ListVimVolumes" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimVolumesInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim volume is not accessable" + } + } + } + }, + "/{vimid}/{tenantid}/volumes/{volumeid}": { + "delete": { + "tags": [ + "vim volumes" + ], + "summary": "delete specific vim volume", + "description": "delete specific vim volume", + "operationId": "delete_vim_volume", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "volumeid", + "in": "path", + "description": "vim volume id", + "required": true, + "type": "string" + } + ], + "responses": { + "204": { + "description": "successful operation" + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim volume is not accessable" + } + } + }, + "get": { + "tags": [ + "vim volumes" + ], + "summary": "query specific vim volume", + "description": "query specific vim volume", + "operationId": "query_vim_volume", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "volumeid", + "in": "path", + "description": "vim volume id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimVolumeInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim volume is not accessable" + } + } + } + } + }, + "definitions": { + "CreateVimVolume": { + "type": "object", + "required": [ + "name", + "volumeSize" + ], + "properties": { + "name": { + "type": "string", + "description": "volume name" + }, + "volumeSize": { + "type": "integer", + "description": "volume size" + }, + "imageName": { + "type": "string", + "description": "image name to create volume" + }, + "volumeType": { + "type": "string", + "description": "volume type" + }, + "availabilityZone": { + "type": "integer", + "description": "available zone for volume" + } + } + }, + "ListVimVolumes": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "volume name to filter volume list" + }, + "limit": { + "type": "integer", + "description": "Requests a page size of items" + }, + "marker": { + "type": "string", + "description": "volume ID of the last-seen item" + } + } + }, + "VimVolumesInfo": { + "type": "object", + "required": [ + "vimId", + "tenantId", + "volumes" + ], + "properties": { + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "volumes": { + "type": "array", + "description": "volume list information", + "items": { + "$ref": "#/definitions/VimVolumeInfo" + } + } + } + }, + "VimVolumeInfo": { + "type": "object", + "required": [ + "name", + "id", + "status" + ], + "properties": { + "name": { + "type": "string", + "description": "volume name" + }, + "id": { + "type": "string", + "description": "volume UUID" + }, + "createTime": { + "type": "string", + "description": "created time" + }, + "volumeSize": { + "type": "integer", + "description": "volume size" + }, + "volumeType": { + "type": "string", + "description": "volume type" + }, + "availabilityZone": { + "type": "integer", + "description": "available zone for volume" + }, + "attachments": { + "type": "array", + "description": "attachment list information", + "items": { + "$ref": "#/definitions/VimVolumeAttachmentInfo" + } + }, + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "returnCode": { + "type": "integer", + "description": "return code: 0: Already exist 1: Newly created" + } + } + }, + "VimVolumeAttachmentInfo": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "attachment UUID" + }, + "serverId": { + "type": "string", + "description": "server UUID" + }, + "volumeId": { + "type": "string", + "description": "volume UUID" + }, + "deviceId": { + "type": "string", + "description": "device UUID" + }, + "hostName": { + "type": "string", + "description": "host name" + } + } + } + } +} diff --git a/vio/vio/swagger/multivim.vport.swagger.json b/vio/vio/swagger/multivim.vport.swagger.json new file mode 100644 index 0000000..f722c26 --- /dev/null +++ b/vio/vio/swagger/multivim.vport.swagger.json @@ -0,0 +1,378 @@ +{ + "swagger": "2.0", + "info": { + "version": "1.0.0", + "title": "MultiVIM Service rest API" + }, + "basePath": "/openoapi/multivim/v1/", + "tags": [ + { + "name": "MultiVIM broker" + } + ], + "paths": { + "/{vimid}/{tenantid}/ports": { + "post": { + "tags": [ + "vim virtual ports" + ], + "summary": "create a virtual port", + "description": "create a virtual port", + "operationId": "create_vim_port", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "create vim virtual port request param", + "required": true, + "schema": { + "$ref": "#/definitions/CreateVimPort" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimPortInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim virtual port is not accessable" + } + } + }, + "get": { + "tags": [ + "vim virtual ports" + ], + "summary": "query vim ports list", + "description": "query vim ports list", + "operationId": "query_vim_ports", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "body", + "description": "get a list of vim virtual ports request param", + "required": false, + "schema": { + "$ref": "#/definitions/ListVimPorts" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimPortsInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim virtual port is not accessable" + } + } + } + }, + "/{vimid}/{tenantid}/ports/{portid}": { + "delete": { + "tags": [ + "vim virtual ports" + ], + "summary": "delete specific vim virtual port", + "description": "delete specific vim virtual port", + "operationId": "delete_vim_port", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "portid", + "in": "path", + "description": "vim virtual port id", + "required": true, + "type": "string" + } + ], + "responses": { + "204": { + "description": "successful operation" + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the virtual port is not accessable" + } + } + }, + "get": { + "tags": [ + "vim virtual ports" + ], + "summary": "query specific vim virtual port", + "description": "query specific vim virtual port", + "operationId": "query_vim_port", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "name": "vimid", + "in": "path", + "description": "vim instance id", + "required": true, + "type": "string" + }, + { + "name": "tenantid", + "in": "path", + "description": "tenant UUID", + "required": true, + "type": "string" + }, + { + "name": "portid", + "in": "path", + "description": "vim virtual port id", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/VimPortInfo" + } + }, + "404": { + "description": "the vim id or tenant UUID is wrong" + }, + "500": { + "description": "the vim virtual port id is not accessable" + } + } + } + } + }, + "definitions": { + "CreateVimPort": { + "type": "object", + "required": [ + "networkId", + "subnetId", + "name", + "cidr", + "ipVersion" + ], + "properties": { + "networkId": { + "type": "string", + "description": "network UUID" + }, + "subnetId": { + "type": "string", + "description": "subnet UUID" + }, + "name": { + "type": "string", + "description": "virtual port name" + }, + "ip": { + "type": "string", + "description": "virtual port fixed IP" + }, + "macAddress": { + "type": "string", + "description": "virtual port MAC address" + }, + "vnicType": { + "type": "string", + "description": "vnicType: normal,direct,macvtap" + }, + "securityGroups": { + "type": "array", + "description": "List of security group names", + "items": { + "type": "string" + } + } + } + }, + "ListVimPorts": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "virtual port name" + } + } + }, + "VimPortsInfo": { + "type": "object", + "required": [ + "vimId", + "tenantId", + "ports" + ], + "properties": { + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "ports": { + "type": "array", + "description": "ports information", + "items": { + "$ref": "#/definitions/VimPortInfo" + } + } + } + }, + "VimPortInfo": { + "type": "object", + "required": [ + "name", + "status", + "id", + "networkId", + "subnetId" + ], + "properties": { + "name": { + "type": "string", + "description": "virtual port name" + }, + "id": { + "type": "string", + "description": "virtual port UUID" + }, + "status": { + "type": "string", + "description": "subnet status" + }, + "networkId": { + "type": "string", + "description": "network UUID" + }, + "networkName": { + "type": "string", + "description": "network name" + }, + "subnetName": { + "type": "string", + "description": "subnet name" + }, + "subnetId": { + "type": "string", + "description": "subnet UUID" + }, + "ip": { + "type": "string", + "description": "virtual port fixed IP" + }, + "macAddress": { + "type": "string", + "description": "virtual port MAC address" + }, + "vnicType": { + "type": "string", + "description": "vnicType: normal,direct,macvtap" + }, + "securityGroups": { + "type": "array", + "description": "list of securityGroups names", + "items": { + "type": "string" + } + }, + "vimId": { + "type": "string" + }, + "vimName": { + "type": "string" + }, + "tenantId": { + "type": "string", + "description": "tenant UUID" + }, + "returnCode": { + "type": "integer", + "description": "0: Already exist 1: Newly created" + } + } + } + } +} diff --git a/vio/vio/swagger/tests.py b/vio/vio/swagger/tests.py new file mode 100644 index 0000000..e29efbd --- /dev/null +++ b/vio/vio/swagger/tests.py @@ -0,0 +1,30 @@ +# 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 unittest +import json +from django.test import Client +from rest_framework import status + + +class SampleViewTest(unittest.TestCase): + def setUp(self): + self.client = Client() + + def tearDown(self): + pass + + def test_sample(self): + response = self.client.get("/openoapi/multivim-vio/v1/swagger.json") + self.assertEqual(status.HTTP_200_OK, response.status_code, response.content) +# resp_data = json.loads(response.content) +# self.assertEqual({"status": "active"}, resp_data) diff --git a/vio/vio/swagger/urls.py b/vio/vio/swagger/urls.py new file mode 100644 index 0000000..824aea1 --- /dev/null +++ b/vio/vio/swagger/urls.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. + +from django.conf.urls import patterns, url +from rest_framework.urlpatterns import format_suffix_patterns + +from vio.swagger.views import SwaggerJsonView + +urlpatterns = [ + url(r'^openoapi/multivim-vio/v1/swagger.json$', SwaggerJsonView.as_view()), +] + +urlpatterns = format_suffix_patterns(urlpatterns) diff --git a/vio/vio/swagger/views.py b/vio/vio/swagger/views.py new file mode 100644 index 0000000..630d965 --- /dev/null +++ b/vio/vio/swagger/views.py @@ -0,0 +1,90 @@ +# 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 json +import logging +import os +import traceback + +from rest_framework import status +from rest_framework.response import Response +from rest_framework.views import APIView + +from vio.pub.exceptions import VimDriverVioException + +logger = logging.getLogger(__name__) + + +class SwaggerJsonView(APIView): + def get(self, request): + json_file = os.path.join(os.path.dirname(__file__), 'multivim.flavor.swagger.json') + f = open(json_file) + json_data = json.JSONDecoder().decode(f.read()) + f.close() + json_file = os.path.join(os.path.dirname(__file__), 'multivim.image.swagger.json') + f = open(json_file) + json_data_temp = json.JSONDecoder().decode(f.read()) + f.close() + json_data["paths"].update(json_data_temp["paths"]) + json_data["definitions"].update(json_data_temp["definitions"]) + json_file = os.path.join(os.path.dirname(__file__), 'multivim.network.swagger.json') + f = open(json_file) + json_data_temp = json.JSONDecoder().decode(f.read()) + f.close() + json_data["paths"].update(json_data_temp["paths"]) + json_data["definitions"].update(json_data_temp["definitions"]) + json_file = os.path.join(os.path.dirname(__file__), 'multivim.subnet.swagger.json') + f = open(json_file) + json_data_temp = json.JSONDecoder().decode(f.read()) + f.close() + json_data["paths"].update(json_data_temp["paths"]) + json_data["definitions"].update(json_data_temp["definitions"]) + json_file = os.path.join(os.path.dirname(__file__), 'multivim.server.swagger.json') + f = open(json_file) + json_data_temp = json.JSONDecoder().decode(f.read()) + f.close() + json_data["paths"].update(json_data_temp["paths"]) + json_data["definitions"].update(json_data_temp["definitions"]) + json_file = os.path.join(os.path.dirname(__file__), 'multivim.volume.swagger.json') + f = open(json_file) + json_data_temp = json.JSONDecoder().decode(f.read()) + f.close() + json_data["paths"].update(json_data_temp["paths"]) + json_data["definitions"].update(json_data_temp["definitions"]) + json_file = os.path.join(os.path.dirname(__file__), 'multivim.vport.swagger.json') + f = open(json_file) + json_data_temp = json.JSONDecoder().decode(f.read()) + f.close() + json_data["paths"].update(json_data_temp["paths"]) + json_data["definitions"].update(json_data_temp["definitions"]) + json_file = os.path.join(os.path.dirname(__file__), 'multivim.tenant.swagger.json') + f = open(json_file) + json_data_temp = json.JSONDecoder().decode(f.read()) + f.close() + json_data["paths"].update(json_data_temp["paths"]) + json_data["definitions"].update(json_data_temp["definitions"]) + json_file = os.path.join(os.path.dirname(__file__), 'multivim.host.swagger.json') + f = open(json_file) + json_data_temp = json.JSONDecoder().decode(f.read()) + f.close() + json_data["paths"].update(json_data_temp["paths"]) + json_data["definitions"].update(json_data_temp["definitions"]) + json_file = os.path.join(os.path.dirname(__file__), 'multivim.limit.swagger.json') + f = open(json_file) + json_data_temp = json.JSONDecoder().decode(f.read()) + f.close() + json_data["paths"].update(json_data_temp["paths"]) + json_data["definitions"].update(json_data_temp["definitions"]) + json_data["basePath"] = "/openoapi/multivim-vio/v1/" + json_data["info"]["title"] = "MultiVIM driver of OpenStack VIO Service NBI" + return Response(json_data) + diff --git a/vio/urls.py b/vio/vio/urls.py index 25acc75..bab793d 100644 --- a/vio/urls.py +++ b/vio/vio/urls.py @@ -1,23 +1,21 @@ -# Copyright 2016 ZTE Corporation. +# 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 +# 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 include, url from vio.pub.config.config import REG_TO_MSB_WHEN_START, REG_TO_MSB_REG_URL, REG_TO_MSB_REG_PARAM urlpatterns = [ + url(r'^', include('vio.swagger.urls')), url(r'^', include('vio.samples.urls')), - url(r'^', include('vio.pub.vim.urls')), ] # regist to MSB when startup diff --git a/vio/pub/vim/drivers/base.py b/vio/vio/wsgi.py index a1c68a6..eb516e7 100644 --- a/vio/pub/vim/drivers/base.py +++ b/vio/vio/wsgi.py @@ -3,20 +3,18 @@ # 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 - +import os -class DriverBase(object): - '''Base class for all drivers.''' +from django.core.wsgi import get_wsgi_application - def __init__(self, params): - self.conn_params = copy.deepcopy(params) +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "vio.settings") +application = get_wsgi_application() diff --git a/vio/wsgi.pyc b/vio/wsgi.pyc Binary files differdeleted file mode 100644 index 66412ed..0000000 --- a/vio/wsgi.pyc +++ /dev/null |