Fixing pep8 errors
removing excess debug lines
This commit is contained in:
parent
dafac9726b
commit
15a625ba16
@ -54,8 +54,8 @@ class APIRouterV01(wsgi.Router):
|
|||||||
mapper.resource('port', 'ports',
|
mapper.resource('port', 'ports',
|
||||||
controller=ports.Controller(),
|
controller=ports.Controller(),
|
||||||
parent_resource=dict(member_name='network',
|
parent_resource=dict(member_name='network',
|
||||||
collection_name=\
|
collection_name=uri_prefix +\
|
||||||
uri_prefix + 'networks'))
|
'networks'))
|
||||||
|
|
||||||
mapper.connect("get_resource",
|
mapper.connect("get_resource",
|
||||||
uri_prefix + 'networks/{network_id}/' \
|
uri_prefix + 'networks/{network_id}/' \
|
||||||
|
@ -78,7 +78,7 @@ class Controller(common.QuantumController):
|
|||||||
except exc.HTTPError as e:
|
except exc.HTTPError as e:
|
||||||
return faults.Fault(e)
|
return faults.Fault(e)
|
||||||
network = self.network_manager.\
|
network = self.network_manager.\
|
||||||
create_network(tenant_id,req_params['network-name'])
|
create_network(tenant_id, req_params['network-name'])
|
||||||
builder = networks_view.get_view_builder(req)
|
builder = networks_view.get_view_builder(req)
|
||||||
result = builder.build(network)
|
result = builder.build(network)
|
||||||
return dict(networks=result)
|
return dict(networks=result)
|
||||||
|
@ -24,24 +24,25 @@ from quantum.common import exceptions as exception
|
|||||||
|
|
||||||
LOG = logging.getLogger('quantum.api.ports')
|
LOG = logging.getLogger('quantum.api.ports')
|
||||||
|
|
||||||
|
|
||||||
class Controller(common.QuantumController):
|
class Controller(common.QuantumController):
|
||||||
""" Port API controller for Quantum API """
|
""" Port API controller for Quantum API """
|
||||||
|
|
||||||
_port_ops_param_list = [{
|
_port_ops_param_list = [{
|
||||||
'param-name': 'port-state',
|
'param-name': 'port-state',
|
||||||
'default-value': 'DOWN',
|
'default-value': 'DOWN',
|
||||||
'required': False},]
|
'required': False},
|
||||||
|
]
|
||||||
|
|
||||||
_attachment_ops_param_list = [{
|
_attachment_ops_param_list = [{
|
||||||
'param-name': 'attachment-id',
|
'param-name': 'attachment-id',
|
||||||
'required': True},]
|
'required': True},
|
||||||
|
]
|
||||||
|
|
||||||
_serialization_metadata = {
|
_serialization_metadata = {
|
||||||
"application/xml": {
|
"application/xml": {
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"port": ["id","state"],
|
"port": ["id", "state"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -56,7 +57,7 @@ class Controller(common.QuantumController):
|
|||||||
|
|
||||||
def _items(self, req, tenant_id, network_id, is_detail):
|
def _items(self, req, tenant_id, network_id, is_detail):
|
||||||
""" Returns a list of networks. """
|
""" Returns a list of networks. """
|
||||||
try :
|
try:
|
||||||
ports = self.network_manager.get_all_ports(tenant_id, network_id)
|
ports = self.network_manager.get_all_ports(tenant_id, network_id)
|
||||||
builder = ports_view.get_view_builder(req)
|
builder = ports_view.get_view_builder(req)
|
||||||
result = [builder.build(port, is_detail)['port']
|
result = [builder.build(port, is_detail)['port']
|
||||||
@ -108,7 +109,7 @@ class Controller(common.QuantumController):
|
|||||||
except exc.HTTPError as e:
|
except exc.HTTPError as e:
|
||||||
return faults.Fault(e)
|
return faults.Fault(e)
|
||||||
try:
|
try:
|
||||||
port = self.network_manager.update_port(tenant_id,network_id, id,
|
port = self.network_manager.update_port(tenant_id, network_id, id,
|
||||||
req_params['port-state'])
|
req_params['port-state'])
|
||||||
builder = ports_view.get_view_builder(req)
|
builder = ports_view.get_view_builder(req)
|
||||||
result = builder.build(port, True)
|
result = builder.build(port, True)
|
||||||
@ -120,14 +121,13 @@ class Controller(common.QuantumController):
|
|||||||
except exception.StateInvalid as e:
|
except exception.StateInvalid as e:
|
||||||
return faults.Fault(faults.RequestedStateInvalid(e))
|
return faults.Fault(faults.RequestedStateInvalid(e))
|
||||||
|
|
||||||
|
|
||||||
def delete(self, req, tenant_id, network_id, id):
|
def delete(self, req, tenant_id, network_id, id):
|
||||||
""" Destroys the port with the given id """
|
""" Destroys the port with the given id """
|
||||||
#look for port state in request
|
#look for port state in request
|
||||||
try:
|
try:
|
||||||
self.network_manager.delete_port(tenant_id, network_id, id)
|
self.network_manager.delete_port(tenant_id, network_id, id)
|
||||||
return exc.HTTPAccepted()
|
return exc.HTTPAccepted()
|
||||||
#TODO(salvatore-orlando): Handle portInUse error
|
# TODO(salvatore-orlando): Handle portInUse error
|
||||||
except exception.NetworkNotFound as e:
|
except exception.NetworkNotFound as e:
|
||||||
return faults.Fault(faults.NetworkNotFound(e))
|
return faults.Fault(faults.NetworkNotFound(e))
|
||||||
except exception.PortNotFound as e:
|
except exception.PortNotFound as e:
|
||||||
@ -135,8 +135,7 @@ class Controller(common.QuantumController):
|
|||||||
except exception.PortInUse as e:
|
except exception.PortInUse as e:
|
||||||
return faults.Fault(faults.PortInUse(e))
|
return faults.Fault(faults.PortInUse(e))
|
||||||
|
|
||||||
|
def get_resource(self, req, tenant_id, network_id, id):
|
||||||
def get_resource(self,req,tenant_id, network_id, id):
|
|
||||||
try:
|
try:
|
||||||
result = self.network_manager.get_interface_details(
|
result = self.network_manager.get_interface_details(
|
||||||
tenant_id, network_id, id)
|
tenant_id, network_id, id)
|
||||||
@ -146,10 +145,7 @@ class Controller(common.QuantumController):
|
|||||||
except exception.PortNotFound as e:
|
except exception.PortNotFound as e:
|
||||||
return faults.Fault(faults.PortNotFound(e))
|
return faults.Fault(faults.PortNotFound(e))
|
||||||
|
|
||||||
#TODO - Complete implementation of these APIs
|
def attach_resource(self, req, tenant_id, network_id, id):
|
||||||
def attach_resource(self,req,tenant_id, network_id, id):
|
|
||||||
content_type = req.best_match_content_type()
|
|
||||||
print "Content type:%s" %content_type
|
|
||||||
try:
|
try:
|
||||||
req_params = \
|
req_params = \
|
||||||
self._parse_request_params(req,
|
self._parse_request_params(req,
|
||||||
@ -158,7 +154,7 @@ class Controller(common.QuantumController):
|
|||||||
return faults.Fault(e)
|
return faults.Fault(e)
|
||||||
try:
|
try:
|
||||||
self.network_manager.plug_interface(tenant_id,
|
self.network_manager.plug_interface(tenant_id,
|
||||||
network_id,id,
|
network_id, id,
|
||||||
req_params['attachment-id'])
|
req_params['attachment-id'])
|
||||||
return exc.HTTPAccepted()
|
return exc.HTTPAccepted()
|
||||||
except exception.NetworkNotFound as e:
|
except exception.NetworkNotFound as e:
|
||||||
@ -170,12 +166,10 @@ class Controller(common.QuantumController):
|
|||||||
except exception.AlreadyAttached as e:
|
except exception.AlreadyAttached as e:
|
||||||
return faults.Fault(faults.AlreadyAttached(e))
|
return faults.Fault(faults.AlreadyAttached(e))
|
||||||
|
|
||||||
|
def detach_resource(self, req, tenant_id, network_id, id):
|
||||||
#TODO - Complete implementation of these APIs
|
|
||||||
def detach_resource(self,req,tenant_id, network_id, id):
|
|
||||||
try:
|
try:
|
||||||
self.network_manager.unplug_interface(tenant_id,
|
self.network_manager.unplug_interface(tenant_id,
|
||||||
network_id,id)
|
network_id, id)
|
||||||
return exc.HTTPAccepted()
|
return exc.HTTPAccepted()
|
||||||
except exception.NetworkNotFound as e:
|
except exception.NetworkNotFound as e:
|
||||||
return faults.Fault(faults.NetworkNotFound(e))
|
return faults.Fault(faults.NetworkNotFound(e))
|
||||||
|
@ -13,4 +13,3 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
# @author: Somik Behera, Nicira Networks, Inc.
|
|
@ -33,7 +33,6 @@ class ViewBuilder(object):
|
|||||||
|
|
||||||
def build(self, network_data, is_detail=False):
|
def build(self, network_data, is_detail=False):
|
||||||
"""Generic method used to generate a network entity."""
|
"""Generic method used to generate a network entity."""
|
||||||
print "NETWORK-DATA:%s" %network_data
|
|
||||||
if is_detail:
|
if is_detail:
|
||||||
network = self._build_detail(network_data)
|
network = self._build_detail(network_data)
|
||||||
else:
|
else:
|
||||||
|
@ -31,7 +31,6 @@ class ViewBuilder(object):
|
|||||||
|
|
||||||
def build(self, port_data, is_detail=False):
|
def build(self, port_data, is_detail=False):
|
||||||
"""Generic method used to generate a port entity."""
|
"""Generic method used to generate a port entity."""
|
||||||
print "PORT-DATA:%s" %port_data
|
|
||||||
if is_detail:
|
if is_detail:
|
||||||
port = self._build_detail(port_data)
|
port = self._build_detail(port_data)
|
||||||
else:
|
else:
|
||||||
|
@ -107,4 +107,3 @@ elif sys.argv[1] == "all" and len(sys.argv) == 2:
|
|||||||
else:
|
else:
|
||||||
print "invalid arguments: %s" % str(sys.argv)
|
print "invalid arguments: %s" % str(sys.argv)
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ def find_config_file(options, args):
|
|||||||
fix_path(os.path.join('~', '.quantum')),
|
fix_path(os.path.join('~', '.quantum')),
|
||||||
fix_path('~'),
|
fix_path('~'),
|
||||||
os.path.join(FLAGS.state_path, 'etc'),
|
os.path.join(FLAGS.state_path, 'etc'),
|
||||||
os.path.join(FLAGS.state_path, 'etc','quantum'),
|
os.path.join(FLAGS.state_path, 'etc', 'quantum'),
|
||||||
'/etc/quantum/',
|
'/etc/quantum/',
|
||||||
'/etc']
|
'/etc']
|
||||||
for cfg_dir in config_file_dirs:
|
for cfg_dir in config_file_dirs:
|
||||||
@ -244,12 +244,10 @@ def load_paste_config(app_name, options, args):
|
|||||||
problem loading the configuration file.
|
problem loading the configuration file.
|
||||||
"""
|
"""
|
||||||
conf_file = find_config_file(options, args)
|
conf_file = find_config_file(options, args)
|
||||||
print "Conf_file:%s" %conf_file
|
|
||||||
if not conf_file:
|
if not conf_file:
|
||||||
raise RuntimeError("Unable to locate any configuration file. "
|
raise RuntimeError("Unable to locate any configuration file. "
|
||||||
"Cannot load application %s" % app_name)
|
"Cannot load application %s" % app_name)
|
||||||
try:
|
try:
|
||||||
print "App_name:%s" %app_name
|
|
||||||
conf = deploy.appconfig("config:%s" % conf_file, name=app_name)
|
conf = deploy.appconfig("config:%s" % conf_file, name=app_name)
|
||||||
return conf_file, conf
|
return conf_file, conf
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
@ -45,6 +45,7 @@ class QuantumException(Exception):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self._error_string
|
return self._error_string
|
||||||
|
|
||||||
|
|
||||||
class ProcessExecutionError(IOError):
|
class ProcessExecutionError(IOError):
|
||||||
def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
|
def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
|
||||||
description=None):
|
description=None):
|
||||||
@ -100,11 +101,13 @@ class PortInUse(QuantumException):
|
|||||||
"for network %(net_id)s. The attachment '%(att_id)s" \
|
"for network %(net_id)s. The attachment '%(att_id)s" \
|
||||||
"is plugged into the logical port.")
|
"is plugged into the logical port.")
|
||||||
|
|
||||||
|
|
||||||
class AlreadyAttached(QuantumException):
|
class AlreadyAttached(QuantumException):
|
||||||
message = _("Unable to plug the attachment %(att_id)s into port " \
|
message = _("Unable to plug the attachment %(att_id)s into port " \
|
||||||
"%(port_id)s for network %(net_id)s. The attachment is " \
|
"%(port_id)s for network %(net_id)s. The attachment is " \
|
||||||
"already plugged into port %(att_port_id)s")
|
"already plugged into port %(att_port_id)s")
|
||||||
|
|
||||||
|
|
||||||
class Duplicate(Error):
|
class Duplicate(Error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -249,4 +249,3 @@ def DECLARE(name, module_string, flag_values=FLAGS):
|
|||||||
|
|
||||||
DEFINE_string('state_path', os.path.join(os.path.dirname(__file__), '../../'),
|
DEFINE_string('state_path', os.path.join(os.path.dirname(__file__), '../../'),
|
||||||
"Top-level directory for maintaining quantum's state")
|
"Top-level directory for maintaining quantum's state")
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ from exceptions import ProcessExecutionError
|
|||||||
TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
|
TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
|
|
||||||
def int_from_bool_as_string(subject):
|
def int_from_bool_as_string(subject):
|
||||||
"""
|
"""
|
||||||
Interpret a string as a boolean and return either 1 or 0.
|
Interpret a string as a boolean and return either 1 or 0.
|
||||||
@ -188,6 +189,7 @@ def isotime(at=None):
|
|||||||
def parse_isotime(timestr):
|
def parse_isotime(timestr):
|
||||||
return datetime.datetime.strptime(timestr, TIME_FORMAT)
|
return datetime.datetime.strptime(timestr, TIME_FORMAT)
|
||||||
|
|
||||||
|
|
||||||
def getPluginFromConfig(file="config.ini"):
|
def getPluginFromConfig(file="config.ini"):
|
||||||
Config = ConfigParser.ConfigParser()
|
Config = ConfigParser.ConfigParser()
|
||||||
Config.read(os.path.join(FLAGS.state_path, file))
|
Config.read(os.path.join(FLAGS.state_path, file))
|
||||||
|
@ -40,6 +40,7 @@ from quantum.common import exceptions as exception
|
|||||||
|
|
||||||
LOG = logging.getLogger('quantum.common.wsgi')
|
LOG = logging.getLogger('quantum.common.wsgi')
|
||||||
|
|
||||||
|
|
||||||
class WritableLogger(object):
|
class WritableLogger(object):
|
||||||
"""A thin wrapper that responds to `write` and logs."""
|
"""A thin wrapper that responds to `write` and logs."""
|
||||||
|
|
||||||
@ -126,7 +127,7 @@ class Request(webob.Request):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
parts = self.path.rsplit('.', 1)
|
parts = self.path.rsplit('.', 1)
|
||||||
LOG.debug("Request parts:%s",parts)
|
LOG.debug("Request parts:%s", parts)
|
||||||
if len(parts) > 1:
|
if len(parts) > 1:
|
||||||
format = parts[1]
|
format = parts[1]
|
||||||
if format in ['json', 'xml']:
|
if format in ['json', 'xml']:
|
||||||
@ -134,7 +135,6 @@ class Request(webob.Request):
|
|||||||
|
|
||||||
ctypes = ['application/json', 'application/xml']
|
ctypes = ['application/json', 'application/xml']
|
||||||
bm = self.accept.best_match(ctypes)
|
bm = self.accept.best_match(ctypes)
|
||||||
LOG.debug("BM:%s",bm)
|
|
||||||
return bm or 'application/json'
|
return bm or 'application/json'
|
||||||
|
|
||||||
def get_content_type(self):
|
def get_content_type(self):
|
||||||
@ -336,10 +336,6 @@ class Controller(object):
|
|||||||
arg_dict = req.environ['wsgiorg.routing_args'][1]
|
arg_dict = req.environ['wsgiorg.routing_args'][1]
|
||||||
action = arg_dict['action']
|
action = arg_dict['action']
|
||||||
method = getattr(self, action)
|
method = getattr(self, action)
|
||||||
LOG.debug("ARG_DICT:%s",arg_dict)
|
|
||||||
LOG.debug("Action:%s",action)
|
|
||||||
LOG.debug("Method:%s",method)
|
|
||||||
LOG.debug("%s %s" % (req.method, req.url))
|
|
||||||
del arg_dict['controller']
|
del arg_dict['controller']
|
||||||
del arg_dict['action']
|
del arg_dict['action']
|
||||||
if 'format' in arg_dict:
|
if 'format' in arg_dict:
|
||||||
@ -349,8 +345,6 @@ class Controller(object):
|
|||||||
|
|
||||||
if type(result) is dict:
|
if type(result) is dict:
|
||||||
content_type = req.best_match_content_type()
|
content_type = req.best_match_content_type()
|
||||||
LOG.debug("Content type:%s",content_type)
|
|
||||||
LOG.debug("Result:%s",result)
|
|
||||||
default_xmlns = self.get_default_xmlns(req)
|
default_xmlns = self.get_default_xmlns(req)
|
||||||
body = self._serialize(result, content_type, default_xmlns)
|
body = self._serialize(result, content_type, default_xmlns)
|
||||||
|
|
||||||
@ -497,9 +491,7 @@ class Serializer(object):
|
|||||||
xmlns = metadata.get('xmlns', None)
|
xmlns = metadata.get('xmlns', None)
|
||||||
if xmlns:
|
if xmlns:
|
||||||
result.setAttribute('xmlns', xmlns)
|
result.setAttribute('xmlns', xmlns)
|
||||||
LOG.debug("DATA:%s",data)
|
|
||||||
if type(data) is list:
|
if type(data) is list:
|
||||||
LOG.debug("TYPE IS LIST")
|
|
||||||
collections = metadata.get('list_collections', {})
|
collections = metadata.get('list_collections', {})
|
||||||
if nodename in collections:
|
if nodename in collections:
|
||||||
metadata = collections[nodename]
|
metadata = collections[nodename]
|
||||||
@ -518,7 +510,6 @@ class Serializer(object):
|
|||||||
node = self._to_xml_node(doc, metadata, singular, item)
|
node = self._to_xml_node(doc, metadata, singular, item)
|
||||||
result.appendChild(node)
|
result.appendChild(node)
|
||||||
elif type(data) is dict:
|
elif type(data) is dict:
|
||||||
LOG.debug("TYPE IS DICT")
|
|
||||||
collections = metadata.get('dict_collections', {})
|
collections = metadata.get('dict_collections', {})
|
||||||
if nodename in collections:
|
if nodename in collections:
|
||||||
metadata = collections[nodename]
|
metadata = collections[nodename]
|
||||||
@ -538,8 +529,6 @@ class Serializer(object):
|
|||||||
result.appendChild(node)
|
result.appendChild(node)
|
||||||
else:
|
else:
|
||||||
# Type is atom
|
# Type is atom
|
||||||
LOG.debug("TYPE IS ATOM:%s",data)
|
|
||||||
node = doc.createTextNode(str(data))
|
node = doc.createTextNode(str(data))
|
||||||
result.appendChild(node)
|
result.appendChild(node)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Quantum's Manager class is responsible for parsing a config file and instantiating the correct
|
Quantum's Manager class is responsible for parsing a config file
|
||||||
plugin that concretely implement quantum_plugin_base class
|
and instantiating the correct plugin that concretely implement
|
||||||
|
quantum_plugin_base class
|
||||||
|
|
||||||
The caller should make sure that QuantumManager is a singleton.
|
The caller should make sure that QuantumManager is a singleton.
|
||||||
"""
|
"""
|
||||||
@ -34,7 +35,7 @@ CONFIG_FILE = "quantum/plugins.ini"
|
|||||||
|
|
||||||
class QuantumManager(object):
|
class QuantumManager(object):
|
||||||
|
|
||||||
def __init__(self,config=CONFIG_FILE):
|
def __init__(self, config=CONFIG_FILE):
|
||||||
self.configuration_file = CONFIG_FILE
|
self.configuration_file = CONFIG_FILE
|
||||||
plugin_location = utils.getPluginFromConfig(CONFIG_FILE)
|
plugin_location = utils.getPluginFromConfig(CONFIG_FILE)
|
||||||
print "PLUGIN LOCATION:%s" % plugin_location
|
print "PLUGIN LOCATION:%s" % plugin_location
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
from quantum.common import exceptions as exc
|
from quantum.common import exceptions as exc
|
||||||
|
|
||||||
|
|
||||||
class QuantumEchoPlugin(object):
|
class QuantumEchoPlugin(object):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -35,7 +36,6 @@ class QuantumEchoPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("get_all_networks() called\n")
|
print("get_all_networks() called\n")
|
||||||
|
|
||||||
|
|
||||||
def create_network(self, tenant_id, net_name):
|
def create_network(self, tenant_id, net_name):
|
||||||
"""
|
"""
|
||||||
Creates a new Virtual Network, and assigns it
|
Creates a new Virtual Network, and assigns it
|
||||||
@ -43,7 +43,6 @@ class QuantumEchoPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("create_network() called\n")
|
print("create_network() called\n")
|
||||||
|
|
||||||
|
|
||||||
def delete_network(self, tenant_id, net_id):
|
def delete_network(self, tenant_id, net_id):
|
||||||
"""
|
"""
|
||||||
Deletes the network with the specified network identifier
|
Deletes the network with the specified network identifier
|
||||||
@ -51,7 +50,6 @@ class QuantumEchoPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("delete_network() called\n")
|
print("delete_network() called\n")
|
||||||
|
|
||||||
|
|
||||||
def get_network_details(self, tenant_id, net_id):
|
def get_network_details(self, tenant_id, net_id):
|
||||||
"""
|
"""
|
||||||
Deletes the Virtual Network belonging to a the
|
Deletes the Virtual Network belonging to a the
|
||||||
@ -59,7 +57,6 @@ class QuantumEchoPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("get_network_details() called\n")
|
print("get_network_details() called\n")
|
||||||
|
|
||||||
|
|
||||||
def rename_network(self, tenant_id, net_id, new_name):
|
def rename_network(self, tenant_id, net_id, new_name):
|
||||||
"""
|
"""
|
||||||
Updates the symbolic name belonging to a particular
|
Updates the symbolic name belonging to a particular
|
||||||
@ -67,7 +64,6 @@ class QuantumEchoPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("rename_network() called\n")
|
print("rename_network() called\n")
|
||||||
|
|
||||||
|
|
||||||
def get_all_ports(self, tenant_id, net_id):
|
def get_all_ports(self, tenant_id, net_id):
|
||||||
"""
|
"""
|
||||||
Retrieves all port identifiers belonging to the
|
Retrieves all port identifiers belonging to the
|
||||||
@ -75,14 +71,12 @@ class QuantumEchoPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("get_all_ports() called\n")
|
print("get_all_ports() called\n")
|
||||||
|
|
||||||
|
|
||||||
def create_port(self, tenant_id, net_id):
|
def create_port(self, tenant_id, net_id):
|
||||||
"""
|
"""
|
||||||
Creates a port on the specified Virtual Network.
|
Creates a port on the specified Virtual Network.
|
||||||
"""
|
"""
|
||||||
print("create_port() called\n")
|
print("create_port() called\n")
|
||||||
|
|
||||||
|
|
||||||
def delete_port(self, tenant_id, net_id, port_id):
|
def delete_port(self, tenant_id, net_id, port_id):
|
||||||
"""
|
"""
|
||||||
Deletes a port on a specified Virtual Network,
|
Deletes a port on a specified Virtual Network,
|
||||||
@ -92,7 +86,6 @@ class QuantumEchoPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("delete_port() called\n")
|
print("delete_port() called\n")
|
||||||
|
|
||||||
|
|
||||||
def get_port_details(self, tenant_id, net_id, port_id):
|
def get_port_details(self, tenant_id, net_id, port_id):
|
||||||
"""
|
"""
|
||||||
This method allows the user to retrieve a remote interface
|
This method allows the user to retrieve a remote interface
|
||||||
@ -100,7 +93,6 @@ class QuantumEchoPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("get_port_details() called\n")
|
print("get_port_details() called\n")
|
||||||
|
|
||||||
|
|
||||||
def plug_interface(self, tenant_id, net_id, port_id, remote_interface_id):
|
def plug_interface(self, tenant_id, net_id, port_id, remote_interface_id):
|
||||||
"""
|
"""
|
||||||
Attaches a remote interface to the specified port on the
|
Attaches a remote interface to the specified port on the
|
||||||
@ -108,7 +100,6 @@ class QuantumEchoPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("plug_interface() called\n")
|
print("plug_interface() called\n")
|
||||||
|
|
||||||
|
|
||||||
def unplug_interface(self, tenant_id, net_id, port_id):
|
def unplug_interface(self, tenant_id, net_id, port_id):
|
||||||
"""
|
"""
|
||||||
Detaches a remote interface from the specified port on the
|
Detaches a remote interface from the specified port on the
|
||||||
@ -116,7 +107,6 @@ class QuantumEchoPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("unplug_interface() called\n")
|
print("unplug_interface() called\n")
|
||||||
|
|
||||||
|
|
||||||
def get_interface_details(self, tenant_id, net_id, port_id):
|
def get_interface_details(self, tenant_id, net_id, port_id):
|
||||||
"""
|
"""
|
||||||
Retrieves the remote interface that is attached at this
|
Retrieves the remote interface that is attached at this
|
||||||
@ -124,7 +114,6 @@ class QuantumEchoPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("get_interface_details() called\n")
|
print("get_interface_details() called\n")
|
||||||
|
|
||||||
|
|
||||||
def get_all_attached_interfaces(self, tenant_id, net_id):
|
def get_all_attached_interfaces(self, tenant_id, net_id):
|
||||||
"""
|
"""
|
||||||
Retrieves all remote interfaces that are attached to
|
Retrieves all remote interfaces that are attached to
|
||||||
@ -132,6 +121,7 @@ class QuantumEchoPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("get_all_attached_interfaces() called\n")
|
print("get_all_attached_interfaces() called\n")
|
||||||
|
|
||||||
|
|
||||||
class DummyDataPlugin(object):
|
class DummyDataPlugin(object):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -146,11 +136,10 @@ class DummyDataPlugin(object):
|
|||||||
<network_uuid, network_name> for
|
<network_uuid, network_name> for
|
||||||
the specified tenant.
|
the specified tenant.
|
||||||
"""
|
"""
|
||||||
nets = {"001": "lNet1", "002": "lNet2" , "003": "lNet3"}
|
nets = {"001": "lNet1", "002": "lNet2", "003": "lNet3"}
|
||||||
print("get_all_networks() called\n")
|
print("get_all_networks() called\n")
|
||||||
return nets
|
return nets
|
||||||
|
|
||||||
|
|
||||||
def create_network(self, tenant_id, net_name):
|
def create_network(self, tenant_id, net_name):
|
||||||
"""
|
"""
|
||||||
Creates a new Virtual Network, and assigns it
|
Creates a new Virtual Network, and assigns it
|
||||||
@ -160,7 +149,6 @@ class DummyDataPlugin(object):
|
|||||||
# return network_id of the created network
|
# return network_id of the created network
|
||||||
return 101
|
return 101
|
||||||
|
|
||||||
|
|
||||||
def delete_network(self, tenant_id, net_id):
|
def delete_network(self, tenant_id, net_id):
|
||||||
"""
|
"""
|
||||||
Deletes the network with the specified network identifier
|
Deletes the network with the specified network identifier
|
||||||
@ -168,17 +156,16 @@ class DummyDataPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("delete_network() called\n")
|
print("delete_network() called\n")
|
||||||
|
|
||||||
|
|
||||||
def get_network_details(self, tenant_id, net_id):
|
def get_network_details(self, tenant_id, net_id):
|
||||||
"""
|
"""
|
||||||
retrieved a list of all the remote vifs that
|
retrieved a list of all the remote vifs that
|
||||||
are attached to the network
|
are attached to the network
|
||||||
"""
|
"""
|
||||||
print("get_network_details() called\n")
|
print("get_network_details() called\n")
|
||||||
vifs_on_net = ["/tenant1/networks/net_id/portid/vif2.0", "/tenant1/networks/10/121/vif1.1"]
|
vifs_on_net = ["/tenant1/networks/net_id/portid/vif2.0",
|
||||||
|
"/tenant1/networks/10/121/vif1.1"]
|
||||||
return vifs_on_net
|
return vifs_on_net
|
||||||
|
|
||||||
|
|
||||||
def rename_network(self, tenant_id, net_id, new_name):
|
def rename_network(self, tenant_id, net_id, new_name):
|
||||||
"""
|
"""
|
||||||
Updates the symbolic name belonging to a particular
|
Updates the symbolic name belonging to a particular
|
||||||
@ -186,7 +173,6 @@ class DummyDataPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("rename_network() called\n")
|
print("rename_network() called\n")
|
||||||
|
|
||||||
|
|
||||||
def get_all_ports(self, tenant_id, net_id):
|
def get_all_ports(self, tenant_id, net_id):
|
||||||
"""
|
"""
|
||||||
Retrieves all port identifiers belonging to the
|
Retrieves all port identifiers belonging to the
|
||||||
@ -196,7 +182,6 @@ class DummyDataPlugin(object):
|
|||||||
port_ids_on_net = ["2", "3", "4"]
|
port_ids_on_net = ["2", "3", "4"]
|
||||||
return port_ids_on_net
|
return port_ids_on_net
|
||||||
|
|
||||||
|
|
||||||
def create_port(self, tenant_id, net_id):
|
def create_port(self, tenant_id, net_id):
|
||||||
"""
|
"""
|
||||||
Creates a port on the specified Virtual Network.
|
Creates a port on the specified Virtual Network.
|
||||||
@ -205,7 +190,6 @@ class DummyDataPlugin(object):
|
|||||||
#return the port id
|
#return the port id
|
||||||
return 201
|
return 201
|
||||||
|
|
||||||
|
|
||||||
def delete_port(self, tenant_id, net_id, port_id):
|
def delete_port(self, tenant_id, net_id, port_id):
|
||||||
"""
|
"""
|
||||||
Deletes a port on a specified Virtual Network,
|
Deletes a port on a specified Virtual Network,
|
||||||
@ -215,7 +199,6 @@ class DummyDataPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("delete_port() called\n")
|
print("delete_port() called\n")
|
||||||
|
|
||||||
|
|
||||||
def get_port_details(self, tenant_id, net_id, port_id):
|
def get_port_details(self, tenant_id, net_id, port_id):
|
||||||
"""
|
"""
|
||||||
This method allows the user to retrieve a remote interface
|
This method allows the user to retrieve a remote interface
|
||||||
@ -225,7 +208,6 @@ class DummyDataPlugin(object):
|
|||||||
#returns the remote interface UUID
|
#returns the remote interface UUID
|
||||||
return "/tenant1/networks/net_id/portid/vif2.1"
|
return "/tenant1/networks/net_id/portid/vif2.1"
|
||||||
|
|
||||||
|
|
||||||
def plug_interface(self, tenant_id, net_id, port_id, remote_interface_id):
|
def plug_interface(self, tenant_id, net_id, port_id, remote_interface_id):
|
||||||
"""
|
"""
|
||||||
Attaches a remote interface to the specified port on the
|
Attaches a remote interface to the specified port on the
|
||||||
@ -233,7 +215,6 @@ class DummyDataPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("plug_interface() called\n")
|
print("plug_interface() called\n")
|
||||||
|
|
||||||
|
|
||||||
def unplug_interface(self, tenant_id, net_id, port_id):
|
def unplug_interface(self, tenant_id, net_id, port_id):
|
||||||
"""
|
"""
|
||||||
Detaches a remote interface from the specified port on the
|
Detaches a remote interface from the specified port on the
|
||||||
@ -241,7 +222,6 @@ class DummyDataPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("unplug_interface() called\n")
|
print("unplug_interface() called\n")
|
||||||
|
|
||||||
|
|
||||||
def get_interface_details(self, tenant_id, net_id, port_id):
|
def get_interface_details(self, tenant_id, net_id, port_id):
|
||||||
"""
|
"""
|
||||||
Retrieves the remote interface that is attached at this
|
Retrieves the remote interface that is attached at this
|
||||||
@ -251,7 +231,6 @@ class DummyDataPlugin(object):
|
|||||||
#returns the remote interface UUID
|
#returns the remote interface UUID
|
||||||
return "/tenant1/networks/net_id/portid/vif2.0"
|
return "/tenant1/networks/net_id/portid/vif2.0"
|
||||||
|
|
||||||
|
|
||||||
def get_all_attached_interfaces(self, tenant_id, net_id):
|
def get_all_attached_interfaces(self, tenant_id, net_id):
|
||||||
"""
|
"""
|
||||||
Retrieves all remote interfaces that are attached to
|
Retrieves all remote interfaces that are attached to
|
||||||
@ -259,7 +238,8 @@ class DummyDataPlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("get_all_attached_interfaces() called\n")
|
print("get_all_attached_interfaces() called\n")
|
||||||
# returns a list of all attached remote interfaces
|
# returns a list of all attached remote interfaces
|
||||||
vifs_on_net = ["/tenant1/networks/net_id/portid/vif2.0", "/tenant1/networks/10/121/vif1.1"]
|
vifs_on_net = ["/tenant1/networks/net_id/portid/vif2.0",
|
||||||
|
"/tenant1/networks/10/121/vif1.1"]
|
||||||
return vifs_on_net
|
return vifs_on_net
|
||||||
|
|
||||||
|
|
||||||
@ -272,37 +252,36 @@ class FakePlugin(object):
|
|||||||
|
|
||||||
#static data for networks and ports
|
#static data for networks and ports
|
||||||
_port_dict_1 = {
|
_port_dict_1 = {
|
||||||
1 : {'port-id': 1,
|
1: {'port-id': 1,
|
||||||
'port-state': 'DOWN',
|
'port-state': 'DOWN',
|
||||||
'attachment': None},
|
'attachment': None},
|
||||||
2 : {'port-id': 2,
|
2: {'port-id': 2,
|
||||||
'port-state':'UP',
|
'port-state': 'UP',
|
||||||
'attachment': None}
|
'attachment': None}
|
||||||
}
|
}
|
||||||
_port_dict_2 = {
|
_port_dict_2 = {
|
||||||
1 : {'port-id': 1,
|
1: {'port-id': 1,
|
||||||
'port-state': 'UP',
|
'port-state': 'UP',
|
||||||
'attachment': 'SomeFormOfVIFID'},
|
'attachment': 'SomeFormOfVIFID'},
|
||||||
2 : {'port-id': 2,
|
2: {'port-id': 2,
|
||||||
'port-state':'DOWN',
|
'port-state': 'DOWN',
|
||||||
'attachment': None}
|
'attachment': None}
|
||||||
}
|
}
|
||||||
_networks={'001':
|
_networks = {'001':
|
||||||
{
|
{
|
||||||
'net-id':'001',
|
'net-id': '001',
|
||||||
'net-name':'pippotest',
|
'net-name': 'pippotest',
|
||||||
'net-ports': _port_dict_1
|
'net-ports': _port_dict_1
|
||||||
},
|
},
|
||||||
'002':
|
'002':
|
||||||
{
|
{
|
||||||
'net-id':'002',
|
'net-id': '002',
|
||||||
'net-name':'cicciotest',
|
'net-name': 'cicciotest',
|
||||||
'net-ports': _port_dict_2
|
'net-ports': _port_dict_2
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
FakePlugin._net_counter=len(FakePlugin._networks)
|
FakePlugin._net_counter = len(FakePlugin._networks)
|
||||||
|
|
||||||
def _get_network(self, tenant_id, network_id):
|
def _get_network(self, tenant_id, network_id):
|
||||||
network = FakePlugin._networks.get(network_id)
|
network = FakePlugin._networks.get(network_id)
|
||||||
@ -310,7 +289,6 @@ class FakePlugin(object):
|
|||||||
raise exc.NetworkNotFound(net_id=network_id)
|
raise exc.NetworkNotFound(net_id=network_id)
|
||||||
return network
|
return network
|
||||||
|
|
||||||
|
|
||||||
def _get_port(self, tenant_id, network_id, port_id):
|
def _get_port(self, tenant_id, network_id, port_id):
|
||||||
net = self._get_network(tenant_id, network_id)
|
net = self._get_network(tenant_id, network_id)
|
||||||
port = net['net-ports'].get(int(port_id))
|
port = net['net-ports'].get(int(port_id))
|
||||||
@ -319,7 +297,7 @@ class FakePlugin(object):
|
|||||||
return port
|
return port
|
||||||
|
|
||||||
def _validate_port_state(self, port_state):
|
def _validate_port_state(self, port_state):
|
||||||
if port_state.upper() not in ('UP','DOWN'):
|
if port_state.upper() not in ('UP', 'DOWN'):
|
||||||
raise exc.StateInvalid(port_state=port_state)
|
raise exc.StateInvalid(port_state=port_state)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -328,10 +306,10 @@ class FakePlugin(object):
|
|||||||
network = self._get_network(tenant_id, network_id)
|
network = self._get_network(tenant_id, network_id)
|
||||||
for port in network['net-ports'].values():
|
for port in network['net-ports'].values():
|
||||||
if port['attachment'] == remote_interface_id:
|
if port['attachment'] == remote_interface_id:
|
||||||
raise exc.AlreadyAttached(net_id = network_id,
|
raise exc.AlreadyAttached(net_id=network_id,
|
||||||
port_id = port_id,
|
port_id=port_id,
|
||||||
att_id = port['attachment'],
|
att_id=port['attachment'],
|
||||||
att_port_id = port['port-id'])
|
att_port_id=port['port-id'])
|
||||||
|
|
||||||
def get_all_networks(self, tenant_id):
|
def get_all_networks(self, tenant_id):
|
||||||
"""
|
"""
|
||||||
@ -357,13 +335,13 @@ class FakePlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("create_network() called\n")
|
print("create_network() called\n")
|
||||||
FakePlugin._net_counter += 1
|
FakePlugin._net_counter += 1
|
||||||
new_net_id=("0" * (3 - len(str(FakePlugin._net_counter)))) + \
|
new_net_id = ("0" * (3 - len(str(FakePlugin._net_counter)))) + \
|
||||||
str(FakePlugin._net_counter)
|
str(FakePlugin._net_counter)
|
||||||
print new_net_id
|
print new_net_id
|
||||||
new_net_dict={'net-id':new_net_id,
|
new_net_dict = {'net-id': new_net_id,
|
||||||
'net-name':net_name,
|
'net-name': net_name,
|
||||||
'net-ports': {}}
|
'net-ports': {}}
|
||||||
FakePlugin._networks[new_net_id]=new_net_dict
|
FakePlugin._networks[new_net_id] = new_net_dict
|
||||||
# return network_id of the created network
|
# return network_id of the created network
|
||||||
return new_net_dict
|
return new_net_dict
|
||||||
|
|
||||||
@ -392,7 +370,7 @@ class FakePlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("rename_network() called\n")
|
print("rename_network() called\n")
|
||||||
net = self._get_network(tenant_id, net_id)
|
net = self._get_network(tenant_id, net_id)
|
||||||
net['net-name']=new_name
|
net['net-name'] = new_name
|
||||||
return net
|
return net
|
||||||
|
|
||||||
def get_all_ports(self, tenant_id, net_id):
|
def get_all_ports(self, tenant_id, net_id):
|
||||||
@ -423,8 +401,8 @@ class FakePlugin(object):
|
|||||||
# TODO(salvatore-orlando): Validate port state in API?
|
# TODO(salvatore-orlando): Validate port state in API?
|
||||||
self._validate_port_state(port_state)
|
self._validate_port_state(port_state)
|
||||||
ports = net['net-ports']
|
ports = net['net-ports']
|
||||||
new_port_id = max(ports.keys())+1
|
new_port_id = max(ports.keys()) + 1
|
||||||
new_port_dict = {'port-id':new_port_id,
|
new_port_dict = {'port-id': new_port_id,
|
||||||
'port-state': port_state,
|
'port-state': port_state,
|
||||||
'attachment': None}
|
'attachment': None}
|
||||||
ports[new_port_id] = new_port_dict
|
ports[new_port_id] = new_port_dict
|
||||||
@ -451,7 +429,7 @@ class FakePlugin(object):
|
|||||||
net = self._get_network(tenant_id, net_id)
|
net = self._get_network(tenant_id, net_id)
|
||||||
port = self._get_port(tenant_id, net_id, port_id)
|
port = self._get_port(tenant_id, net_id, port_id)
|
||||||
if port['attachment']:
|
if port['attachment']:
|
||||||
raise exc.PortInUse(net_id=net_id,port_id=port_id,
|
raise exc.PortInUse(net_id=net_id, port_id=port_id,
|
||||||
att_id=port['attachment'])
|
att_id=port['attachment'])
|
||||||
try:
|
try:
|
||||||
net['net-ports'].pop(int(port_id))
|
net['net-ports'].pop(int(port_id))
|
||||||
@ -478,7 +456,7 @@ class FakePlugin(object):
|
|||||||
remote_interface_id)
|
remote_interface_id)
|
||||||
port = self._get_port(tenant_id, net_id, port_id)
|
port = self._get_port(tenant_id, net_id, port_id)
|
||||||
if port['attachment']:
|
if port['attachment']:
|
||||||
raise exc.PortInUse(net_id=net_id,port_id=port_id,
|
raise exc.PortInUse(net_id=net_id, port_id=port_id,
|
||||||
att_id=port['attachment'])
|
att_id=port['attachment'])
|
||||||
port['attachment'] = remote_interface_id
|
port['attachment'] = remote_interface_id
|
||||||
|
|
||||||
@ -493,7 +471,7 @@ class FakePlugin(object):
|
|||||||
# Should unplug on port without attachment raise an Error?
|
# Should unplug on port without attachment raise an Error?
|
||||||
port['attachment'] = None
|
port['attachment'] = None
|
||||||
|
|
||||||
#TODO - neeed to update methods from this point onwards
|
# TODO - neeed to update methods from this point onwards
|
||||||
def get_all_attached_interfaces(self, tenant_id, net_id):
|
def get_all_attached_interfaces(self, tenant_id, net_id):
|
||||||
"""
|
"""
|
||||||
Retrieves all remote interfaces that are attached to
|
Retrieves all remote interfaces that are attached to
|
||||||
@ -501,6 +479,6 @@ class FakePlugin(object):
|
|||||||
"""
|
"""
|
||||||
print("get_all_attached_interfaces() called\n")
|
print("get_all_attached_interfaces() called\n")
|
||||||
# returns a list of all attached remote interfaces
|
# returns a list of all attached remote interfaces
|
||||||
vifs_on_net = ["/tenant1/networks/net_id/portid/vif2.0", "/tenant1/networks/10/121/vif1.1"]
|
vifs_on_net = ["/tenant1/networks/net_id/portid/vif2.0",
|
||||||
|
"/tenant1/networks/10/121/vif1.1"]
|
||||||
return vifs_on_net
|
return vifs_on_net
|
||||||
|
|
@ -88,7 +88,7 @@ class QuantumApiService(WsgiService):
|
|||||||
return service
|
return service
|
||||||
|
|
||||||
|
|
||||||
def serve_wsgi(cls, conf=None, options = None, args=None):
|
def serve_wsgi(cls, conf=None, options=None, args=None):
|
||||||
try:
|
try:
|
||||||
service = cls.create(conf, options, args)
|
service = cls.create(conf, options, args)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user