desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'Remove the association of the VIF with the dynamic vnic'
def detach_port(self, tenant_id, instance_id, instance_desc):
LOG.debug(_('detach_port() called')) return self._invoke_device_plugins(self._func_name(), [tenant_id, instance_id, instance_desc])
'Device-specific calls including core API and extensions are delegated to the model.'
def _invoke_device_plugins(self, function_name, args):
if hasattr(self._model, function_name): return getattr(self._model, function_name)(*args)
'Getting the name of the calling funciton'
def _func_name(self, offset=0):
return inspect.stack()[(1 + offset)][3]
'Returns Ext Resource Name'
@classmethod def get_name(cls):
return 'Cisco Credential'
'Returns Ext Resource Alias'
@classmethod def get_alias(cls):
return 'Cisco Credential'
'Returns Ext Resource Description'
@classmethod def get_description(cls):
return 'Credential include username and password'
'Returns Ext Resource Namespace'
@classmethod def get_namespace(cls):
return 'http://docs.ciscocloud.com/api/ext/credential/v1.0'
'Returns Ext Resource Update Time'
@classmethod def get_updated(cls):
return '2011-07-25T13:25:27-06:00'
'Returns Ext Resources'
@classmethod def get_resources(cls):
parent_resource = dict(member_name='tenant', collection_name='extensions/csco/tenants') controller = CredentialController(QuantumManager.get_plugin()) return [extensions.ResourceExtension('credentials', controller, parent=parent_resource)]
'Returns a list of credential ids'
def index(self, request, tenant_id):
return self._items(request, tenant_id, is_detail=False)
'Returns a list of credentials.'
def _items(self, request, tenant_id, is_detail):
credentials = self._plugin.get_all_credentials(tenant_id) builder = credential_view.get_view_builder(request) result = [builder.build(credential, is_detail)['credential'] for credential in credentials] return dict(credentials=result)
'Returns credential details for the given credential id'
def show(self, request, tenant_id, id):
try: credential = self._plugin.get_credential_details(tenant_id, id) builder = credential_view.get_view_builder(request) result = builder.build(credential, True) return dict(credentials=result) except exception.CredentialNotFound as exp: return faults.Fault(faults.Credent...
'Creates a new credential for a given tenant'
def create(self, request, tenant_id):
try: body = self._deserialize(request.body, request.get_content_type()) req_body = self._prepare_request_body(body, self._credential_ops_param_list) req_params = req_body[self._resource_name] except exc.HTTPError as exp: return faults.Fault(exp) credential = self._plugin.crea...
'Updates the name for the credential with the given id'
def update(self, request, tenant_id, id):
try: body = self._deserialize(request.body, request.get_content_type()) req_body = self._prepare_request_body(body, self._credential_ops_param_list) req_params = req_body[self._resource_name] except exc.HTTPError as exp: return faults.Fault(exp) try: credential = self...
'Destroys the credential with the given id'
def delete(self, request, tenant_id, id):
try: self._plugin.delete_credential(tenant_id, id) return exc.HTTPOk() except exception.CredentialNotFound as exp: return faults.Fault(faults.CredentialNotFound(exp))
':param base_url: url of the root wsgi application'
def __init__(self, base_url):
self.base_url = base_url
'Generic method used to generate a credential entity.'
def build(self, credential_data, is_detail=False):
if is_detail: credential = self._build_detail(credential_data) else: credential = self._build_simple(credential_data) return credential
'Return a simple description of credential.'
def _build_simple(self, credential_data):
return dict(credential=dict(id=credential_data['credential_id']))
'Return a detailed description of credential.'
def _build_detail(self, credential_data):
return dict(credential=dict(id=credential_data['credential_id'], name=credential_data['user_name'], password=credential_data['password']))
':param base_url: url of the root wsgi application'
def __init__(self, base_url):
self.base_url = base_url
'Generic method used to generate a QoS entity.'
def build(self, qos_data, is_detail=False):
if is_detail: qos = self._build_detail(qos_data) else: qos = self._build_simple(qos_data) return qos
'Return a simple description of qos.'
def _build_simple(self, qos_data):
return dict(qos=dict(id=qos_data['qos_id']))
'Return a detailed description of qos.'
def _build_detail(self, qos_data):
return dict(qos=dict(id=qos_data['qos_id'], name=qos_data['qos_name'], description=qos_data['qos_desc']))
'Returns Ext Resource Name'
@classmethod def get_name(cls):
return 'Cisco qos'
'Returns Ext Resource Alias'
@classmethod def get_alias(cls):
return 'Cisco qos'
'Returns Ext Resource Description'
@classmethod def get_description(cls):
return 'qos includes qos_name and qos_desc'
'Returns Ext Resource Namespace'
@classmethod def get_namespace(cls):
return 'http://docs.ciscocloud.com/api/ext/qos/v1.0'
'Returns Ext Resource update'
@classmethod def get_updated(cls):
return '2011-07-25T13:25:27-06:00'
'Returns Ext Resources'
@classmethod def get_resources(cls):
parent_resource = dict(member_name='tenant', collection_name='extensions/csco/tenants') controller = QosController(QuantumManager.get_plugin()) return [extensions.ResourceExtension('qoss', controller, parent=parent_resource)]
'Returns a list of qos ids'
def index(self, request, tenant_id):
return self._items(request, tenant_id, is_detail=False)
'Returns a list of qoss.'
def _items(self, request, tenant_id, is_detail):
qoss = self._plugin.get_all_qoss(tenant_id) builder = qos_view.get_view_builder(request) result = [builder.build(qos, is_detail)['qos'] for qos in qoss] return dict(qoss=result)
'Returns qos details for the given qos id'
def show(self, request, tenant_id, id):
try: qos = self._plugin.get_qos_details(tenant_id, id) builder = qos_view.get_view_builder(request) result = builder.build(qos, True) return dict(qoss=result) except exception.QosNotFound as exp: return faults.Fault(faults.QosNotFound(exp))
'Creates a new qos for a given tenant'
def create(self, request, tenant_id):
try: body = self._deserialize(request.body, request.get_content_type()) req_body = self._prepare_request_body(body, self._qos_ops_param_list) req_params = req_body[self._resource_name] except exc.HTTPError as exp: return faults.Fault(exp) qos = self._plugin.create_qos(tenant_...
'Updates the name for the qos with the given id'
def update(self, request, tenant_id, id):
try: body = self._deserialize(request.body, request.get_content_type()) req_body = self._prepare_request_body(body, self._qos_ops_param_list) req_params = req_body[self._resource_name] except exc.HTTPError as exp: return faults.Fault(exp) try: qos = self._plugin.renam...
'Destroys the qos with the given id'
def delete(self, request, tenant_id, id):
try: self._plugin.delete_qos(tenant_id, id) return exc.HTTPOk() except exception.QosNotFound as exp: return faults.Fault(faults.QosNotFound(exp))
'Makes the SSH connection to the Nexus Switch'
def nxos_connect(self, nexus_host, nexus_ssh_port, nexus_user, nexus_password):
man = manager.connect(host=nexus_host, port=nexus_ssh_port, username=nexus_user, password=nexus_password) return man
'Creates the Proper XML structure for the Nexus Switch Configuration'
def create_xml_snippet(self, cutomized_config):
conf_xml_snippet = (snipp.EXEC_CONF_SNIPPET % cutomized_config) return conf_xml_snippet
'Creates a VLAN on Nexus Switch given the VLAN ID and Name'
def enable_vlan(self, mgr, vlanid, vlanname):
confstr = (snipp.CMD_VLAN_CONF_SNIPPET % (vlanid, vlanname)) confstr = self.create_xml_snippet(confstr) mgr.edit_config(target='running', config=confstr)
'Delete a VLAN on Nexus Switch given the VLAN ID'
def disable_vlan(self, mgr, vlanid):
confstr = (snipp.CMD_NO_VLAN_CONF_SNIPPET % vlanid) confstr = self.create_xml_snippet(confstr) mgr.edit_config(target='running', config=confstr)
'Enables trunk mode an interface on Nexus Switch'
def enable_port_trunk(self, mgr, interface):
confstr = (snipp.CMD_PORT_TRUNK % interface) confstr = self.create_xml_snippet(confstr) LOG.debug(_('NexusDriver: %s'), confstr) mgr.edit_config(target='running', config=confstr)
'Disables trunk mode an interface on Nexus Switch'
def disable_switch_port(self, mgr, interface):
confstr = (snipp.CMD_NO_SWITCHPORT % interface) confstr = self.create_xml_snippet(confstr) LOG.debug(_('NexusDriver: %s'), confstr) mgr.edit_config(target='running', config=confstr)
'Enables trunk mode vlan access an interface on Nexus Switch given VLANID'
def enable_vlan_on_trunk_int(self, mgr, interface, vlanid):
confstr = (snipp.CMD_VLAN_INT_SNIPPET % (interface, vlanid)) confstr = self.create_xml_snippet(confstr) LOG.debug(_('NexusDriver: %s'), confstr) mgr.edit_config(target='running', config=confstr)
'Enables trunk mode vlan access an interface on Nexus Switch given VLANID'
def disable_vlan_on_trunk_int(self, mgr, interface, vlanid):
confstr = (snipp.CMD_NO_VLAN_INT_SNIPPET % (interface, vlanid)) confstr = self.create_xml_snippet(confstr) LOG.debug(_('NexusDriver: %s'), confstr) mgr.edit_config(target='running', config=confstr)
'Creates a VLAN and Enable on trunk mode an interface on Nexus Switch given the VLAN ID and Name and Interface Number'
def create_vlan(self, vlan_name, vlan_id, nexus_host, nexus_user, nexus_password, nexus_ports, nexus_ssh_port, vlan_ids=None):
man = self.nxos_connect(nexus_host, int(nexus_ssh_port), nexus_user, nexus_password) self.enable_vlan(man, vlan_id, vlan_name) if (vlan_ids is ''): vlan_ids = self.build_vlans_cmd() LOG.debug(_('NexusDriver VLAN IDs: %s'), vlan_ids) for ports in nexus_ports: self.enable_vlan...
'Delete a VLAN and Disables trunk mode an interface on Nexus Switch given the VLAN ID and Interface Number'
def delete_vlan(self, vlan_id, nexus_host, nexus_user, nexus_password, nexus_ports, nexus_ssh_port):
man = self.nxos_connect(nexus_host, int(nexus_ssh_port), nexus_user, nexus_password) self.disable_vlan(man, vlan_id) for ports in nexus_ports: self.disable_vlan_on_trunk_int(man, ports, vlan_id)
'Builds a string with all the VLANs on the same Switch'
def build_vlans_cmd(self):
assigned_vlan = cdb.get_all_vlanids_used() vlans = '' for vlanid in assigned_vlan: vlans = ((str(vlanid['vlan_id']) + ',') + vlans) if (vlans == ''): vlans = 'none' return vlans.strip(',')
'Adds a vlan from interfaces on the Nexus switch given the VLAN ID'
def add_vlan_int(self, vlan_id, nexus_host, nexus_user, nexus_password, nexus_ports, nexus_ssh_port, vlan_ids=None):
man = self.nxos_connect(nexus_host, int(nexus_ssh_port), nexus_user, nexus_password) if (not vlan_ids): vlan_ids = self.build_vlans_cmd() for ports in nexus_ports: self.enable_vlan_on_trunk_int(man, ports, vlan_ids)
'Removes a vlan from interfaces on the Nexus switch given the VLAN ID'
def remove_vlan_int(self, vlan_id, nexus_host, nexus_user, nexus_password, nexus_ports, nexus_ssh_port):
man = self.nxos_connect(nexus_host, int(nexus_ssh_port), nexus_user, nexus_password) for ports in nexus_ports: self.disable_vlan_on_trunk_int(man, ports, vlan_id)
'Extracts the configuration parameters from the configuration file'
def __init__(self):
self._client = importutils.import_object(conf.NEXUS_DRIVER) LOG.debug(_('Loaded driver %s'), conf.NEXUS_DRIVER) self._nexus_switches = conf.NEXUS_DETAILS self.credentials = {}
'Returns a dictionary containing all <network_uuid, network_name> for the specified tenant.'
def get_all_networks(self, tenant_id):
LOG.debug(_('NexusPlugin:get_all_networks() called')) return self._networks.values()
'Create a VLAN in the appropriate switch/port, and configure the appropriate interfaces for this VLAN'
def create_network(self, tenant_id, net_name, net_id, vlan_name, vlan_id, host, instance):
LOG.debug(_('NexusPlugin:create_network() called')) switch_ip = '' port_id = '' for switch in self._nexus_switches.keys(): for hostname in self._nexus_switches[switch].keys(): if (str(hostname) == str(host)): switch_ip = switch port_id = self._nexus...
'Deletes the VLAN in all switches, and removes the VLAN configuration from the relevant interfaces'
def delete_network(self, tenant_id, net_id, **kwargs):
LOG.debug(_('NexusPlugin:delete_network() called'))
'Returns the details of a particular network'
def get_network_details(self, tenant_id, net_id, **kwargs):
LOG.debug(_('NexusPlugin:get_network_details() called')) network = self._get_network(tenant_id, net_id) return network
'Updates the properties of a particular Virtual Network.'
def update_network(self, tenant_id, net_id, **kwargs):
LOG.debug(_('NexusPlugin:update_network() called'))
'This is probably not applicable to the Nexus plugin. Delete if not required.'
def get_all_ports(self, tenant_id, net_id, **kwargs):
LOG.debug(_('NexusPlugin:get_all_ports() called'))
'This is probably not applicable to the Nexus plugin. Delete if not required.'
def create_port(self, tenant_id, net_id, port_state, port_id, **kwargs):
LOG.debug(_('NexusPlugin:create_port() called'))
'Delete port bindings from the database and scan whether the network is still required on the interfaces trunked'
def delete_port(self, device_id, vlan_id):
LOG.debug(_('NexusPlugin:delete_port() called')) row = nxos_db.get_nexusvm_binding(vlan_id, device_id) if row: nxos_db.remove_nexusport_binding(row['port_id'], row['vlan_id'], row['switch_ip'], row['instance_id']) bindings = nxos_db.get_nexusvlan_binding(row['vlan_id'], row['switch_ip']) ...
'This is probably not applicable to the Nexus plugin. Delete if not required.'
def update_port(self, tenant_id, net_id, port_id, port_state, **kwargs):
LOG.debug(_('NexusPlugin:update_port() called'))
'This is probably not applicable to the Nexus plugin. Delete if not required.'
def get_port_details(self, tenant_id, net_id, port_id, **kwargs):
LOG.debug(_('NexusPlugin:get_port_details() called'))
'This is probably not applicable to the Nexus plugin. Delete if not required.'
def plug_interface(self, tenant_id, net_id, port_id, remote_interface_id, **kwargs):
LOG.debug(_('NexusPlugin:plug_interface() called'))
'This is probably not applicable to the Nexus plugin. Delete if not required.'
def unplug_interface(self, tenant_id, net_id, port_id, **kwargs):
LOG.debug(_('NexusPlugin:unplug_interface() called'))
'Obtain the VLAN ID given the Network ID'
def _get_vlan_id_for_network(self, tenant_id, network_id, context, base_plugin_ref):
vlan = cdb.get_vlan_binding(network_id) return vlan.vlan_id
'Gets the NETWORK ID'
def _get_network(self, tenant_id, network_id, context, base_plugin_ref):
network = base_plugin_ref._get_network(context, network_id) if (not network): raise exc.NetworkNotFound(net_id=network_id) return {const.NET_ID: network_id, const.NET_NAME: network.name, const.NET_PORTS: network.ports}
'A helper method which retrieves the quotas for the specific resources identified by keys, and which apply to the current context. :param context: The request context, for access checks. :param resources: A dictionary of the registered resources. :param keys: A list of the desired quotas to retrieve.'
def _get_quotas(self, context, resources, keys):
desired = set(keys) sub_resources = dict(((k, v) for (k, v) in resources.items() if (k in desired))) if (len(keys) != len(sub_resources)): unknown = (desired - set(sub_resources.keys())) raise exceptions.QuotaResourceUnknown(unknown=sorted(unknown)) quotas = {} for resource in sub_re...
'Check simple quota limits. For limits--those quotas for which there is no usage synchronization function--this method checks that a set of proposed values are permitted by the limit restriction. This method will raise a QuotaResourceUnknown exception if a given resource is unknown or if it is not a simple limit resour...
def limit_check(self, context, tenant_id, resources, values):
unders = [key for (key, val) in values.items() if (val < 0)] if unders: raise exceptions.InvalidQuotaValue(unders=sorted(unders)) quotas = self._get_quotas(context, resources, values.keys()) overs = [key for (key, val) in values.items() if ((quotas[key] >= 0) and (quotas[key] < val))] if ove...
'Initializes a Resource. :param name: The name of the resource, i.e., "instances". :param flag: The name of the flag or configuration option'
def __init__(self, name, flag):
self.name = name self.flag = flag
'Return the default value of the quota.'
@property def default(self):
return getattr(cfg.CONF.QUOTAS, self.flag, cfg.CONF.QUOTAS.default_quota)
'Initializes a CountableResource. Countable resources are those resources which directly correspond to objects in the database, i.e., netowk, subnet, etc.,. A CountableResource must be constructed with a counting function, which will be called to determine the current counts of the resource. The counting function will...
def __init__(self, name, count, flag=None):
super(CountableResource, self).__init__(name, flag=flag) self.count = count
'Initialize a Quota object.'
def __init__(self, quota_driver_class=None):
if (not quota_driver_class): quota_driver_class = cfg.CONF.QUOTAS.quota_driver if isinstance(quota_driver_class, basestring): quota_driver_class = importutils.import_object(quota_driver_class) self._resources = {} self._driver = quota_driver_class
'Register a resource.'
def register_resource(self, resource):
if (resource.name in self._resources): LOG.warn(_('%s is already registered.'), resource.name) return self._resources[resource.name] = resource
'Register a resource by name.'
def register_resource_by_name(self, resourcename):
resource = CountableResource(resourcename, _count_resource, ('quota_' + resourcename)) self.register_resource(resource)
'Register a list of resources.'
def register_resources(self, resources):
for resource in resources: self.register_resource(resource)
'Count a resource. For countable resources, invokes the count() function and returns its result. Arguments following the context and resource are passed directly to the count function declared by the resource. :param context: The request context, for access checks. :param resource: The name of the resource, as a strin...
def count(self, context, resource, *args, **kwargs):
res = self._resources.get(resource) if ((not res) or (not hasattr(res, 'count'))): raise exceptions.QuotaResourceUnknown(unknown=[resource]) return res.count(context, *args, **kwargs)
'Check simple quota limits. For limits--those quotas for which there is no usage synchronization function--this method checks that a set of proposed values are permitted by the limit restriction. The values to check are given as keyword arguments, where the key identifies the specific quota limit to check, and the val...
def limit_check(self, context, tenant_id, **values):
return self._driver.limit_check(context, tenant_id, self._resources, values)
'Create a subnet, which represents a range of IP addresses that can be allocated to devices : param context: quantum api request context : param subnet: dictionary describing the subnet, with keys as listed in the RESOURCE_ATTRIBUTE_MAP object in quantum/api/v2/attributes.py. All keys will be populated.'
@abstractmethod def create_subnet(self, context, subnet):
pass
'Update values of a subnet. : param context: quantum api request context : param id: UUID representing the subnet to update. : param subnet: dictionary with keys indicating fields to update. valid keys are those that have a value of True for \'allow_put\' as listed in the RESOURCE_ATTRIBUTE_MAP object in quantum/api/v2...
@abstractmethod def update_subnet(self, context, id, subnet):
pass
'Retrieve a subnet. : param context: quantum api request context : param id: UUID representing the subnet to fetch. : param fields: a list of strings that are valid keys in a subnet dictionary as listed in the RESOURCE_ATTRIBUTE_MAP object in quantum/api/v2/attributes.py. Only these fields will be returned.'
@abstractmethod def get_subnet(self, context, id, fields=None):
pass
'Retrieve a list of subnets. The contents of the list depends on the identity of the user making the request (as indicated by the context) as well as any filters. : param context: quantum api request context : param filters: a dictionary with keys that are valid keys for a subnet as listed in the RESOURCE_ATTRIBUTE_MA...
@abstractmethod def get_subnets(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, page_reverse=False):
pass
'Return the number of subnets. The result depends on the identity of the user making the request (as indicated by the context) as well as any filters. : param context: quantum api request context : param filters: a dictionary with keys that are valid keys for a network as listed in the RESOURCE_ATTRIBUTE_MAP object in...
def get_subnets_count(self, context, filters=None):
raise exceptions.NotImplementedError()
'Delete a subnet. : param context: quantum api request context : param id: UUID representing the subnet to delete.'
@abstractmethod def delete_subnet(self, context, id):
pass
'Create a network, which represents an L2 network segment which can have a set of subnets and ports associated with it. : param context: quantum api request context : param network: dictionary describing the network, with keys as listed in the RESOURCE_ATTRIBUTE_MAP object in quantum/api/v2/attributes.py. All keys wil...
@abstractmethod def create_network(self, context, network):
pass
'Update values of a network. : param context: quantum api request context : param id: UUID representing the network to update. : param network: dictionary with keys indicating fields to update. valid keys are those that have a value of True for \'allow_put\' as listed in the RESOURCE_ATTRIBUTE_MAP object in quantum/api...
@abstractmethod def update_network(self, context, id, network):
pass
'Retrieve a network. : param context: quantum api request context : param id: UUID representing the network to fetch. : param fields: a list of strings that are valid keys in a network dictionary as listed in the RESOURCE_ATTRIBUTE_MAP object in quantum/api/v2/attributes.py. Only these fields will be returned.'
@abstractmethod def get_network(self, context, id, fields=None):
pass
'Retrieve a list of networks. The contents of the list depends on the identity of the user making the request (as indicated by the context) as well as any filters. : param context: quantum api request context : param filters: a dictionary with keys that are valid keys for a network as listed in the RESOURCE_ATTRIBUTE_...
@abstractmethod def get_networks(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, page_reverse=False):
pass
'Return the number of networks. The result depends on the identity of the user making the request (as indicated by the context) as well as any filters. : param context: quantum api request context : param filters: a dictionary with keys that are valid keys for a network as listed in the RESOURCE_ATTRIBUTE_MAP object i...
def get_networks_count(self, context, filters=None):
raise exceptions.NotImplementedError()
'Delete a network. : param context: quantum api request context : param id: UUID representing the network to delete.'
@abstractmethod def delete_network(self, context, id):
pass
'Create a port, which is a connection point of a device (e.g., a VM NIC) to attach to a L2 Quantum network. : param context: quantum api request context : param port: dictionary describing the port, with keys as listed in the RESOURCE_ATTRIBUTE_MAP object in quantum/api/v2/attributes.py. All keys will be populated.'
@abstractmethod def create_port(self, context, port):
pass
'Update values of a port. : param context: quantum api request context : param id: UUID representing the port to update. : param port: dictionary with keys indicating fields to update. valid keys are those that have a value of True for \'allow_put\' as listed in the RESOURCE_ATTRIBUTE_MAP object in quantum/api/v2/attri...
@abstractmethod def update_port(self, context, id, port):
pass
'Retrieve a port. : param context: quantum api request context : param id: UUID representing the port to fetch. : param fields: a list of strings that are valid keys in a port dictionary as listed in the RESOURCE_ATTRIBUTE_MAP object in quantum/api/v2/attributes.py. Only these fields will be returned.'
@abstractmethod def get_port(self, context, id, fields=None):
pass
'Retrieve a list of ports. The contents of the list depends on the identity of the user making the request (as indicated by the context) as well as any filters. : param context: quantum api request context : param filters: a dictionary with keys that are valid keys for a port as listed in the RESOURCE_ATTRIBUTE_MAP ob...
@abstractmethod def get_ports(self, context, filters=None, fields=None, sorts=None, limit=None, marker=None, page_reverse=False):
pass
'Return the number of ports. The result depends on the identity of the user making the request (as indicated by the context) as well as any filters. : param context: quantum api request context : param filters: a dictionary with keys that are valid keys for a network as listed in the RESOURCE_ATTRIBUTE_MAP object in q...
def get_ports_count(self, context, filters=None):
raise exceptions.NotImplementedError()
'Delete a port. : param context: quantum api request context : param id: UUID representing the port to delete.'
@abstractmethod def delete_port(self, context, id):
pass
'Run a WSGI server with the given application.'
def start(self, application, port, host='0.0.0.0', backlog=128):
self._host = host self._port = port try: info = socket.getaddrinfo(self._host, self._port, socket.AF_UNSPEC, socket.SOCK_STREAM)[0] family = info[0] bind_addr = info[(-1)] self._socket = eventlet.listen(bind_addr, family=family, backlog=backlog) except: LOG.except...
'Wait until all servers have completed running.'
def wait(self):
try: self.pool.waitall() except KeyboardInterrupt: pass
'Start a WSGI server in a new green thread.'
def _run(self, application, socket):
logger = logging.getLogger('eventlet.wsgi.server') eventlet.wsgi.server(socket, application, custom_pool=self.pool, log=logging.WritableLogger(logger))
'Used for paste app factories in paste.deploy config files. Any local configuration (that is, values under the [filter:APPNAME] section of the paste config) will be passed into the `__init__` method as kwargs. A hypothetical configuration would look like: [filter:analytics] redis_host = 127.0.0.1 paste.filter_factory =...
@classmethod def factory(cls, global_config, **local_config):
def _factory(app): return cls(app, **local_config) return _factory
'Called on each request. If this returns None, the next application down the stack will be executed. If it returns a response then that response will be returned and execution will stop here.'
def process_request(self, req):
return None
'Do whatever you\'d like to the response.'
def process_response(self, response):
return response
'Determine the most acceptable content-type. Based on: 1) URI extension (.json/.xml) 2) Content-type header 3) Accept* headers'
def best_match_content_type(self):
parts = self.path.rsplit('.', 1) if (len(parts) > 1): _format = parts[1] if (_format in ['json', 'xml']): return 'application/{0}'.format(_format) type_from_header = self.get_content_type() if type_from_header: return type_from_header ctypes = ['application/json',...
'Find and call local method.'
def dispatch(self, *args, **kwargs):
action = kwargs.pop('action', 'default') action_method = getattr(self, str(action), self.default) return action_method(*args, **kwargs)