
2) Created demo quantum plugin that conforms to QuantumPluginBase Abstract class specification. 3) Demonstrated plugin registration and invocation using the demo plugin called "QuantumEchoPlugin" 4) Created the initial file structure for a quantum CLI 5) Seeded the utils module that will contain frequently used Quantum utilities. 6) Modified the manager module to initialize and register the quantum plugin defined in a configuration file. I have hard-coded the path to plugin for now but this will move to a quantum.conf file. TODO: 1) Finish up the Quantum CLI 2) Write Quantum unit tests that can be run against any plug-in for certification. 3) Create a working quantum plugin.
153 lines
4.4 KiB
Python
153 lines
4.4 KiB
Python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
# Copyright 2011 Nicira Networks, Inc.
|
|
# 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: Somik Behera, Nicira Networks, Inc.
|
|
|
|
"""
|
|
Quantum Plug-in API specification.
|
|
|
|
QuantumPluginBase provides the definition of minimum set of
|
|
methods that needs to be implemented by a Quantum Plug-in.
|
|
"""
|
|
|
|
from abc import ABCMeta, abstractmethod
|
|
|
|
class QuantumPluginBase(object):
|
|
|
|
__metaclass__ = ABCMeta
|
|
|
|
@abstractmethod
|
|
def get_all_networks(self, tenant_id):
|
|
"""
|
|
Returns a dictionary containing all
|
|
<network_uuid, network_name> for
|
|
the specified tenant.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def create_network(self, tenant_id, net_name):
|
|
"""
|
|
Creates a new Virtual Network, and assigns it
|
|
a symbolic name.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def delete_network(self, tenant_id, net_id):
|
|
"""
|
|
Deletes the network with the specified network identifier
|
|
belonging to the specified tenant.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_network_details(self, tenant_id, net_id):
|
|
"""
|
|
Deletes the Virtual Network belonging to a the
|
|
spec
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def rename_network(self, tenant_id, net_id, new_name):
|
|
"""
|
|
Updates the symbolic name belonging to a particular
|
|
Virtual Network.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_all_ports(self, tenant_id, net_id):
|
|
"""
|
|
Retrieves all port identifiers belonging to the
|
|
specified Virtual Network.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def create_port(self, tenant_id, net_id):
|
|
"""
|
|
Creates a port on the specified Virtual Network.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def delete_port(self, tenant_id, net_id, port_id):
|
|
"""
|
|
Deletes a port on a specified Virtual Network,
|
|
if the port contains a remote interface attachment,
|
|
the remote interface is first un-plugged and then the port
|
|
is deleted.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_port_details(self, tenant_id, net_id, port_id):
|
|
"""
|
|
This method allows the user to retrieve a remote interface
|
|
that is attached to this particular port.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def plug_interface(self, tenant_id, net_id, port_id, remote_interface_id):
|
|
"""
|
|
Attaches a remote interface to the specified port on the
|
|
specified Virtual Network.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def unplug_interface(self, tenant_id, net_id, port_id):
|
|
"""
|
|
Detaches a remote interface from the specified port on the
|
|
specified Virtual Network.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_interface_details(self, tenant_id, net_id, port_id):
|
|
"""
|
|
Retrieves the remote interface that is attached at this
|
|
particular port.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def get_all_attached_interfaces(self, tenant_id, net_id):
|
|
"""
|
|
Retrieves all remote interfaces that are attached to
|
|
a particular Virtual Network.
|
|
"""
|
|
pass
|
|
|
|
@classmethod
|
|
def __subclasshook__(cls, klass):
|
|
"""
|
|
The __subclasshook__ method is a class method
|
|
that will be called everytime a class is tested
|
|
using issubclass(klass, Plugin).
|
|
In that case, it will check that every method
|
|
marked with the abstractmethod decorator is
|
|
provided by the plugin class.
|
|
"""
|
|
if cls is QuantumPluginBase:
|
|
for method in cls.__abstractmethods__:
|
|
if any(method in base.__dict__ for base in klass.__mro__):
|
|
continue
|
|
return NotImplemented
|
|
return True
|
|
return NotImplemented |