summaryrefslogtreecommitdiffstats
path: root/vio/pub/vim/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'vio/pub/vim/drivers')
-rw-r--r--vio/pub/vim/drivers/__init__.py0
-rw-r--r--vio/pub/vim/drivers/__init__.pycbin131 -> 0 bytes
-rw-r--r--vio/pub/vim/drivers/base.py22
-rw-r--r--vio/pub/vim/drivers/base.pycbin611 -> 0 bytes
-rw-r--r--vio/pub/vim/drivers/openstacksdk/__init__.py16
-rw-r--r--vio/pub/vim/drivers/openstacksdk/__init__.pycbin265 -> 0 bytes
-rw-r--r--vio/pub/vim/drivers/openstacksdk/keystone_v3.py39
-rw-r--r--vio/pub/vim/drivers/openstacksdk/keystone_v3.pycbin1501 -> 0 bytes
-rw-r--r--vio/pub/vim/drivers/openstacksdk/sdk.py124
-rw-r--r--vio/pub/vim/drivers/openstacksdk/sdk.pycbin3086 -> 0 bytes
-rw-r--r--vio/pub/vim/drivers/vimdriver.py25
-rw-r--r--vio/pub/vim/drivers/vimdriver.pycbin689 -> 0 bytes
12 files changed, 0 insertions, 226 deletions
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
deleted file mode 100644
index c62f8eb..0000000
--- a/vio/pub/vim/drivers/__init__.pyc
+++ /dev/null
Binary files differ
diff --git a/vio/pub/vim/drivers/base.py b/vio/pub/vim/drivers/base.py
deleted file mode 100644
index a1c68a6..0000000
--- a/vio/pub/vim/drivers/base.py
+++ /dev/null
@@ -1,22 +0,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.
-
-import copy
-
-
-
-class DriverBase(object):
- '''Base class for all drivers.'''
-
- def __init__(self, params):
- self.conn_params = copy.deepcopy(params)
-
diff --git a/vio/pub/vim/drivers/base.pyc b/vio/pub/vim/drivers/base.pyc
deleted file mode 100644
index b8ba13c..0000000
--- a/vio/pub/vim/drivers/base.pyc
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index d0030da..0000000
--- a/vio/pub/vim/drivers/openstacksdk/__init__.pyc
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index 4b279fb..0000000
--- a/vio/pub/vim/drivers/openstacksdk/keystone_v3.pyc
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index 3daec03..0000000
--- a/vio/pub/vim/drivers/openstacksdk/sdk.pyc
+++ /dev/null
Binary files differ
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
deleted file mode 100644
index 69ecf31..0000000
--- a/vio/pub/vim/drivers/vimdriver.pyc
+++ /dev/null
Binary files differ