def main(): opts = [ cfg.StrOpt('network_id', help=_('Network that will have instance metadata ' 'proxied.')), cfg.StrOpt('router_id', help=_('Router that will have connected instances\' ' 'metadata proxied.')), cfg.StrOpt('domain_id', help=_('L3 domain that will have connected instances\' ' 'metadata proxied.')), cfg.StrOpt('pid_file', help=_('Location of pid file of this process.')), cfg.BoolOpt('daemonize', default=False, help=_('Run as daemon.')), cfg.StrOpt('metadata_host', default="0.0.0.0", help=_("IP address to listen for metadata server " "requests.")), cfg.IntOpt('metadata_port', default=9697, help=_("TCP Port to listen for metadata server " "requests.")), cfg.StrOpt('metadata_proxy_socket', default='$state_path/metadata_proxy', help=_('Location of Metadata Proxy UNIX domain ' 'socket')), cfg.StrOpt('metadata_proxy_user', default=None, help=_("User (uid or name) running metadata proxy after " "its initialization")), cfg.StrOpt('metadata_proxy_group', default=None, help=_("Group (gid or name) running metadata proxy after " "its initialization")), ] cfg.CONF.register_cli_opts(opts) # Don't get the default configuration file cfg.CONF(project='neutron', default_config_files=[]) config.setup_logging() utils.log_opt_values(LOG) proxy = ProxyDaemon(cfg.CONF.pid_file, cfg.CONF.metadata_port, network_id=cfg.CONF.network_id, router_id=cfg.CONF.router_id, domain_id=cfg.CONF.domain_id, user=cfg.CONF.metadata_proxy_user, group=cfg.CONF.metadata_proxy_group, host=cfg.CONF.metadata_host) if cfg.CONF.daemonize: proxy.start() else: proxy.run()
def _proxy_request(self, remote_address, method, path_info, query_string, body): headers = { 'X-Forwarded-For': remote_address, } if self.domain_id: network_id = self.get_network_id(self.domain_id, remote_address) if network_id: headers['X-Neutron-Network-ID'] = network_id else: return webob.exc.HTTPNotFound() elif self.router_id: headers['X-Neutron-Router-ID'] = self.router_id else: headers['X-Neutron-Network-ID'] = self.network_id url = urlparse.urlunsplit(( 'http', '169.254.169.254', # a dummy value to make the request proper path_info, query_string, '')) h = httplib2.Http() resp, content = h.request( url, method=method, headers=headers, body=body, connection_type=agent_utils.UnixDomainHTTPConnection) if resp.status == 200: LOG.debug(resp) LOG.debug(content) response = webob.Response() response.status = resp.status response.headers['Content-Type'] = resp['content-type'] response.body = content return response elif resp.status == 400: return webob.exc.HTTPBadRequest() elif resp.status == 404: return webob.exc.HTTPNotFound() elif resp.status == 409: return webob.exc.HTTPConflict() elif resp.status == 500: msg = _( 'Remote metadata server experienced an internal server error.') LOG.debug(msg) return webob.exc.HTTPInternalServerError( explanation=six.text_type(msg)) else: raise Exception(_('Unexpected response code: %s') % resp.status)
def validate_provider_segment(self, segment): physical_network = segment.get(api.PHYSICAL_NETWORK) if not physical_network: msg = _("physical_network required for opflex provider network") raise exc.InvalidInput(error_message=msg) for key, value in segment.items(): if value and key not in [ api.NETWORK_TYPE, api.PHYSICAL_NETWORK, api.MTU ]: msg = _("%s prohibited for opflex provider network") % key raise exc.InvalidInput(error_message=msg)
def __init__(self, network_id=None, router_id=None, domain_id=None): self.network_id = network_id self.router_id = router_id self.domain_id = domain_id if network_id is None and router_id is None and domain_id is None: msg = _('network_id, router_id, and domain_id are None. ' 'One of them must be provided.') raise ValueError(msg)
def __call__(self, req): LOG.debug("Request: %s", req) try: return self._proxy_request(req.remote_addr, req.method, req.path_info, req.query_string, req.body) except Exception: LOG.exception("Unexpected error.") msg = _('An unknown error has occurred. ' 'Please try your request again.') return webob.exc.HTTPInternalServerError( explanation=six.text_type(msg))
def initialize(self, host, conf, agent_state): ovs_config = conf.OVS try: bridge_mappings = helpers.parse_mappings( ovs_config.bridge_mappings) except ValueError as e: raise ValueError(_("Parsing bridge_mappings failed: %s.") % e) self.int_br_device_count = 0 self.int_br = ovs_lib.OVSBridge(ovs_config.integration_bridge, ovs_config.datapath_type) self.fabric_br = ovs_lib.OVSBridge(conf.OPFLEX.fabric_bridge, ovs_config.datapath_type) self.local_ip = ovs_config.local_ip self.setup_integration_bridge() agent_state['agent_type'] = ofcst.AGENT_TYPE_OPFLEX_OVS if 'configurations' not in agent_state: agent_state['configurations'] = {} agent_state['configurations']['bridge_mappings'] = bridge_mappings agent_state['configurations']['datapath_type'] = ( ovs_config.datapath_type) agent_state['configurations']['vhostuser_socket_dir'] = ( ovs_config.vhostuser_socket_dir) return self, agent_state
from neutron.plugins.ml2.drivers import helpers from neutron_lib import exceptions as exc from neutron_lib.plugins.ml2 import api from oslo_config import cfg from oslo_log import log as logging from opflexagent._i18n import _ from opflexagent import constants LOG = logging.getLogger(__name__) flat_opts = [ cfg.StrOpt('default_opflex_network', default='physnet1', help=_("Default opflex network for tenants.")) ] cfg.CONF.register_opts(flat_opts, "ml2_type_opflex") class OpflexTypeDriver(helpers.BaseTypeDriver): def __init__(self): LOG.info("ML2 OpflexTypeDriver initialization complete") self.default_opflex_network = ( cfg.CONF.ml2_type_opflex.default_opflex_network) super(OpflexTypeDriver, self).__init__() def get_type(self): return constants.TYPE_OPFLEX
class DeviceListRetrievalError(exceptions.NeutronException): message = _("Unable to retrieve port details for devices: %(devices)s ")
config as ovs_config) from neutron_lib.utils import helpers from oslo_config import cfg from oslo_log import log as logging from oslo_utils import encodeutils from opflexagent._i18n import _ from opflexagent import config as oscfg # noqa from opflexagent.utils import utils as opflexagent_utils LOG = logging.getLogger(__name__) gbp_opts = [ cfg.StrOpt('epg_mapping_dir', default='/var/lib/opflex-agent-ovs/endpoints/', help=_("Directory where the EPG port mappings will be " "stored.")), cfg.StrOpt('as_mapping_dir', default='/var/lib/opflex-agent-ovs/services/', help=_("Directory where the anycast svc mappings will be " "stored.")), cfg.StrOpt('opflex_agent_dir', default='/var/lib/neutron/opflex_agent', help=_("Directory where the opflex agent state will be " "stored.")), ] EP_FILE_EXTENSION = "ep" AS_FILE_EXTENSION = "as" AS_FILE_NAME_FORMAT = "%s." + AS_FILE_EXTENSION AS_MAPPING_DIR = "/var/lib/opflex-agent-ovs/services" EOQ = 'STOP'
# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from oslo_config import cfg from opflexagent._i18n import _ gbp_opts = [ cfg.StrOpt('epg_mapping_dir', default='/var/lib/opflex-agent-ovs/endpoints/', help=_("Directory where the EPG port mappings will be " "stored.")), cfg.StrOpt('as_mapping_dir', default='/var/lib/opflex-agent-ovs/services/', help=_("Directory where the anycast svc mappings will be " "stored.")), cfg.StrOpt('opflex_agent_dir', default='/var/lib/neutron/opflex_agent', help=_("Directory where the opflex agent state will be " "stored.")), cfg.ListOpt('opflex_networks', default=['*'], help=_("List of the physical networks managed by this agent. " "Use * for binding any opflex network to this agent")), cfg.ListOpt('vlan_networks', default=['*'], help=_("List of the physical networks managed by this agent. "
class MissingPortProfile(osv_exception.ExceptionBase): msg_fmt = _('A port profile is mandatory for the OpenVSwitch plugin')
class AgentError(osv_exception.ExceptionBase): msg_fmt = _('Error during following call to agent: %(method)s')
'topology/pod-(\d+)/paths-(\d+)/pathep-\[eth(\d+)/(\d+(\/\d+)*)\]', ] ACI_PORT_LOCAL_FORMAT = 'Eth(\d+)/(\d+(\/\d+)*)' ACI_VPCPORT_DESCR_FORMAT = ('topology/pod-(\d+)/protpaths-(\d+)-(\d+)/pathep-' '\[(.*)\]') AGENT_FORCE_UPDATE_COUNT = 5 BINARY_APIC_HOST_AGENT = 'neutron-cisco-apic-host-agent' TYPE_APIC_HOST_AGENT = 'cisco-apic-host-agent' LOG = logging.getLogger(__name__) apic_opts = [ cfg.ListOpt('apic_host_uplink_ports', default=[], help=_('The uplink ports to check for ACI connectivity')), cfg.FloatOpt('apic_agent_poll_interval', default=60, help=_('Interval between agent poll for topology (in sec)')), cfg.FloatOpt('apic_agent_report_interval', default=60, help=_('Interval between agent status updates (in sec)')), ] cfg.CONF.register_opts(apic_opts, "apic_host_agent") class ApicTopologyAgent(manager.Manager): def __init__(self, host=None): if host is None: host = net_utils.get_hostname()
class PciDeviceNotFoundById(osv_exception.ExceptionBase): msg_fmt = _("PCI device %(id)s not found")
class RepresentorNotFound(osv_exception.ExceptionBase): msg_fmt = _('Failed getting representor port for PF %(ifname)s with ' '%(vf_num)s')
class UnsupportedPlatform(osv_exception.ExceptionBase): msg_fmt = _('VPP vhostuser interface is not supported on this platform')
class WrongPortProfile(osv_exception.ExceptionBase): msg_fmt = _('Port profile %(profile)s is not a subclass ' 'of VIFPortProfileOpenVSwitch')