def refresh_dhcp_helper(self, network_id):
"""Refresh or disable DHCP for a network depending on the current state
of the network.
-
"""
old_network = self.cache.get_network_by_id(network_id)
if not old_network:
-"""
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright 2012 Nicira Networks, Inc. All rights reserved.
#
# @author: Dan Wendlandt, Nicira, Inc
#
-"""
import eventlet
from eventlet import semaphore
class Daemon(object):
- """
- A generic daemon class.
+ """A generic daemon class.
Usage: subclass the Daemon class and override the run() method
"""
def init_l3(self, device_name, ip_cidrs, namespace=None):
"""Set the L3 settings for the interface using data from the port.
- ip_cidrs: list of 'X.X.X.X/YY' strings
+
+ ip_cidrs: list of 'X.X.X.X/YY' strings
"""
device = ip_lib.IPDevice(device_name,
self.root_helper,
return retval
def pullup_route(self, interface_name):
- """
- Ensures that the route entry for the interface is before all
+ """Ensures that the route entry for the interface is before all
others on the same subnet.
"""
device_list = []
class NetworkMetadataProxyHandler(object):
"""Proxy AF_INET metadata request through Unix Domain socket.
- The Unix domain socket allows the proxy access resource that are not
- accessible within the isolated tenant context.
+ The Unix domain socket allows the proxy access resource that are not
+ accessible within the isolated tenant context.
"""
def __init__(self, network_id=None, router_id=None):
class SecurityGroupServerRpcApiMixin(object):
- """A mix-in that enable SecurityGroup support in plugin rpc
- """
+ """A mix-in that enable SecurityGroup support in plugin rpc."""
def security_group_rules_for_devices(self, context, devices):
LOG.debug(_("Get security group rules "
"for devices via rpc %r"), devices)
def get_filters(request, attr_info, skips=[]):
- """
- Extracts the filters from the request string
+ """Extracts the filters from the request string.
+
Returns a dict of lists for the filters:
check=a&check=b&name=Bob&
becomes:
def get_sorts(request, attr_info):
- """Extract sort_key and sort_dir from request, return as:
- [(key1, value1), (key2, value2)]
+ """Extract sort_key and sort_dir from request.
+
+ Return as: [(key1, value1), (key2, value2)]
"""
sort_keys = list_args(request, "sort_key")
sort_dirs = list_args(request, "sort_dir")
def _prepare_request_body(self, body, params):
"""Verifies required parameters are in request body.
- sets default value for missing optional parameters.
- body argument must be the deserialized body
+ Sets default value for missing optional parameters.
+ Body argument must be the deserialized body.
"""
try:
if body is None:
@classmethod
def __subclasshook__(cls, klass):
- """
+ """Checking plugin class.
+
The __subclasshook__ method is a class method
that will be called everytime a class is tested
using issubclass(klass, PluginInterface).
return request_exts
def get_extended_resources(self, version):
- """retrieve extended resources or attributes for core resources.
+ """Retrieve extended resources or attributes for core resources.
Extended attributes are implemented by a core plugin similarly
to the attributes defined in the core, and can appear in
return {}
def get_plugin_interface(self):
- """
- Returns an abstract class which defines contract for the plugin.
+ """Returns an abstract class which defines contract for the plugin.
+
The abstract class should inherit from extesnions.PluginInterface,
Methods in this abstract class should be decorated as abstractmethod
"""
def update_attributes_map(self, extended_attributes,
extension_attrs_map=None):
- """Update attributes map for this extension
+ """Update attributes map for this extension.
This is default method for extending an extension's attributes map.
An extension can use this method and supplying its own resource
def _verify_dict_keys(expected_keys, target_dict, strict=True):
"""Allows to verify keys in a dictionary.
+
:param expected_keys: A list of keys expected to be present.
:param target_dict: The dictionary which should be verified.
:param strict: Specifies whether additional keys are allowed to be present.
def _validate_ip_pools(data, valid_values=None):
- """Validate that start and end IP addresses are present
+ """Validate that start and end IP addresses are present.
In addition to this the IP addresses will also be validated
-
"""
if not isinstance(data, list):
msg = _("Invalid data format for IP pool: '%s'") % data
@staticmethod
def prepare_request_body(context, body, is_create, resource, attr_info,
allow_bulk=False):
- """Verifies required attributes are in request body, and that
- an attribute is only specified if it is allowed for the given
- operation (create/update).
- Attribute with default values are considered to be
- optional.
+ """Verifies required attributes are in request body.
- body argument must be the deserialized body
+ Also checking that an attribute is only specified if it is allowed
+ for the given operation (create/update).
+
+ Attribute with default values are considered to be optional.
+
+ body argument must be the deserialized body.
"""
collection = resource + "s"
if not body:
class ViewBuilder(object):
def __init__(self, base_url):
- """
+ """Object initialization.
+
:param base_url: url of the root wsgi application
"""
self.base_url = base_url