feedback from jk0's review, including removing a lot of spaces from docstrings
This commit is contained in:
@@ -779,8 +779,7 @@ class NetworkCommands(object):
|
||||
|
||||
def list(self):
|
||||
"""List all created networks"""
|
||||
_fmt = "%-5s\t%-18s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s"\
|
||||
"\t%-15s\t%-15s"
|
||||
_fmt = "%-5s\t%-18s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s"
|
||||
print _fmt % (_('id'),
|
||||
_('IPv4'),
|
||||
_('IPv6'),
|
||||
|
||||
@@ -946,7 +946,7 @@ def virtual_interface_get_by_address(context, address):
|
||||
def virtual_interface_get_by_uuid(context, vif_uuid):
|
||||
"""Gets a virtual interface from the table.
|
||||
|
||||
:param vif_uuid: = the uuid of the interface you're looking to get
|
||||
:param vif_uuid: the uuid of the interface you're looking to get
|
||||
"""
|
||||
session = get_session()
|
||||
vif_ref = session.query(models.VirtualInterface).\
|
||||
|
||||
@@ -547,7 +547,7 @@ class NetworkManager(manager.SchedulerDependentManager):
|
||||
'network_id': network_id,
|
||||
'uuid': str(utils.gen_uuid())}
|
||||
# try FLAG times to create a vif record with a unique mac_address
|
||||
for i in xrange(FLAGS.create_unique_mac_address_attempts):
|
||||
for _ in xrange(FLAGS.create_unique_mac_address_attempts):
|
||||
try:
|
||||
return self.db.virtual_interface_create(context, vif)
|
||||
except exception.VirtualInterfaceCreateException:
|
||||
|
||||
@@ -22,14 +22,14 @@ import socket
|
||||
import urllib
|
||||
|
||||
|
||||
#FIXME(danwent): All content in this file should be removed once the
|
||||
# FIXME(danwent): All content in this file should be removed once the
|
||||
# packaging work for the quantum client libraries is complete.
|
||||
# At that point, we will be able to just install the libraries as a
|
||||
# dependency and import from quantum.client.* and quantum.common.*
|
||||
# Until then, we have simplified versions of these classes in this file.
|
||||
|
||||
class JSONSerializer(object):
|
||||
""" This is a simple json-only serializer to use until we can just grab
|
||||
"""This is a simple json-only serializer to use until we can just grab
|
||||
the standard serializer from the quantum library.
|
||||
"""
|
||||
def serialize(self, data, content_type):
|
||||
@@ -47,17 +47,17 @@ class JSONSerializer(object):
|
||||
# granular exceptions, for now, just try to distinguish
|
||||
# between the cases we care about.
|
||||
class QuantumNotFoundException(Exception):
|
||||
""" Indicates that Quantum Server returned 404"""
|
||||
"""Indicates that Quantum Server returned 404"""
|
||||
pass
|
||||
|
||||
|
||||
class QuantumServerException(Exception):
|
||||
""" Indicates any non-404 error from Quantum Server"""
|
||||
"""Indicates any non-404 error from Quantum Server"""
|
||||
pass
|
||||
|
||||
|
||||
class QuantumIOException(Exception):
|
||||
""" Indicates network IO trouble reaching Quantum Server"""
|
||||
"""Indicates network IO trouble reaching Quantum Server"""
|
||||
pass
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ class Client(object):
|
||||
def __init__(self, host="127.0.0.1", port=9696, use_ssl=False, tenant=None,
|
||||
format="xml", testing_stub=None, key_file=None,
|
||||
cert_file=None, logger=None):
|
||||
""" Creates a new client to some service.
|
||||
"""Creates a new client to some service.
|
||||
|
||||
:param host: The host where service resides
|
||||
:param port: The port where service resides
|
||||
@@ -123,7 +123,7 @@ class Client(object):
|
||||
self.logger = logger
|
||||
|
||||
def get_connection_type(self):
|
||||
""" Returns the proper connection type """
|
||||
"""Returns the proper connection type"""
|
||||
if self.testing_stub:
|
||||
return self.testing_stub
|
||||
elif self.use_ssl:
|
||||
@@ -133,7 +133,7 @@ class Client(object):
|
||||
|
||||
def do_request(self, method, action, body=None,
|
||||
headers=None, params=None):
|
||||
""" Connects to the server and issues a request.
|
||||
"""Connects to the server and issues a request.
|
||||
Returns the result data, or raises an appropriate exception if
|
||||
HTTP status code is not 2xx
|
||||
|
||||
@@ -142,7 +142,6 @@ class Client(object):
|
||||
:param headers: mapping of key/value pairs to add as headers
|
||||
:param params: dictionary of key/value pairs to add to append
|
||||
to action
|
||||
|
||||
"""
|
||||
|
||||
# Ensure we have a tenant id
|
||||
@@ -207,7 +206,7 @@ class Client(object):
|
||||
"server. Got error: %s" % e))
|
||||
|
||||
def get_status_code(self, response):
|
||||
""" Returns the integer status code from the response, which
|
||||
"""Returns the integer status code from the response, which
|
||||
can be either a Webob.Response (used in testing) or httplib.Response
|
||||
"""
|
||||
if hasattr(response, 'status_int'):
|
||||
@@ -236,73 +235,73 @@ class Client(object):
|
||||
|
||||
@api_call
|
||||
def list_networks(self):
|
||||
""" Fetches a list of all networks for a tenant """
|
||||
"""Fetches a list of all networks for a tenant"""
|
||||
return self.do_request("GET", self.networks_path)
|
||||
|
||||
@api_call
|
||||
def show_network_details(self, network):
|
||||
""" Fetches the details of a certain network """
|
||||
"""Fetches the details of a certain network"""
|
||||
return self.do_request("GET", self.network_path % (network))
|
||||
|
||||
@api_call
|
||||
def create_network(self, body=None):
|
||||
""" Creates a new network """
|
||||
"""Creates a new network"""
|
||||
body = self.serialize(body)
|
||||
return self.do_request("POST", self.networks_path, body=body)
|
||||
|
||||
@api_call
|
||||
def update_network(self, network, body=None):
|
||||
""" Updates a network """
|
||||
"""Updates a network"""
|
||||
body = self.serialize(body)
|
||||
return self.do_request("PUT", self.network_path % (network), body=body)
|
||||
|
||||
@api_call
|
||||
def delete_network(self, network):
|
||||
""" Deletes the specified network """
|
||||
"""Deletes the specified network"""
|
||||
return self.do_request("DELETE", self.network_path % (network))
|
||||
|
||||
@api_call
|
||||
def list_ports(self, network):
|
||||
""" Fetches a list of ports on a given network """
|
||||
"""Fetches a list of ports on a given network"""
|
||||
return self.do_request("GET", self.ports_path % (network))
|
||||
|
||||
@api_call
|
||||
def show_port_details(self, network, port):
|
||||
""" Fetches the details of a certain port """
|
||||
"""Fetches the details of a certain port"""
|
||||
return self.do_request("GET", self.port_path % (network, port))
|
||||
|
||||
@api_call
|
||||
def create_port(self, network, body=None):
|
||||
""" Creates a new port on a given network """
|
||||
"""Creates a new port on a given network"""
|
||||
body = self.serialize(body)
|
||||
return self.do_request("POST", self.ports_path % (network), body=body)
|
||||
|
||||
@api_call
|
||||
def delete_port(self, network, port):
|
||||
""" Deletes the specified port from a network """
|
||||
"""Deletes the specified port from a network"""
|
||||
return self.do_request("DELETE", self.port_path % (network, port))
|
||||
|
||||
@api_call
|
||||
def set_port_state(self, network, port, body=None):
|
||||
""" Sets the state of the specified port """
|
||||
"""Sets the state of the specified port"""
|
||||
body = self.serialize(body)
|
||||
return self.do_request("PUT",
|
||||
self.port_path % (network, port), body=body)
|
||||
|
||||
@api_call
|
||||
def show_port_attachment(self, network, port):
|
||||
""" Fetches the attachment-id associated with the specified port """
|
||||
"""Fetches the attachment-id associated with the specified port"""
|
||||
return self.do_request("GET", self.attachment_path % (network, port))
|
||||
|
||||
@api_call
|
||||
def attach_resource(self, network, port, body=None):
|
||||
""" Sets the attachment-id of the specified port """
|
||||
"""Sets the attachment-id of the specified port"""
|
||||
body = self.serialize(body)
|
||||
return self.do_request("PUT",
|
||||
self.attachment_path % (network, port), body=body)
|
||||
|
||||
@api_call
|
||||
def detach_resource(self, network, port):
|
||||
""" Removes the attachment-id of the specified port """
|
||||
"""Removes the attachment-id of the specified port"""
|
||||
return self.do_request("DELETE",
|
||||
self.attachment_path % (network, port))
|
||||
|
||||
@@ -24,7 +24,7 @@ from nova.network import manager
|
||||
from nova.network.quantum import quantum_connection
|
||||
from nova import utils
|
||||
|
||||
LOG = logging.getLogger("quantum_manager")
|
||||
LOG = logging.getLogger("nova.network.quantum.manager")
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
@@ -34,7 +34,7 @@ flags.DEFINE_string('quantum_ipam_lib',
|
||||
|
||||
|
||||
class QuantumManager(manager.FlatManager):
|
||||
""" NetworkManager class that communicates with a Quantum service
|
||||
"""NetworkManager class that communicates with a Quantum service
|
||||
via a web services API to provision VM network connectivity.
|
||||
|
||||
For IP Address management, QuantumManager can be configured to
|
||||
@@ -50,7 +50,7 @@ class QuantumManager(manager.FlatManager):
|
||||
"""
|
||||
|
||||
def __init__(self, q_conn=None, ipam_lib=None, *args, **kwargs):
|
||||
""" Initialize two key libraries, the connection to a
|
||||
"""Initialize two key libraries, the connection to a
|
||||
Quantum service, and the library for implementing IPAM.
|
||||
|
||||
Calls inherited FlatManager constructor.
|
||||
@@ -70,7 +70,7 @@ class QuantumManager(manager.FlatManager):
|
||||
network_size, cidr_v6, gateway_v6, bridge,
|
||||
bridge_interface, dns1=None, dns2=None, uuid=None,
|
||||
**kwargs):
|
||||
""" Unlike other NetworkManagers, with QuantumManager, each
|
||||
"""Unlike other NetworkManagers, with QuantumManager, each
|
||||
create_networks calls should create only a single network.
|
||||
|
||||
Two scenarios exist:
|
||||
@@ -101,7 +101,7 @@ class QuantumManager(manager.FlatManager):
|
||||
priority, cidr, gateway_v6, cidr_v6, dns1, dns2)
|
||||
|
||||
def delete_network(self, context, fixed_range):
|
||||
""" Lookup network by IPv4 cidr, delete both the IPAM
|
||||
"""Lookup network by IPv4 cidr, delete both the IPAM
|
||||
subnet and the corresponding Quantum network.
|
||||
"""
|
||||
project_id = context.project_id
|
||||
@@ -113,7 +113,7 @@ class QuantumManager(manager.FlatManager):
|
||||
self.q_conn.delete_network(q_tenant_id, quantum_net_id)
|
||||
|
||||
def allocate_for_instance(self, context, **kwargs):
|
||||
""" Called by compute when it is creating a new VM.
|
||||
"""Called by compute when it is creating a new VM.
|
||||
|
||||
There are three key tasks:
|
||||
- Determine the number and order of vNICs to create
|
||||
@@ -181,7 +181,7 @@ class QuantumManager(manager.FlatManager):
|
||||
|
||||
def get_instance_nw_info(self, context, instance_id,
|
||||
instance_type_id, host):
|
||||
""" This method is used by compute to fetch all network data
|
||||
"""This method is used by compute to fetch all network data
|
||||
that should be used when creating the VM.
|
||||
|
||||
The method simply loops through all virtual interfaces
|
||||
@@ -269,7 +269,7 @@ class QuantumManager(manager.FlatManager):
|
||||
return network_info
|
||||
|
||||
def deallocate_for_instance(self, context, **kwargs):
|
||||
""" Called when a VM is terminated. Loop through each virtual
|
||||
"""Called when a VM is terminated. Loop through each virtual
|
||||
interface in the Nova DB and remove the Quantum port and
|
||||
clear the IP allocation using the IPAM. Finally, remove
|
||||
the virtual interfaces from the Nova DB.
|
||||
@@ -309,7 +309,7 @@ class QuantumManager(manager.FlatManager):
|
||||
(instance_id)))
|
||||
|
||||
def validate_networks(self, context, networks):
|
||||
""" Validates that this tenant has quantum networks with the associated
|
||||
"""Validates that this tenant has quantum networks with the associated
|
||||
UUIDs. This is called by the 'os-create-server-ext' API extension
|
||||
code so that we can return an API error code to the caller if they
|
||||
request an invalid network.
|
||||
|
||||
@@ -35,7 +35,7 @@ flags.DEFINE_string('melange_port',
|
||||
|
||||
json_content_type = {'Content-type': "application/json"}
|
||||
|
||||
#FIXME(danwent): talk to the Melange folks about creating a
|
||||
# FIXME(danwent): talk to the Melange folks about creating a
|
||||
# client lib that we can import as a library, instead of
|
||||
# have to have all of the client code in here.
|
||||
class MelangeConnection(object):
|
||||
|
||||
@@ -24,7 +24,7 @@ from nova import log as logging
|
||||
from nova.network.quantum import melange_connection
|
||||
|
||||
|
||||
LOG = logging.getLogger("quantum_melange_ipam")
|
||||
LOG = logging.getLogger("nova.network.quantum.melange_ipam_lib")
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
@@ -34,20 +34,20 @@ def get_ipam_lib(net_man):
|
||||
|
||||
|
||||
class QuantumMelangeIPAMLib(object):
|
||||
""" Implements Quantum IP Address Management (IPAM) interface
|
||||
"""Implements Quantum IP Address Management (IPAM) interface
|
||||
using the Melange service, which is access using the Melange
|
||||
web services API.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
""" Initialize class used to connect to Melange server"""
|
||||
"""Initialize class used to connect to Melange server"""
|
||||
self.m_conn = melange_connection.MelangeConnection()
|
||||
|
||||
def create_subnet(self, context, label, project_id,
|
||||
quantum_net_id, priority, cidr=None,
|
||||
gateway_v6=None, cidr_v6=None,
|
||||
dns1=None, dns2=None):
|
||||
""" Contact Melange and create a subnet for any non-NULL
|
||||
"""Contact Melange and create a subnet for any non-NULL
|
||||
IPv4 or IPv6 subnets.
|
||||
|
||||
Also create a entry in the Nova networks DB, but only
|
||||
@@ -73,14 +73,14 @@ class QuantumMelangeIPAMLib(object):
|
||||
network = db.network_create_safe(admin_context, net)
|
||||
|
||||
def allocate_fixed_ip(self, context, project_id, quantum_net_id, vif_ref):
|
||||
""" Pass call to allocate fixed IP on to Melange"""
|
||||
"""Pass call to allocate fixed IP on to Melange"""
|
||||
tenant_id = project_id or FLAGS.quantum_default_tenant_id
|
||||
self.m_conn.allocate_ip(quantum_net_id,
|
||||
vif_ref['uuid'], project_id=tenant_id,
|
||||
mac_address=vif_ref['address'])
|
||||
|
||||
def get_network_id_by_cidr(self, context, cidr, project_id):
|
||||
""" Find the Quantum UUID associated with a IPv4 CIDR
|
||||
"""Find the Quantum UUID associated with a IPv4 CIDR
|
||||
address for the specified tenant.
|
||||
"""
|
||||
tenant_id = project_id or FLAGS.quantum_default_tenant_id
|
||||
@@ -91,7 +91,7 @@ class QuantumMelangeIPAMLib(object):
|
||||
raise exception.NotFound(_("No network found for cidr %s" % cidr))
|
||||
|
||||
def delete_subnets_by_net_id(self, context, net_id, project_id):
|
||||
""" Find Melange block associated with the Quantum UUID,
|
||||
"""Find Melange block associated with the Quantum UUID,
|
||||
then tell Melange to delete that block.
|
||||
"""
|
||||
admin_context = context.elevated()
|
||||
@@ -105,9 +105,10 @@ class QuantumMelangeIPAMLib(object):
|
||||
db.network_delete_safe(context, network['id'])
|
||||
|
||||
def get_project_and_global_net_ids(self, context, project_id):
|
||||
""" Fetches all networks associated with this project, or
|
||||
"""Fetches all networks associated with this project, or
|
||||
that are "global" (i.e., have no project set).
|
||||
Returns list sorted by 'priority'.
|
||||
Returns list sorted by 'priority' (lowest integer value
|
||||
is highest priority).
|
||||
"""
|
||||
if project_id is None:
|
||||
raise Exception(_("get_project_and_global_net_ids must be called"
|
||||
@@ -134,7 +135,7 @@ class QuantumMelangeIPAMLib(object):
|
||||
for priority, network_id, tenant_id in priority_nets]
|
||||
|
||||
def get_subnets_by_net_id(self, context, project_id, net_id):
|
||||
""" Returns information about the IPv4 and IPv6 subnets
|
||||
"""Returns information about the IPv4 and IPv6 subnets
|
||||
associated with a Quantum Network UUID.
|
||||
"""
|
||||
|
||||
@@ -164,14 +165,14 @@ class QuantumMelangeIPAMLib(object):
|
||||
return (subnet_v4, subnet_v6)
|
||||
|
||||
def get_v4_ips_by_interface(self, context, net_id, vif_id, project_id):
|
||||
""" Returns a list of IPv4 address strings associated with
|
||||
"""Returns a list of IPv4 address strings associated with
|
||||
the specified virtual interface.
|
||||
"""
|
||||
return self._get_ips_by_interface(context, net_id, vif_id,
|
||||
project_id, 4)
|
||||
|
||||
def get_v6_ips_by_interface(self, context, net_id, vif_id, project_id):
|
||||
""" Returns a list of IPv6 address strings associated with
|
||||
"""Returns a list of IPv6 address strings associated with
|
||||
the specified virtual interface.
|
||||
"""
|
||||
return self._get_ips_by_interface(context, net_id, vif_id,
|
||||
@@ -179,7 +180,7 @@ class QuantumMelangeIPAMLib(object):
|
||||
|
||||
def _get_ips_by_interface(self, context, net_id, vif_id, project_id,
|
||||
ip_version):
|
||||
""" Helper method to fetch v4 or v6 addresses for a particular
|
||||
"""Helper method to fetch v4 or v6 addresses for a particular
|
||||
virtual interface.
|
||||
"""
|
||||
tenant_id = project_id or FLAGS.quantum_default_tenant_id
|
||||
@@ -188,7 +189,7 @@ class QuantumMelangeIPAMLib(object):
|
||||
if IPNetwork(ip['address']).version == ip_version]
|
||||
|
||||
def verify_subnet_exists(self, context, project_id, quantum_net_id):
|
||||
""" Confirms that a subnet exists that is associated with the
|
||||
"""Confirms that a subnet exists that is associated with the
|
||||
specified Quantum Network UUID.
|
||||
"""
|
||||
tenant_id = project_id or FLAGS.quantum_default_tenant_id
|
||||
@@ -197,7 +198,7 @@ class QuantumMelangeIPAMLib(object):
|
||||
return v4_subnet is not None
|
||||
|
||||
def deallocate_ips_by_vif(self, context, project_id, net_id, vif_ref):
|
||||
""" Deallocate all fixed IPs associated with the specified
|
||||
"""Deallocate all fixed IPs associated with the specified
|
||||
virtual interface.
|
||||
"""
|
||||
tenant_id = project_id or FLAGS.quantum_default_tenant_id
|
||||
|
||||
@@ -27,7 +27,7 @@ from nova.network.quantum import melange_connection as melange
|
||||
from nova import utils
|
||||
|
||||
|
||||
LOG = logging.getLogger("quantum_nova_ipam_lib")
|
||||
LOG = logging.getLogger("nova.network.quantum.nova_ipam_lib")
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
@@ -37,13 +37,13 @@ def get_ipam_lib(net_man):
|
||||
|
||||
|
||||
class QuantumNovaIPAMLib(object):
|
||||
""" Implements Quantum IP Address Management (IPAM) interface
|
||||
"""Implements Quantum IP Address Management (IPAM) interface
|
||||
using the local Nova database. This implementation is inline
|
||||
with how IPAM is used by other NetworkManagers.
|
||||
"""
|
||||
|
||||
def __init__(self, net_manager):
|
||||
""" Holds a reference to the "parent" network manager, used
|
||||
"""Holds a reference to the "parent" network manager, used
|
||||
to take advantage of various FlatManager methods to avoid
|
||||
code duplication.
|
||||
"""
|
||||
@@ -53,7 +53,7 @@ class QuantumNovaIPAMLib(object):
|
||||
quantum_net_id, priority, cidr=None,
|
||||
gateway_v6=None, cidr_v6=None,
|
||||
dns1=None, dns2=None):
|
||||
""" Re-use the basic FlatManager create_networks method to
|
||||
"""Re-use the basic FlatManager create_networks method to
|
||||
initialize the networks and fixed_ips tables in Nova DB.
|
||||
|
||||
Also stores a few more fields in the networks table that
|
||||
@@ -85,7 +85,7 @@ class QuantumNovaIPAMLib(object):
|
||||
return network['uuid']
|
||||
|
||||
def delete_subnets_by_net_id(self, context, net_id, project_id):
|
||||
""" Deletes a network based on Quantum UUID. Uses FlatManager
|
||||
"""Deletes a network based on Quantum UUID. Uses FlatManager
|
||||
delete_network to avoid duplication.
|
||||
"""
|
||||
admin_context = context.elevated()
|
||||
@@ -97,7 +97,7 @@ class QuantumNovaIPAMLib(object):
|
||||
require_disassociated=False)
|
||||
|
||||
def get_project_and_global_net_ids(self, context, project_id):
|
||||
""" Fetches all networks associated with this project, or
|
||||
"""Fetches all networks associated with this project, or
|
||||
that are "global" (i.e., have no project set).
|
||||
Returns list sorted by 'priority'.
|
||||
"""
|
||||
@@ -113,7 +113,7 @@ class QuantumNovaIPAMLib(object):
|
||||
return sorted(net_list, key=lambda x: id_priority_map[x[0]])
|
||||
|
||||
def allocate_fixed_ip(self, context, tenant_id, quantum_net_id, vif_rec):
|
||||
""" Allocates a single fixed IPv4 address for a virtual interface."""
|
||||
"""Allocates a single fixed IPv4 address for a virtual interface."""
|
||||
admin_context = context.elevated()
|
||||
network = db.network_get_by_uuid(admin_context, quantum_net_id)
|
||||
if network['cidr']:
|
||||
@@ -125,7 +125,7 @@ class QuantumNovaIPAMLib(object):
|
||||
db.fixed_ip_update(admin_context, address, values)
|
||||
|
||||
def get_subnets_by_net_id(self, context, tenant_id, net_id):
|
||||
""" Returns information about the IPv4 and IPv6 subnets
|
||||
"""Returns information about the IPv4 and IPv6 subnets
|
||||
associated with a Quantum Network UUID.
|
||||
"""
|
||||
n = db.network_get_by_uuid(context.elevated(), net_id)
|
||||
@@ -148,7 +148,7 @@ class QuantumNovaIPAMLib(object):
|
||||
return (subnet_data_v4, subnet_data_v6)
|
||||
|
||||
def get_v4_ips_by_interface(self, context, net_id, vif_id, project_id):
|
||||
""" Returns a list of IPv4 address strings associated with
|
||||
"""Returns a list of IPv4 address strings associated with
|
||||
the specified virtual interface, based on the fixed_ips table.
|
||||
"""
|
||||
vif_rec = db.virtual_interface_get_by_uuid(context, vif_id)
|
||||
@@ -157,7 +157,7 @@ class QuantumNovaIPAMLib(object):
|
||||
return [fixed_ip['address'] for fixed_ip in fixed_ips]
|
||||
|
||||
def get_v6_ips_by_interface(self, context, net_id, vif_id, project_id):
|
||||
""" Returns a list containing a single IPv6 address strings
|
||||
"""Returns a list containing a single IPv6 address strings
|
||||
associated with the specified virtual interface.
|
||||
"""
|
||||
admin_context = context.elevated()
|
||||
@@ -171,7 +171,7 @@ class QuantumNovaIPAMLib(object):
|
||||
return []
|
||||
|
||||
def verify_subnet_exists(self, context, tenant_id, quantum_net_id):
|
||||
""" Confirms that a subnet exists that is associated with the
|
||||
"""Confirms that a subnet exists that is associated with the
|
||||
specified Quantum Network UUID. Raises an exception if no
|
||||
such subnet exists.
|
||||
"""
|
||||
@@ -179,7 +179,7 @@ class QuantumNovaIPAMLib(object):
|
||||
db.network_get_by_uuid(admin_context, quantum_net_id)
|
||||
|
||||
def deallocate_ips_by_vif(self, context, tenant_id, net_id, vif_ref):
|
||||
""" Deallocate all fixed IPs associated with the specified
|
||||
"""Deallocate all fixed IPs associated with the specified
|
||||
virtual interface.
|
||||
"""
|
||||
try:
|
||||
|
||||
@@ -21,7 +21,7 @@ from nova.network.quantum import client as quantum_client
|
||||
from nova import utils
|
||||
|
||||
|
||||
LOG = logging.getLogger("nova.network.quantum")
|
||||
LOG = logging.getLogger("nova.network.quantum.quantum_connection")
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
flags.DEFINE_string('quantum_connection_host',
|
||||
@@ -38,7 +38,7 @@ flags.DEFINE_string('quantum_default_tenant_id',
|
||||
|
||||
|
||||
class QuantumClientConnection(object):
|
||||
""" Abstracts connection to Quantum service into higher level
|
||||
"""Abstracts connection to Quantum service into higher level
|
||||
operations performed by the QuantumManager.
|
||||
|
||||
Separating this out as a class also let's us create a 'fake'
|
||||
@@ -46,14 +46,14 @@ class QuantumClientConnection(object):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
""" Initialize Quantum client class based on flags. """
|
||||
"""Initialize Quantum client class based on flags."""
|
||||
self.client = quantum_client.Client(FLAGS.quantum_connection_host,
|
||||
FLAGS.quantum_connection_port,
|
||||
format="json",
|
||||
logger=LOG)
|
||||
|
||||
def create_network(self, tenant_id, network_name):
|
||||
""" Create network using specified name, return Quantum
|
||||
"""Create network using specified name, return Quantum
|
||||
network UUID.
|
||||
"""
|
||||
data = {'network': {'name': network_name}}
|
||||
@@ -61,11 +61,11 @@ class QuantumClientConnection(object):
|
||||
return resdict["network"]["id"]
|
||||
|
||||
def delete_network(self, tenant_id, net_id):
|
||||
""" Deletes Quantum network with specified UUID. """
|
||||
"""Deletes Quantum network with specified UUID."""
|
||||
self.client.delete_network(net_id, tenant=tenant_id)
|
||||
|
||||
def network_exists(self, tenant_id, net_id):
|
||||
""" Determine if a Quantum network exists for the
|
||||
"""Determine if a Quantum network exists for the
|
||||
specified tenant.
|
||||
"""
|
||||
try:
|
||||
@@ -76,7 +76,7 @@ class QuantumClientConnection(object):
|
||||
return False
|
||||
|
||||
def create_and_attach_port(self, tenant_id, net_id, interface_id):
|
||||
""" Creates a Quantum port on the specified network, sets
|
||||
"""Creates a Quantum port on the specified network, sets
|
||||
status to ACTIVE to enable traffic, and attaches the
|
||||
vNIC with the specified interface-id.
|
||||
"""
|
||||
@@ -91,7 +91,7 @@ class QuantumClientConnection(object):
|
||||
tenant=tenant_id)
|
||||
|
||||
def detach_and_delete_port(self, tenant_id, net_id, port_id):
|
||||
""" Detach and delete the specified Quantum port. """
|
||||
"""Detach and delete the specified Quantum port."""
|
||||
LOG.debug(_("Deleting port %(port_id)s on net %(net_id)s"
|
||||
" for %(tenant_id)s" % locals()))
|
||||
|
||||
@@ -99,7 +99,7 @@ class QuantumClientConnection(object):
|
||||
self.client.delete_port(net_id, port_id, tenant=tenant_id)
|
||||
|
||||
def get_port_by_attachment(self, tenant_id, attachment_id):
|
||||
""" Given a tenant, search for the Quantum network and port
|
||||
"""Given a tenant, search for the Quantum network and port
|
||||
UUID that has the specified interface-id attachment.
|
||||
"""
|
||||
# FIXME(danwent): this will be inefficient until the Quantum
|
||||
|
||||
Reference in New Issue
Block a user