summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrey Morris <trey.morris@rackspace.com>2011-06-17 13:47:28 -0500
committerTrey Morris <trey.morris@rackspace.com>2011-06-17 13:47:28 -0500
commit749eac4d36ff2f7a855044d677f3cde07451f32a (patch)
treeecf74cb3b1580dfd00b3f9163a6b489188c323fb
parentc3300c29277423c28c5403d23b4a7f0a960f429d (diff)
bunch of docstring changes
-rw-r--r--nova/compute/api.py8
-rw-r--r--nova/compute/manager.py5
-rw-r--r--nova/db/api.py18
-rw-r--r--nova/db/sqlalchemy/api.py47
-rw-r--r--nova/db/sqlalchemy/models.py2
-rw-r--r--nova/network/api.py26
-rw-r--r--nova/network/linux_net.py4
-rw-r--r--nova/network/manager.py49
-rw-r--r--nova/test.py4
-rw-r--r--nova/tests/db/fakes.py4
-rw-r--r--nova/tests/test_iptables_network.py4
11 files changed, 84 insertions, 87 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py
index b05db3ca5..6c31a9697 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -716,14 +716,14 @@ class API(base.Base):
@scheduler_api.reroute_compute("add_fixed_ip")
def add_fixed_ip(self, context, instance_id, network_id):
- """add fixed_ip from specified network to given instance"""
+ """Add fixed_ip from specified network to given instance."""
self._cast_compute_message('add_fixed_ip_to_instance', context,
instance_id,
network_id)
#TODO(tr3buchet): how to run this in the correct zone?
def add_network_to_project(self, context, project_id):
- """force adds a network to the project"""
+ """Force adds a network to the project."""
# this will raise if zone doesn't know about project so the decorator
# can catch it and pass it down
self.db.project_get(context, project_id)
@@ -873,9 +873,9 @@ class API(base.Base):
return instance
def associate_floating_ip(self, context, instance_id, address):
- """makes calls to network_api to associate_floating_ip
+ """Makes calls to network_api to associate_floating_ip.
- address is a string floating ip address
+ :param address: is a string floating ip address
"""
instance = self.get(context, instance_id)
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index d08286224..2ad0c0d04 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -607,8 +607,9 @@ class ComputeManager(manager.SchedulerDependentManager):
@exception.wrap_exception
@checks_instance_lock
def add_fixed_ip_to_instance(self, context, instance_id, network_id):
- """calls network_api to add new fixed_ip to instance
- then injects the new network info and resets instance networking
+ """Calls network_api to add new fixed_ip to instance
+ then injects the new network info and resets instance networking.
+
"""
self.network_api.add_fixed_ip_to_instance(context, instance_id,
network_id)
diff --git a/nova/db/api.py b/nova/db/api.py
index 64b6a893e..b625a0b0f 100644
--- a/nova/db/api.py
+++ b/nova/db/api.py
@@ -406,50 +406,50 @@ def fixed_ip_update(context, address, values):
def virtual_interface_create(context, values):
- """create a virtual interface record in the database"""
+ """Create a virtual interface record in the database."""
return IMPL.virtual_interface_create(context, values)
def virtual_interface_get(context, vif_id):
- """gets a virtual interface from the table"""
+ """Gets a virtual interface from the table,"""
return IMPL.virtual_interface_get(context, vif_id)
def virtual_interface_get_by_address(context, address):
- """gets a virtual interface from the table filtering on address"""
+ """Gets a virtual interface from the table filtering on address."""
return IMPL.virtual_interface_get_by_address(context, address)
def virtual_interface_get_by_fixed_ip(context, fixed_ip_id):
- """gets the virtual interface fixed_ip is associated with"""
+ """Gets the virtual interface fixed_ip is associated with."""
return IMPL.virtual_interface_get_by_fixed_ip(context, fixed_ip_id)
def virtual_interface_get_by_instance(context, instance_id):
- """gets all virtual_interfaces for instance"""
+ """Gets all virtual_interfaces for instance."""
return IMPL.virtual_interface_get_by_instance(context, instance_id)
def virtual_interface_get_by_instance_and_network(context, instance_id,
network_id):
- """gets all virtual interfaces for instance"""
+ """Gets all virtual interfaces for instance."""
return IMPL.virtual_interface_get_by_instance_and_network(context,
instance_id,
network_id)
def virtual_interface_get_by_network(context, network_id):
- """gets all virtual interfaces on network"""
+ """Gets all virtual interfaces on network."""
return IMPL.virtual_interface_get_by_network(context, network_id)
def virtual_interface_delete(context, vif_id):
- """delete virtual interface record from the database"""
+ """Delete virtual interface record from the database."""
return IMPL.virtual_interface_delete(context, vif_id)
def virtual_interface_delete_by_instance(context, instance_id):
- """delete virtual interface records associated with instance """
+ """Delete virtual interface records associated with instance."""
return IMPL.virtual_interface_delete_by_instance(context, instance_id)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 12044f23d..8d12e25c0 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -804,10 +804,9 @@ def fixed_ip_update(context, address, values):
@require_context
def virtual_interface_create(context, values):
- """create a new virtual interface record in teh database
+ """Create a new virtual interface record in teh database.
- context = request context object
- values = dict containing column values
+ :param values: = dict containing column values
"""
vif_ref = models.VirtualInterface()
vif_ref.update(values)
@@ -818,10 +817,9 @@ def virtual_interface_create(context, values):
@require_context
def virtual_interface_get(context, vif_id):
- """gets a virtual interface from the table
+ """Gets a virtual interface from the table.
- context = request context object
- vif_id = id of the virtual interface
+ :param vif_id: = id of the virtual interface
"""
session = get_session()
vif_ref = session.query(models.VirtualInterface).\
@@ -835,10 +833,9 @@ def virtual_interface_get(context, vif_id):
@require_context
def virtual_interface_get_by_address(context, address):
- """gets a virtual interface from the table
+ """Gets a virtual interface from the table.
- context = request context object
- address = the address of the interface you're looking to get
+ :param address: = the address of the interface you're looking to get
"""
session = get_session()
vif_ref = session.query(models.VirtualInterface).\
@@ -852,10 +849,9 @@ def virtual_interface_get_by_address(context, address):
@require_context
def virtual_interface_get_by_fixed_ip(context, fixed_ip_id):
- """gets the virtual interface fixed_ip is associated with
+ """Gets the virtual interface fixed_ip is associated with.
- context = request context object
- fixed_ip_id = id of the fixed_ip
+ :param fixed_ip_id: = id of the fixed_ip
"""
session = get_session()
vif_ref = session.query(models.VirtualInterface).\
@@ -869,10 +865,9 @@ def virtual_interface_get_by_fixed_ip(context, fixed_ip_id):
@require_context
def virtual_interface_get_by_instance(context, instance_id):
- """gets all virtual interfaces for instance
+ """Gets all virtual interfaces for instance.
- context = request context object
- instance_id = id of the instance to retreive vifs for
+ :param instance_id: = id of the instance to retreive vifs for
"""
session = get_session()
vif_refs = session.query(models.VirtualInterface).\
@@ -887,7 +882,7 @@ def virtual_interface_get_by_instance(context, instance_id):
@require_context
def virtual_interface_get_by_instance_and_network(context, instance_id,
network_id):
- """gets virtual interface for instance that's associated with network"""
+ """Gets virtual interface for instance that's associated with network."""
session = get_session()
vif_ref = session.query(models.VirtualInterface).\
filter_by(instance_id=instance_id).\
@@ -901,10 +896,9 @@ def virtual_interface_get_by_instance_and_network(context, instance_id,
@require_admin_context
def virtual_interface_get_by_network(context, network_id):
- """gets all virtual_interface on network
+ """Gets all virtual_interface on network.
- context = request context object
- network_id = network to retreive vifs for
+ :param network_id: = network to retreive vifs for
"""
session = get_session()
vif_refs = session.query(models.VirtualInterface).\
@@ -918,10 +912,9 @@ def virtual_interface_get_by_network(context, network_id):
@require_context
def virtual_interface_delete(context, vif_id):
- """delete virtual interface record from teh database
+ """Delete virtual interface record from teh database.
- context = request context object
- vif_id = id of vif to delete
+ :param vif_id: = id of vif to delete
"""
vif_ref = virtual_interface_get(context, vif_id)
session = get_session()
@@ -934,11 +927,10 @@ def virtual_interface_delete(context, vif_id):
@require_context
def virtual_interface_delete_by_instance(context, instance_id):
- """delete virtual interface records that are associated
- with the instance given by instance_id
+ """Delete virtual interface records that are associated
+ with the instance given by instance_id.
- context = request context object
- instance_id = id of instance
+ :param instance_id: = id of instance
"""
vif_refs = virtual_interface_get_by_instance(context, instance_id)
for vif_ref in vif_refs:
@@ -1366,7 +1358,8 @@ def key_pair_get_all_by_user(context, user_id):
@require_admin_context
def network_associate(context, project_id, force=False):
- """associate a project with a network
+ """Associate a project with a network.
+
called by project_get_networks under certain conditions
and network manager add_network_to_project()
diff --git a/nova/db/sqlalchemy/models.py b/nova/db/sqlalchemy/models.py
index ddf068565..300a75ce0 100644
--- a/nova/db/sqlalchemy/models.py
+++ b/nova/db/sqlalchemy/models.py
@@ -512,7 +512,7 @@ class Network(BASE, NovaBase):
class VirtualInterface(BASE, NovaBase):
- """Represents a virtual interface on an instance"""
+ """Represents a virtual interface on an instance."""
__tablename__ = 'virtual_interfaces'
id = Column(Integer, primary_key=True)
address = Column(String(255), unique=True)
diff --git a/nova/network/api.py b/nova/network/api.py
index e333866ed..a43e76d2a 100644
--- a/nova/network/api.py
+++ b/nova/network/api.py
@@ -34,7 +34,7 @@ class API(base.Base):
"""API for interacting with the network manager."""
def allocate_floating_ip(self, context):
- """adds a floating ip to a project"""
+ """Adds a floating ip to a project."""
# NOTE(vish): We don't know which network host should get the ip
# when we allocate, so just send it to any one. This
# will probably need to move into a network supervisor
@@ -46,7 +46,7 @@ class API(base.Base):
def release_floating_ip(self, context, address,
affect_auto_assigned=False):
- """removes floating ip with address from a project"""
+ """Removes floating ip with address from a project."""
floating_ip = self.db.floating_ip_get_by_address(context, address)
if not affect_auto_assigned and floating_ip.get('auto_assigned'):
return
@@ -61,11 +61,12 @@ class API(base.Base):
def associate_floating_ip(self, context, floating_ip, fixed_ip,
affect_auto_assigned=False):
- """associates a floating ip with a fixed ip
+ """Associates a floating ip with a fixed ip.
+
ensures floating ip is allocated to the project in context
- fixed_ip is either a fixed_ip object or a string fixed ip address
- floating_ip is a string floating ip address
+ :param fixed_ip: is either fixed_ip object or a string fixed ip address
+ :param floating_ip: is a string floating ip address
"""
# NOTE(tr3buchet): i don't like the "either or" argument type
# funcationility but i've left it alone for now
@@ -100,7 +101,7 @@ class API(base.Base):
def disassociate_floating_ip(self, context, address,
affect_auto_assigned=False):
- """disassociates a floating ip from fixed ip it is associated with"""
+ """Disassociates a floating ip from fixed ip it is associated with."""
floating_ip = self.db.floating_ip_get_by_address(context, address)
if not affect_auto_assigned and floating_ip.get('auto_assigned'):
return
@@ -113,8 +114,9 @@ class API(base.Base):
'args': {'floating_address': floating_ip['address']}})
def allocate_for_instance(self, context, instance, **kwargs):
- """allocates all network structures for an instance
- returns network info as from get_instance_nw_info() below
+ """Allocates all network structures for an instance.
+
+ :returns: network info as from get_instance_nw_info() below
"""
args = kwargs
args['instance_id'] = instance['id']
@@ -125,7 +127,7 @@ class API(base.Base):
'args': args})
def deallocate_for_instance(self, context, instance, **kwargs):
- """deallocates all network structures related to instance"""
+ """Deallocates all network structures related to instance."""
args = kwargs
args['instance_id'] = instance['id']
args['project_id'] = instance['project_id']
@@ -134,7 +136,7 @@ class API(base.Base):
'args': args})
def add_fixed_ip_to_instance(self, context, instance_id, network_id):
- """adds a fixed ip to instance from specified network"""
+ """Adds a fixed ip to instance from specified network."""
args = {'instance_id': instance_id,
'network_id': network_id}
rpc.cast(context, FLAGS.network_topic,
@@ -142,13 +144,13 @@ class API(base.Base):
'args': args})
def add_network_to_project(self, context, project_id):
- """force adds another network to a project"""
+ """Force adds another network to a project."""
rpc.cast(context, FLAGS.network_topic,
{'method': 'add_network_to_project',
'args': {'project_id': project_id}})
def get_instance_nw_info(self, context, instance):
- """returns all network info related to an instance"""
+ """Returns all network info related to an instance."""
args = {'instance_id': instance['id'],
'instance_type_id': instance['instance_type_id']}
return rpc.call(context, FLAGS.network_topic,
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py
index 3062e0ca0..4b998fbba 100644
--- a/nova/network/linux_net.py
+++ b/nova/network/linux_net.py
@@ -445,14 +445,14 @@ def floating_forward_rules(floating_ip, fixed_ip):
def ensure_vlan_bridge(vlan_num, bridge, bridge_interface, net_attrs=None):
- """Create a vlan and bridge unless they already exist"""
+ """Create a vlan and bridge unless they already exist."""
interface = ensure_vlan(vlan_num, bridge_interface)
ensure_bridge(bridge, interface, net_attrs)
@utils.synchronized('ensure_vlan', external=True)
def ensure_vlan(vlan_num, bridge_interface):
- """Create a vlan unless it already exists"""
+ """Create a vlan unless it already exists."""
interface = 'vlan%s' % vlan_num
if not _device_exists(interface):
LOG.debug(_('Starting VLAN inteface %s'), interface)
diff --git a/nova/network/manager.py b/nova/network/manager.py
index d725be69f..fd592c3e3 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -116,13 +116,13 @@ class AddressAlreadyAllocated(exception.Error):
class RPCAllocateFixedIP(object):
- """mixin class originally for FlatDCHP and VLAN network managers
+ """Mixin class originally for FlatDCHP and VLAN network managers.
used since they share code to RPC.call allocate_fixed_ip on the
correct network host to configure dnsmasq
"""
def _allocate_fixed_ips(self, context, instance_id, networks):
- """calls allocate_fixed_ip once for each network"""
+ """Calls allocate_fixed_ip once for each network."""
green_pool = greenpool.GreenPool()
for network in networks:
@@ -145,17 +145,17 @@ class RPCAllocateFixedIP(object):
green_pool.waitall()
def _rpc_allocate_fixed_ip(self, context, instance_id, network_id):
- """sits in between _allocate_fixed_ips and allocate_fixed_ip to
- perform network lookup on the far side of rpc
+ """Sits in between _allocate_fixed_ips and allocate_fixed_ip to
+ perform network lookup on the far side of rpc.
"""
network = self.db.network_get(context, network_id)
self.allocate_fixed_ip(context, instance_id, network)
class FloatingIP(object):
- """mixin class for adding floating IP functionality to a manager"""
+ """Mixin class for adding floating IP functionality to a manager."""
def init_host_floating_ips(self):
- """configures floating ips owned by host"""
+ """Configures floating ips owned by host."""
admin_context = context.get_admin_context()
floating_ips = self.db.floating_ip_get_all_by_host(admin_context,
@@ -170,7 +170,8 @@ class FloatingIP(object):
fixed_address)
def allocate_for_instance(self, context, **kwargs):
- """handles allocating the floating IP resources for an instance
+ """Handles allocating the floating IP resources for an instance.
+
calls super class allocate_for_instance() as well
rpc.called by network_api
@@ -204,8 +205,9 @@ class FloatingIP(object):
return ips
def deallocate_for_instance(self, context, **kwargs):
- """handles deallocating floating IP resources for an instance
- calls super class deallocate_for_instance() as well
+ """Handles deallocating floating IP resources for an instance.
+
+ calls super class deallocate_for_instance() as well.
rpc.called by network_api
"""
@@ -326,7 +328,7 @@ class NetworkManager(manager.SchedulerDependentManager):
return host
def set_network_hosts(self, context):
- """Set the network hosts for any networks which are unset"""
+ """Set the network hosts for any networks which are unset."""
networks = self.db.network_get_all(context)
for network in networks:
host = network['host']
@@ -335,7 +337,7 @@ class NetworkManager(manager.SchedulerDependentManager):
return self.set_network_host(context, network['id'])
def _get_networks_for_instance(self, context, instance_id, project_id):
- """determine which networks an instance should connect to"""
+ """Determine & return which networks an instance should connect to."""
# TODO(tr3buchet) maybe this needs to be updated in the future if
# there is a better way to determine which networks
# a non-vlan instance should connect to
@@ -346,7 +348,7 @@ class NetworkManager(manager.SchedulerDependentManager):
not network['vlan'] and network['host']]
def allocate_for_instance(self, context, **kwargs):
- """handles allocating the various network resources for an instance
+ """Handles allocating the various network resources for an instance.
rpc.called by network_api
"""
@@ -363,7 +365,7 @@ class NetworkManager(manager.SchedulerDependentManager):
return self.get_instance_nw_info(context, instance_id, type_id)
def deallocate_for_instance(self, context, **kwargs):
- """handles deallocating various network resources for an instance
+ """Handles deallocating various network resources for an instance.
rpc.called by network_api
kwargs can contain fixed_ips to circumvent another db lookup
@@ -381,11 +383,11 @@ class NetworkManager(manager.SchedulerDependentManager):
self.deallocate_fixed_ip(context, fixed_ip['address'], **kwargs)
def get_instance_nw_info(self, context, instance_id, instance_type_id):
- """creates network info list for instance
+ """Creates network info list for instance.
called by allocate_for_instance and netowrk_api
context needs to be elevated
- returns network info list [(network,info),(network,info)...]
+ :returns: network info list [(network,info),(network,info)...]
where network = dict containing pertinent data from a network db object
and info = dict containing pertinent networking data
"""
@@ -439,7 +441,7 @@ class NetworkManager(manager.SchedulerDependentManager):
return network_info
def _allocate_mac_addresses(self, context, instance_id, networks):
- """generates mac addresses and creates vif rows in db for them"""
+ """Generates mac addresses and creates vif rows in db for them."""
for network in networks:
vif = {'address': self.generate_mac_address(),
'instance_id': instance_id,
@@ -457,7 +459,7 @@ class NetworkManager(manager.SchedulerDependentManager):
raise exception.VirtualInterface(_("5 create attempts failed"))
def generate_mac_address(self):
- """generate a mac address for a vif on an instance"""
+ """Generate a mac address for a vif on an instance."""
mac = [0x02, 0x16, 0x3e,
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
@@ -465,7 +467,7 @@ class NetworkManager(manager.SchedulerDependentManager):
return ':'.join(map(lambda x: "%02x" % x, mac))
def add_fixed_ip_to_instance(self, context, instance_id, network_id):
- """adds a fixed ip to an instance from specified network"""
+ """Adds a fixed ip to an instance from specified network."""
networks = [self.db.network_get(context, network_id)]
self._allocate_fixed_ips(context, instance_id, networks)
@@ -632,7 +634,7 @@ class NetworkManager(manager.SchedulerDependentManager):
'reserved': reserved})
def _allocate_fixed_ips(self, context, instance_id, networks):
- """calls allocate_fixed_ip once for each network"""
+ """Calls allocate_fixed_ip once for each network."""
raise NotImplementedError()
def _on_set_network_host(self, context, network_id):
@@ -641,6 +643,7 @@ class NetworkManager(manager.SchedulerDependentManager):
def setup_compute_network(self, context, instance_id):
"""Sets up matching network for compute hosts.
+
this code is run on and by the compute host, not on network
hosts
"""
@@ -678,7 +681,7 @@ class FlatManager(NetworkManager):
timeout_fixed_ips = False
def _allocate_fixed_ips(self, context, instance_id, networks):
- """calls allocate_fixed_ip once for each network"""
+ """Calls allocate_fixed_ip once for each network."""
for network in networks:
self.allocate_fixed_ip(context, instance_id, network)
@@ -690,6 +693,7 @@ class FlatManager(NetworkManager):
def setup_compute_network(self, context, instance_id):
"""Network is created manually.
+
this code is run on and by the compute host, not on network hosts
"""
pass
@@ -725,6 +729,7 @@ class FlatDHCPManager(FloatingIP, RPCAllocateFixedIP, NetworkManager):
def setup_compute_network(self, context, instance_id):
"""Sets up matching networks for compute hosts.
+
this code is run on and by the compute host, not on network hosts
"""
networks = db.network_get_all_by_instance(context, instance_id)
@@ -804,7 +809,7 @@ class VlanManager(RPCAllocateFixedIP, FloatingIP, NetworkManager):
self.driver.update_dhcp(context, network['id'])
def add_network_to_project(self, context, project_id):
- """force adds another network to a project"""
+ """Force adds another network to a project."""
self.db.network_associate(context, project_id, force=True)
def setup_compute_network(self, context, instance_id):
@@ -818,7 +823,7 @@ class VlanManager(RPCAllocateFixedIP, FloatingIP, NetworkManager):
network['bridge_interface'])
def _get_networks_for_instance(self, context, instance_id, project_id):
- """determine which networks an instance should connect to"""
+ """Determine which networks an instance should connect to."""
# get networks associated with project
networks = self.db.project_get_networks(context, project_id)
diff --git a/nova/test.py b/nova/test.py
index f03ddc6d5..8718f8d5b 100644
--- a/nova/test.py
+++ b/nova/test.py
@@ -55,13 +55,13 @@ LOG = log.getLogger('nova.tests')
class skip_test(object):
- """decorator that skips a test"""
+ """Decorator that skips a test."""
def __init__(self, msg):
self.message = msg
def __call__(self, func):
def _skipper(*args, **kw):
- """wrapped skipper function."""
+ """Wrapped skipper function."""
raise nose.SkipTest(self.message)
_skipper.__name__ = func.__name__
_skipper.__doc__ = func.__doc__
diff --git a/nova/tests/db/fakes.py b/nova/tests/db/fakes.py
index 525f720a5..ba1e99755 100644
--- a/nova/tests/db/fakes.py
+++ b/nova/tests/db/fakes.py
@@ -44,9 +44,7 @@ class FakeModel(object):
def stub_out(stubs, funcs):
- """
- Set the stubs in mapping in the db api
- """
+ """Set the stubs in mapping in the db api."""
for func in funcs:
func_name = '_'.join(func.__name__.split('_')[1:])
stubs.Set(db, func_name, func)
diff --git a/nova/tests/test_iptables_network.py b/nova/tests/test_iptables_network.py
index 77f6aaff3..29b09ade2 100644
--- a/nova/tests/test_iptables_network.py
+++ b/nova/tests/test_iptables_network.py
@@ -15,9 +15,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
-"""
-Unit Tests for network code
-"""
+"""Unit Tests for network code."""
import IPy
import os