device_driver: base class and noop driver
Change-Id: Id8239d36acc74ca2da001ae56b6bf188c4b175a9
This commit is contained in:
parent
f8faccb842
commit
5c955aaf89
|
@ -0,0 +1,73 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013, 2014 Intel Corporation.
|
||||
# Copyright 2013, 2014 Isaku Yamahata <isaku.yamahata at intel com>
|
||||
# <isaku.yamahata at gmail com>
|
||||
# All Rights Reserved.
|
||||
#
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# @author: Isaku Yamahata, Intel Corporation.
|
||||
# TODO(yamahata): once unittests are impletemted, move this there
|
||||
import uuid
|
||||
|
||||
from tacker.openstack.common import log as logging
|
||||
from tacker.vm.drivers import abstract_driver
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DeviceNoop(abstract_driver.DeviceAbstractDriver):
|
||||
|
||||
"""Noop driver of hosting device for tests."""
|
||||
|
||||
def __init__(self):
|
||||
super(DeviceNoop, self).__init__()
|
||||
self._instances = set()
|
||||
|
||||
def get_type(self):
|
||||
return 'noop'
|
||||
|
||||
def get_name(self):
|
||||
return 'noop'
|
||||
|
||||
def get_description(self):
|
||||
return 'Nuetron Device Noop driver'
|
||||
|
||||
def create(self, **kwargs):
|
||||
LOG.debug(_('create %s'), kwargs)
|
||||
instance_id = str(uuid.uuid4())
|
||||
self._instances.add(instance_id)
|
||||
return instance_id
|
||||
|
||||
def create_wait(self, plugin, context, device_id):
|
||||
LOG.debug(_('create_wait %s'), device_id)
|
||||
|
||||
def update(self, plugin, context, device_id, **kwargs):
|
||||
LOG.debug(_('update device_id %(devcie_id)s kwargs %(kwargs)s'),
|
||||
{'device_id': device_id, 'kwargs': kwargs})
|
||||
if device_id not in self._instances:
|
||||
LOG.debug(_('not found'))
|
||||
raise ValueError('No instance %s' % device_id)
|
||||
|
||||
def update_wait(self, plugin, context, device_id):
|
||||
LOG.debug(_('update_wait %s'), device_id)
|
||||
|
||||
def delete(self, plugin, context, device_id):
|
||||
LOG.debug(_('delete %s'), device_id)
|
||||
self._instances.remove(device_id)
|
||||
|
||||
def delete_wait(self, plugin, context, device_id):
|
||||
LOG.debug(_('delete_wait %s'), device_id)
|
|
@ -0,0 +1,69 @@
|
|||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013, 2014 Intel Corporation.
|
||||
# Copyright 2013, 2014 Isaku Yamahata <isaku.yamahata at intel com>
|
||||
# <isaku.yamahata at gmail com>
|
||||
# All Rights Reserved.
|
||||
#
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# @author: Isaku Yamahata, Intel Corporation.
|
||||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
from tacker.api import extensions
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class DeviceAbstractDriver(extensions.PluginInterface):
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_type(self):
|
||||
"""Return one of predefined type of the hosting device drivers."""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_name(self):
|
||||
"""Return a symbolic name for the service VM plugin."""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_description(self):
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def create(self, plugin, context, device):
|
||||
"""Create device and return its id."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def create_wait(self, plugin, context, device_id):
|
||||
"""wait for device creation to complete."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def update(self, plugin, context, device):
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def update_wait(self, plugin, context, device_id):
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def delete(self, plugin, context, device_id):
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def delete_wait(self, plugin, context, device_id):
|
||||
pass
|
Loading…
Reference in New Issue