def ovs_ctxt(self): # In addition to generating config context, ensure the OVS service # is running and the OVS bridge exists. Also need to ensure # local_ip points to actual IP, not hostname. ovs_ctxt = super(OVSPluginContext, self).ovs_ctxt() if not ovs_ctxt: return {} conf = config() fallback = get_host_ip(unit_get('private-address')) if config('os-data-network'): # NOTE: prefer any existing use of config based networking ovs_ctxt['local_ip'] = \ get_address_in_network(config('os-data-network'), fallback) else: # NOTE: test out network-spaces support, then fallback try: ovs_ctxt['local_ip'] = get_host_ip( network_get_primary_address('data') ) except NotImplementedError: ovs_ctxt['local_ip'] = fallback neutron_api_settings = NeutronAPIContext()() ovs_ctxt['neutron_security_groups'] = self.neutron_security_groups ovs_ctxt['l2_population'] = neutron_api_settings['l2_population'] ovs_ctxt['distributed_routing'] = neutron_api_settings['enable_dvr'] ovs_ctxt['overlay_network_type'] = \ neutron_api_settings['overlay_network_type'] # TODO: We need to sort out the syslog and debug/verbose options as a # general context helper ovs_ctxt['use_syslog'] = conf['use-syslog'] ovs_ctxt['verbose'] = conf['verbose'] ovs_ctxt['debug'] = conf['debug'] ovs_ctxt['prevent_arp_spoofing'] = conf['prevent-arp-spoofing'] ovs_ctxt['enable_dpdk'] = conf['enable-dpdk'] net_dev_mtu = neutron_api_settings.get('network_device_mtu') if net_dev_mtu: # neutron.conf ovs_ctxt['network_device_mtu'] = net_dev_mtu # ml2 conf ovs_ctxt['veth_mtu'] = net_dev_mtu mappings = config('bridge-mappings') if mappings: ovs_ctxt['bridge_mappings'] = ','.join(mappings.split()) flat_providers = config('flat-network-providers') if flat_providers: ovs_ctxt['network_providers'] = ','.join(flat_providers.split()) vlan_ranges = config('vlan-ranges') if vlan_ranges: ovs_ctxt['vlan_ranges'] = ','.join(vlan_ranges.split()) return ovs_ctxt
def __call__(self): """Return the 'default_availability_zone' from the principal that this ovs unit is attached to (as a subordinate) and the 'dns_domain' from the neutron-plugin-api relations (if one is set). :returns: {} if no relation set, or {'availability_zone': availability_zone from principal relation} """ # as ovs is a subordinate charm, it should only have one relation to # its principal charm. Thus we can take the 1st (only) element in each # list. rids = relation_ids('neutron-plugin') ctxt = {} if rids: rid = rids[0] units = related_units(rid) if units: availability_zone = relation_get( 'default_availability_zone', rid=rid, unit=units[0]) if availability_zone: ctxt['availability_zone'] = availability_zone dnsmasq_flags = config('dnsmasq-flags') if dnsmasq_flags: ctxt['dnsmasq_flags'] = config_flags_parser(dnsmasq_flags) ctxt['dns_servers'] = config('dns-servers') neutron_api_settings = NeutronAPIContext()() if neutron_api_settings.get('dns_domain'): ctxt['dns_domain'] = neutron_api_settings.get('dns_domain') ctxt['instance_mtu'] = config('instance-mtu') return ctxt
def ovs_ctxt(self): # In addition to generating config context, ensure the OVS service # is running and the OVS bridge exists. Also need to ensure # local_ip points to actual IP, not hostname. ovs_ctxt = super(OVSPluginContext, self).ovs_ctxt() if not ovs_ctxt: return {} conf = config() ovs_ctxt['local_ip'] = \ get_address_in_network(config('os-data-network'), get_host_ip(unit_get('private-address'))) neutron_api_settings = NeutronAPIContext()() ovs_ctxt['neutron_security_groups'] = self.neutron_security_groups ovs_ctxt['l2_population'] = neutron_api_settings['l2_population'] ovs_ctxt['distributed_routing'] = neutron_api_settings['enable_dvr'] ovs_ctxt['overlay_network_type'] = \ neutron_api_settings['overlay_network_type'] # TODO: We need to sort out the syslog and debug/verbose options as a # general context helper ovs_ctxt['use_syslog'] = conf['use-syslog'] ovs_ctxt['verbose'] = conf['verbose'] ovs_ctxt['debug'] = conf['debug'] net_dev_mtu = neutron_api_settings.get('network_device_mtu') if net_dev_mtu: # neutron.conf ovs_ctxt['network_device_mtu'] = net_dev_mtu # ml2 conf ovs_ctxt['veth_mtu'] = net_dev_mtu mappings = config('bridge-mappings') if mappings: ovs_ctxt['bridge_mappings'] = ','.join(mappings.split()) flat_providers = config('flat-network-providers') if flat_providers: ovs_ctxt['network_providers'] = ','.join(flat_providers.split()) vlan_ranges = config('vlan-ranges') if vlan_ranges: ovs_ctxt['vlan_ranges'] = ','.join(vlan_ranges.split()) return ovs_ctxt
def ovs_ctxt(self): # In addition to generating config context, ensure the OVS service # is running and the OVS bridge exists. Also need to ensure # local_ip points to actual IP, not hostname. ovs_ctxt = super(OVSPluginContext, self).ovs_ctxt() if not ovs_ctxt: return {} conf = config() fallback = get_host_ip(unit_get('private-address')) if config('os-data-network'): # NOTE: prefer any existing use of config based networking ovs_ctxt['local_ip'] = \ get_address_in_network(config('os-data-network'), fallback) else: # NOTE: test out network-spaces support, then fallback try: ovs_ctxt['local_ip'] = get_host_ip( network_get_primary_address('data') ) except NotImplementedError: ovs_ctxt['local_ip'] = fallback neutron_api_settings = NeutronAPIContext()() ovs_ctxt['neutron_security_groups'] = self.neutron_security_groups ovs_ctxt['l2_population'] = neutron_api_settings['l2_population'] ovs_ctxt['distributed_routing'] = neutron_api_settings['enable_dvr'] ovs_ctxt['extension_drivers'] = neutron_api_settings[ 'extension_drivers'] ovs_ctxt['overlay_network_type'] = \ neutron_api_settings['overlay_network_type'] ovs_ctxt['polling_interval'] = neutron_api_settings['polling_interval'] ovs_ctxt['rpc_response_timeout'] = \ neutron_api_settings['rpc_response_timeout'] ovs_ctxt['report_interval'] = neutron_api_settings['report_interval'] # TODO: We need to sort out the syslog and debug/verbose options as a # general context helper ovs_ctxt['use_syslog'] = conf['use-syslog'] ovs_ctxt['verbose'] = conf['verbose'] ovs_ctxt['debug'] = conf['debug'] cmp_release = CompareOpenStackReleases( os_release('neutron-common', base='icehouse')) if conf['prevent-arp-spoofing'] and cmp_release >= 'ocata': log("prevent-arp-spoofing is True yet this feature is deprecated " "and no longer has any effect in your version of Openstack", WARNING) ovs_ctxt['prevent_arp_spoofing'] = conf['prevent-arp-spoofing'] ovs_ctxt['enable_dpdk'] = conf['enable-dpdk'] net_dev_mtu = neutron_api_settings.get('network_device_mtu') if net_dev_mtu: # neutron.conf ovs_ctxt['network_device_mtu'] = net_dev_mtu # ml2 conf ovs_ctxt['veth_mtu'] = net_dev_mtu mappings = config('bridge-mappings') if mappings: ovs_ctxt['bridge_mappings'] = ','.join(mappings.split()) sriov_mappings = config('sriov-device-mappings') if sriov_mappings: ovs_ctxt['sriov_device_mappings'] = ( ','.join(sriov_mappings.split()) ) enable_sriov = config('enable-sriov') if enable_sriov: ovs_ctxt['enable_sriov'] = True sriov_numvfs = config('sriov-numvfs') if sriov_numvfs: try: if sriov_numvfs != 'auto': int(sriov_numvfs) except ValueError: ovs_ctxt['sriov_vfs_list'] = sriov_numvfs else: ovs_ctxt['sriov_vfs_blanket'] = sriov_numvfs flat_providers = config('flat-network-providers') if flat_providers: ovs_ctxt['network_providers'] = ','.join(flat_providers.split()) vlan_ranges = config('vlan-ranges') if vlan_ranges: ovs_ctxt['vlan_ranges'] = ','.join(vlan_ranges.split()) ovs_ctxt['enable_nsg_logging'] = \ neutron_api_settings['enable_nsg_logging'] ovs_ctxt['nsg_log_output_base'] = get_nsg_log_path( config('security-group-log-output-base') ) ovs_ctxt['nsg_log_rate_limit'] = \ config('security-group-log-rate-limit') ovs_ctxt['nsg_log_burst_limit'] = \ config('security-group-log-burst-limit') ovs_ctxt['firewall_driver'] = _get_firewall_driver(ovs_ctxt) if ovs_ctxt['firewall_driver'] != OPENVSWITCH: ovs_ctxt['enable_nsg_logging'] = False return ovs_ctxt
def ovs_ctxt(self): # In addition to generating config context, ensure the OVS service # is running and the OVS bridge exists. Also need to ensure # local_ip points to actual IP, not hostname. ovs_ctxt = super(OVSPluginContext, self).ovs_ctxt() if not ovs_ctxt: return {} conf = config() fallback = get_host_ip(unit_get('private-address')) if config('os-data-network'): # NOTE: prefer any existing use of config based networking ovs_ctxt['local_ip'] = \ get_address_in_network(config('os-data-network'), fallback) else: # NOTE: test out network-spaces support, then fallback try: ovs_ctxt['local_ip'] = get_host_ip( network_get_primary_address('data')) except NotImplementedError: ovs_ctxt['local_ip'] = fallback neutron_api_settings = NeutronAPIContext()() ovs_ctxt['neutron_security_groups'] = self.neutron_security_groups ovs_ctxt['l2_population'] = neutron_api_settings['l2_population'] ovs_ctxt['distributed_routing'] = neutron_api_settings['enable_dvr'] ovs_ctxt['overlay_network_type'] = \ neutron_api_settings['overlay_network_type'] # TODO: We need to sort out the syslog and debug/verbose options as a # general context helper ovs_ctxt['use_syslog'] = conf['use-syslog'] ovs_ctxt['verbose'] = conf['verbose'] ovs_ctxt['debug'] = conf['debug'] ovs_ctxt['prevent_arp_spoofing'] = conf['prevent-arp-spoofing'] ovs_ctxt['enable_dpdk'] = conf['enable-dpdk'] net_dev_mtu = neutron_api_settings.get('network_device_mtu') if net_dev_mtu: # neutron.conf ovs_ctxt['network_device_mtu'] = net_dev_mtu # ml2 conf ovs_ctxt['veth_mtu'] = net_dev_mtu mappings = config('bridge-mappings') if mappings: ovs_ctxt['bridge_mappings'] = ','.join(mappings.split()) sriov_mappings = config('sriov-device-mappings') if sriov_mappings: ovs_ctxt['sriov_device_mappings'] = (','.join( sriov_mappings.split())) flat_providers = config('flat-network-providers') if flat_providers: ovs_ctxt['network_providers'] = ','.join(flat_providers.split()) vlan_ranges = config('vlan-ranges') if vlan_ranges: ovs_ctxt['vlan_ranges'] = ','.join(vlan_ranges.split()) ovs_ctxt['firewall_driver'] = _get_firewall_driver() return ovs_ctxt
def lb_ctxt(self): # In addition to generating config context, ensure the OVS service # is running and the OVS bridge exists. Also need to ensure # local_ip points to actual IP, not hostname. lb_ctxt = super(LBPluginContext, self).lb_ctxt() if not lb_ctxt: return {} conf = config() fallback = get_host_ip(unit_get('private-address')) if config('os-data-network'): # NOTE: prefer any existing use of config based networking lb_ctxt['local_ip'] = \ get_address_in_network(config('os-data-network'), fallback) else: # NOTE: test out network-spaces support, then fallback try: lb_ctxt['local_ip'] = get_host_ip( network_get_primary_address('data')) except NotImplementedError: lb_ctxt['local_ip'] = fallback neutron_api_settings = NeutronAPIContext()() portmaps = context.DataPortContext()() if not portmaps: log("There are no data-ports defined for this host.", level=ERROR) lb_ctxt['interface_mappings'] = "physnet1:%s" % portmaps.keys()[0] #lb_ctxt['interface_mappings'] = conf['interface-mappings'] lb_ctxt['neutron_security_groups'] = self.neutron_security_groups lb_ctxt['l2_population'] = neutron_api_settings['l2_population'] lb_ctxt['overlay_network_type'] = \ neutron_api_settings['overlay_network_type'] # TODO: We need to sort out the syslog and debug/verbose options as a # general context helper lb_ctxt['use_syslog'] = conf['use-syslog'] lb_ctxt['verbose'] = conf['verbose'] lb_ctxt['debug'] = conf['debug'] lb_ctxt['prevent_arp_spoofing'] = conf['prevent-arp-spoofing'] lb_ctxt['enable_vxlan'] = conf['enable-vxlan'] lb_ctxt['enable_dpdk'] = conf['enable-dpdk'] net_dev_mtu = neutron_api_settings.get('network_device_mtu') if net_dev_mtu: # neutron.conf lb_ctxt['network_device_mtu'] = net_dev_mtu # ml2 conf lb_ctxt['veth_mtu'] = net_dev_mtu mappings = config('bridge-mappings') if mappings: lb_ctxt['bridge_mappings'] = ','.join(mappings.split()) flat_providers = config('flat-network-providers') if flat_providers: lb_ctxt['network_providers'] = ','.join(flat_providers.split()) vlan_ranges = config('vlan-ranges') if vlan_ranges: lb_ctxt['vlan_ranges'] = ','.join(vlan_ranges.split()) return lb_ctxt