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',
|
||||
controller=ports.Controller(),
|
||||
parent_resource=dict(member_name='network',
|
||||
collection_name=\
|
||||
uri_prefix + 'networks'))
|
||||
collection_name=uri_prefix +\
|
||||
'networks'))
|
||||
|
||||
mapper.connect("get_resource",
|
||||
uri_prefix + 'networks/{network_id}/' \
|
||||
|
@ -24,19 +24,20 @@ from quantum.common import exceptions as exception
|
||||
|
||||
LOG = logging.getLogger('quantum.api.ports')
|
||||
|
||||
|
||||
class Controller(common.QuantumController):
|
||||
""" Port API controller for Quantum API """
|
||||
|
||||
_port_ops_param_list = [{
|
||||
'param-name': 'port-state',
|
||||
'default-value': 'DOWN',
|
||||
'required': False},]
|
||||
|
||||
'required': False},
|
||||
]
|
||||
|
||||
_attachment_ops_param_list = [{
|
||||
'param-name': 'attachment-id',
|
||||
'required': True},]
|
||||
|
||||
'required': True},
|
||||
]
|
||||
|
||||
_serialization_metadata = {
|
||||
"application/xml": {
|
||||
@ -120,7 +121,6 @@ class Controller(common.QuantumController):
|
||||
except exception.StateInvalid as e:
|
||||
return faults.Fault(faults.RequestedStateInvalid(e))
|
||||
|
||||
|
||||
def delete(self, req, tenant_id, network_id, id):
|
||||
""" Destroys the port with the given id """
|
||||
#look for port state in request
|
||||
@ -135,7 +135,6 @@ class Controller(common.QuantumController):
|
||||
except exception.PortInUse as e:
|
||||
return faults.Fault(faults.PortInUse(e))
|
||||
|
||||
|
||||
def get_resource(self, req, tenant_id, network_id, id):
|
||||
try:
|
||||
result = self.network_manager.get_interface_details(
|
||||
@ -146,10 +145,7 @@ class Controller(common.QuantumController):
|
||||
except exception.PortNotFound as e:
|
||||
return faults.Fault(faults.PortNotFound(e))
|
||||
|
||||
#TODO - Complete implementation of these APIs
|
||||
def attach_resource(self, req, tenant_id, network_id, id):
|
||||
content_type = req.best_match_content_type()
|
||||
print "Content type:%s" %content_type
|
||||
try:
|
||||
req_params = \
|
||||
self._parse_request_params(req,
|
||||
@ -170,8 +166,6 @@ class Controller(common.QuantumController):
|
||||
except exception.AlreadyAttached as e:
|
||||
return faults.Fault(faults.AlreadyAttached(e))
|
||||
|
||||
|
||||
#TODO - Complete implementation of these APIs
|
||||
def detach_resource(self, req, tenant_id, network_id, id):
|
||||
try:
|
||||
self.network_manager.unplug_interface(tenant_id,
|
||||
|
@ -13,4 +13,3 @@
|
||||
# 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.
|
@ -33,7 +33,6 @@ class ViewBuilder(object):
|
||||
|
||||
def build(self, network_data, is_detail=False):
|
||||
"""Generic method used to generate a network entity."""
|
||||
print "NETWORK-DATA:%s" %network_data
|
||||
if is_detail:
|
||||
network = self._build_detail(network_data)
|
||||
else:
|
||||
|
@ -31,7 +31,6 @@ class ViewBuilder(object):
|
||||
|
||||
def build(self, port_data, is_detail=False):
|
||||
"""Generic method used to generate a port entity."""
|
||||
print "PORT-DATA:%s" %port_data
|
||||
if is_detail:
|
||||
port = self._build_detail(port_data)
|
||||
else:
|
||||
|
@ -107,4 +107,3 @@ elif sys.argv[1] == "all" and len(sys.argv) == 2:
|
||||
else:
|
||||
print "invalid arguments: %s" % str(sys.argv)
|
||||
usage()
|
||||
|
||||
|
@ -244,12 +244,10 @@ def load_paste_config(app_name, options, args):
|
||||
problem loading the configuration file.
|
||||
"""
|
||||
conf_file = find_config_file(options, args)
|
||||
print "Conf_file:%s" %conf_file
|
||||
if not conf_file:
|
||||
raise RuntimeError("Unable to locate any configuration file. "
|
||||
"Cannot load application %s" % app_name)
|
||||
try:
|
||||
print "App_name:%s" %app_name
|
||||
conf = deploy.appconfig("config:%s" % conf_file, name=app_name)
|
||||
return conf_file, conf
|
||||
except Exception, e:
|
||||
|
@ -45,6 +45,7 @@ class QuantumException(Exception):
|
||||
def __str__(self):
|
||||
return self._error_string
|
||||
|
||||
|
||||
class ProcessExecutionError(IOError):
|
||||
def __init__(self, stdout=None, stderr=None, exit_code=None, cmd=None,
|
||||
description=None):
|
||||
@ -100,11 +101,13 @@ class PortInUse(QuantumException):
|
||||
"for network %(net_id)s. The attachment '%(att_id)s" \
|
||||
"is plugged into the logical port.")
|
||||
|
||||
|
||||
class AlreadyAttached(QuantumException):
|
||||
message = _("Unable to plug the attachment %(att_id)s into port " \
|
||||
"%(port_id)s for network %(net_id)s. The attachment is " \
|
||||
"already plugged into port %(att_port_id)s")
|
||||
|
||||
|
||||
class Duplicate(Error):
|
||||
pass
|
||||
|
||||
|
@ -249,4 +249,3 @@ def DECLARE(name, module_string, flag_values=FLAGS):
|
||||
|
||||
DEFINE_string('state_path', os.path.join(os.path.dirname(__file__), '../../'),
|
||||
"Top-level directory for maintaining quantum's state")
|
||||
|
||||
|
@ -37,6 +37,7 @@ from exceptions import ProcessExecutionError
|
||||
TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
|
||||
def int_from_bool_as_string(subject):
|
||||
"""
|
||||
Interpret a string as a boolean and return either 1 or 0.
|
||||
@ -188,6 +189,7 @@ def isotime(at=None):
|
||||
def parse_isotime(timestr):
|
||||
return datetime.datetime.strptime(timestr, TIME_FORMAT)
|
||||
|
||||
|
||||
def getPluginFromConfig(file="config.ini"):
|
||||
Config = ConfigParser.ConfigParser()
|
||||
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')
|
||||
|
||||
|
||||
class WritableLogger(object):
|
||||
"""A thin wrapper that responds to `write` and logs."""
|
||||
|
||||
@ -134,7 +135,6 @@ class Request(webob.Request):
|
||||
|
||||
ctypes = ['application/json', 'application/xml']
|
||||
bm = self.accept.best_match(ctypes)
|
||||
LOG.debug("BM:%s",bm)
|
||||
return bm or 'application/json'
|
||||
|
||||
def get_content_type(self):
|
||||
@ -336,10 +336,6 @@ class Controller(object):
|
||||
arg_dict = req.environ['wsgiorg.routing_args'][1]
|
||||
action = arg_dict['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['action']
|
||||
if 'format' in arg_dict:
|
||||
@ -349,8 +345,6 @@ class Controller(object):
|
||||
|
||||
if type(result) is dict:
|
||||
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)
|
||||
body = self._serialize(result, content_type, default_xmlns)
|
||||
|
||||
@ -497,9 +491,7 @@ class Serializer(object):
|
||||
xmlns = metadata.get('xmlns', None)
|
||||
if xmlns:
|
||||
result.setAttribute('xmlns', xmlns)
|
||||
LOG.debug("DATA:%s",data)
|
||||
if type(data) is list:
|
||||
LOG.debug("TYPE IS LIST")
|
||||
collections = metadata.get('list_collections', {})
|
||||
if nodename in collections:
|
||||
metadata = collections[nodename]
|
||||
@ -518,7 +510,6 @@ class Serializer(object):
|
||||
node = self._to_xml_node(doc, metadata, singular, item)
|
||||
result.appendChild(node)
|
||||
elif type(data) is dict:
|
||||
LOG.debug("TYPE IS DICT")
|
||||
collections = metadata.get('dict_collections', {})
|
||||
if nodename in collections:
|
||||
metadata = collections[nodename]
|
||||
@ -538,8 +529,6 @@ class Serializer(object):
|
||||
result.appendChild(node)
|
||||
else:
|
||||
# Type is atom
|
||||
LOG.debug("TYPE IS ATOM:%s",data)
|
||||
node = doc.createTextNode(str(data))
|
||||
result.appendChild(node)
|
||||
return result
|
||||
|
||||
|
@ -18,8 +18,9 @@
|
||||
|
||||
|
||||
"""
|
||||
Quantum's Manager class is responsible for parsing a config file and instantiating the correct
|
||||
plugin that concretely implement quantum_plugin_base class
|
||||
Quantum's Manager class is responsible for parsing a config file
|
||||
and instantiating the correct plugin that concretely implement
|
||||
quantum_plugin_base class
|
||||
|
||||
The caller should make sure that QuantumManager is a singleton.
|
||||
"""
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
from quantum.common import exceptions as exc
|
||||
|
||||
|
||||
class QuantumEchoPlugin(object):
|
||||
|
||||
"""
|
||||
@ -35,7 +36,6 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("get_all_networks() called\n")
|
||||
|
||||
|
||||
def create_network(self, tenant_id, net_name):
|
||||
"""
|
||||
Creates a new Virtual Network, and assigns it
|
||||
@ -43,7 +43,6 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("create_network() called\n")
|
||||
|
||||
|
||||
def delete_network(self, tenant_id, net_id):
|
||||
"""
|
||||
Deletes the network with the specified network identifier
|
||||
@ -51,7 +50,6 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("delete_network() called\n")
|
||||
|
||||
|
||||
def get_network_details(self, tenant_id, net_id):
|
||||
"""
|
||||
Deletes the Virtual Network belonging to a the
|
||||
@ -59,7 +57,6 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("get_network_details() called\n")
|
||||
|
||||
|
||||
def rename_network(self, tenant_id, net_id, new_name):
|
||||
"""
|
||||
Updates the symbolic name belonging to a particular
|
||||
@ -67,7 +64,6 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("rename_network() called\n")
|
||||
|
||||
|
||||
def get_all_ports(self, tenant_id, net_id):
|
||||
"""
|
||||
Retrieves all port identifiers belonging to the
|
||||
@ -75,14 +71,12 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("get_all_ports() called\n")
|
||||
|
||||
|
||||
def create_port(self, tenant_id, net_id):
|
||||
"""
|
||||
Creates a port on the specified Virtual Network.
|
||||
"""
|
||||
print("create_port() called\n")
|
||||
|
||||
|
||||
def delete_port(self, tenant_id, net_id, port_id):
|
||||
"""
|
||||
Deletes a port on a specified Virtual Network,
|
||||
@ -92,7 +86,6 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("delete_port() called\n")
|
||||
|
||||
|
||||
def get_port_details(self, tenant_id, net_id, port_id):
|
||||
"""
|
||||
This method allows the user to retrieve a remote interface
|
||||
@ -100,7 +93,6 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("get_port_details() called\n")
|
||||
|
||||
|
||||
def plug_interface(self, tenant_id, net_id, port_id, remote_interface_id):
|
||||
"""
|
||||
Attaches a remote interface to the specified port on the
|
||||
@ -108,7 +100,6 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("plug_interface() called\n")
|
||||
|
||||
|
||||
def unplug_interface(self, tenant_id, net_id, port_id):
|
||||
"""
|
||||
Detaches a remote interface from the specified port on the
|
||||
@ -116,7 +107,6 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("unplug_interface() called\n")
|
||||
|
||||
|
||||
def get_interface_details(self, tenant_id, net_id, port_id):
|
||||
"""
|
||||
Retrieves the remote interface that is attached at this
|
||||
@ -124,7 +114,6 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("get_interface_details() called\n")
|
||||
|
||||
|
||||
def get_all_attached_interfaces(self, tenant_id, net_id):
|
||||
"""
|
||||
Retrieves all remote interfaces that are attached to
|
||||
@ -132,6 +121,7 @@ class QuantumEchoPlugin(object):
|
||||
"""
|
||||
print("get_all_attached_interfaces() called\n")
|
||||
|
||||
|
||||
class DummyDataPlugin(object):
|
||||
|
||||
"""
|
||||
@ -150,7 +140,6 @@ class DummyDataPlugin(object):
|
||||
print("get_all_networks() called\n")
|
||||
return nets
|
||||
|
||||
|
||||
def create_network(self, tenant_id, net_name):
|
||||
"""
|
||||
Creates a new Virtual Network, and assigns it
|
||||
@ -160,7 +149,6 @@ class DummyDataPlugin(object):
|
||||
# return network_id of the created network
|
||||
return 101
|
||||
|
||||
|
||||
def delete_network(self, tenant_id, net_id):
|
||||
"""
|
||||
Deletes the network with the specified network identifier
|
||||
@ -168,17 +156,16 @@ class DummyDataPlugin(object):
|
||||
"""
|
||||
print("delete_network() called\n")
|
||||
|
||||
|
||||
def get_network_details(self, tenant_id, net_id):
|
||||
"""
|
||||
retrieved a list of all the remote vifs that
|
||||
are attached to the network
|
||||
"""
|
||||
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
|
||||
|
||||
|
||||
def rename_network(self, tenant_id, net_id, new_name):
|
||||
"""
|
||||
Updates the symbolic name belonging to a particular
|
||||
@ -186,7 +173,6 @@ class DummyDataPlugin(object):
|
||||
"""
|
||||
print("rename_network() called\n")
|
||||
|
||||
|
||||
def get_all_ports(self, tenant_id, net_id):
|
||||
"""
|
||||
Retrieves all port identifiers belonging to the
|
||||
@ -196,7 +182,6 @@ class DummyDataPlugin(object):
|
||||
port_ids_on_net = ["2", "3", "4"]
|
||||
return port_ids_on_net
|
||||
|
||||
|
||||
def create_port(self, tenant_id, net_id):
|
||||
"""
|
||||
Creates a port on the specified Virtual Network.
|
||||
@ -205,7 +190,6 @@ class DummyDataPlugin(object):
|
||||
#return the port id
|
||||
return 201
|
||||
|
||||
|
||||
def delete_port(self, tenant_id, net_id, port_id):
|
||||
"""
|
||||
Deletes a port on a specified Virtual Network,
|
||||
@ -215,7 +199,6 @@ class DummyDataPlugin(object):
|
||||
"""
|
||||
print("delete_port() called\n")
|
||||
|
||||
|
||||
def get_port_details(self, tenant_id, net_id, port_id):
|
||||
"""
|
||||
This method allows the user to retrieve a remote interface
|
||||
@ -225,7 +208,6 @@ class DummyDataPlugin(object):
|
||||
#returns the remote interface UUID
|
||||
return "/tenant1/networks/net_id/portid/vif2.1"
|
||||
|
||||
|
||||
def plug_interface(self, tenant_id, net_id, port_id, remote_interface_id):
|
||||
"""
|
||||
Attaches a remote interface to the specified port on the
|
||||
@ -233,7 +215,6 @@ class DummyDataPlugin(object):
|
||||
"""
|
||||
print("plug_interface() called\n")
|
||||
|
||||
|
||||
def unplug_interface(self, tenant_id, net_id, port_id):
|
||||
"""
|
||||
Detaches a remote interface from the specified port on the
|
||||
@ -241,7 +222,6 @@ class DummyDataPlugin(object):
|
||||
"""
|
||||
print("unplug_interface() called\n")
|
||||
|
||||
|
||||
def get_interface_details(self, tenant_id, net_id, port_id):
|
||||
"""
|
||||
Retrieves the remote interface that is attached at this
|
||||
@ -251,7 +231,6 @@ class DummyDataPlugin(object):
|
||||
#returns the remote interface UUID
|
||||
return "/tenant1/networks/net_id/portid/vif2.0"
|
||||
|
||||
|
||||
def get_all_attached_interfaces(self, tenant_id, net_id):
|
||||
"""
|
||||
Retrieves all remote interfaces that are attached to
|
||||
@ -259,7 +238,8 @@ class DummyDataPlugin(object):
|
||||
"""
|
||||
print("get_all_attached_interfaces() called\n")
|
||||
# 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
|
||||
|
||||
|
||||
@ -300,7 +280,6 @@ class FakePlugin(object):
|
||||
'net-ports': _port_dict_2
|
||||
}}
|
||||
|
||||
|
||||
def __init__(self):
|
||||
FakePlugin._net_counter = len(FakePlugin._networks)
|
||||
|
||||
@ -310,7 +289,6 @@ class FakePlugin(object):
|
||||
raise exc.NetworkNotFound(net_id=network_id)
|
||||
return network
|
||||
|
||||
|
||||
def _get_port(self, tenant_id, network_id, port_id):
|
||||
net = self._get_network(tenant_id, network_id)
|
||||
port = net['net-ports'].get(int(port_id))
|
||||
@ -501,6 +479,6 @@ class FakePlugin(object):
|
||||
"""
|
||||
print("get_all_attached_interfaces() called\n")
|
||||
# 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user