def neutron_api_relation_joined(rid=None): base_url = canonical_url(CONFIGS, INTERNAL) neutron_url = '%s:%s' % (base_url, api_port('neutron-server')) relation_data = { 'enable-sriov': config('enable-sriov'), 'neutron-url': neutron_url, 'neutron-plugin': config('neutron-plugin'), } if config('neutron-security-groups'): relation_data['neutron-security-groups'] = "yes" else: relation_data['neutron-security-groups'] = "no" if is_api_ready(CONFIGS): relation_data['neutron-api-ready'] = "yes" else: relation_data['neutron-api-ready'] = "no" # LP Bug#1805645 dns_domain = get_dns_domain() if dns_domain: relation_data['dns-domain'] = dns_domain relation_set(relation_id=rid, **relation_data) # Nova-cc may have grabbed the neutron endpoint so kick identity-service # relation to register that its here for r_id in relation_ids('identity-service'): identity_joined(rid=r_id, relation_trigger=True)
def _test_is_api_ready(self, tgt): fake_config = MagicMock() with patch.object(nutils, 'incomplete_relation_data') as ird: ird.return_value = (not tgt) self.assertEqual(nutils.is_api_ready(fake_config), tgt) ird.assert_called_with( fake_config, nutils.REQUIRED_INTERFACES)
def neutron_plugin_api_relation_joined(rid=None): if config('neutron-plugin') == 'nsx': relation_data = { 'nsx-username': config('nsx-username'), 'nsx-password': config('nsx-password'), 'nsx-cluster-name': config('nsx-cluster-name'), 'nsx-tz-uuid': config('nsx-tz-uuid'), 'nsx-l3-uuid': config('nsx-l3-uuid'), 'nsx-controllers': config('nsx-controllers'), } else: relation_data = { 'neutron-security-groups': config('neutron-security-groups'), 'l2-population': get_l2population(), 'enable-dvr': get_dvr(), 'enable-l3ha': get_l3ha(), 'overlay-network-type': get_overlay_network_type(), 'addr': unit_get('private-address'), } # Provide this value to relations since it needs to be set in multiple # places e.g. neutron.conf, nova.conf net_dev_mtu = config('network-device-mtu') if net_dev_mtu: relation_data['network-device-mtu'] = net_dev_mtu identity_ctxt = IdentityServiceContext()() if not identity_ctxt: identity_ctxt = {} relation_data.update({ 'auth_host': identity_ctxt.get('auth_host'), 'auth_port': identity_ctxt.get('auth_port'), 'auth_protocol': identity_ctxt.get('auth_protocol'), 'service_protocol': identity_ctxt.get('service_protocol'), 'service_host': identity_ctxt.get('service_host'), 'service_port': identity_ctxt.get('service_port'), 'service_tenant': identity_ctxt.get('admin_tenant_name'), 'service_username': identity_ctxt.get('admin_user'), 'service_password': identity_ctxt.get('admin_password'), 'region': config('region'), }) if is_api_ready(CONFIGS): relation_data['neutron-api-ready'] = "yes" else: relation_data['neutron-api-ready'] = "no" relation_set(relation_id=rid, **relation_data)
def neutron_plugin_api_relation_joined(rid=None): if config('neutron-plugin') == 'nsx': relation_data = { 'nsx-username': config('nsx-username'), 'nsx-password': config('nsx-password'), 'nsx-cluster-name': config('nsx-cluster-name'), 'nsx-tz-uuid': config('nsx-tz-uuid'), 'nsx-l3-uuid': config('nsx-l3-uuid'), 'nsx-controllers': config('nsx-controllers'), } else: relation_data = { 'neutron-security-groups': config('neutron-security-groups'), 'l2-population': get_l2population(), 'enable-dvr': get_dvr(), 'enable-l3ha': get_l3ha(), 'enable-qos': is_qos_requested_and_valid(), 'enable-vlan-trunking': is_vlan_trunking_requested_and_valid(), 'enable-nsg-logging': is_nsg_logging_enabled(), 'overlay-network-type': get_overlay_network_type(), 'addr': unit_get('private-address'), 'polling-interval': config('polling-interval'), 'rpc-response-timeout': config('rpc-response-timeout'), 'report-interval': config('report-interval'), } # Provide this value to relations since it needs to be set in multiple # places e.g. neutron.conf, nova.conf net_dev_mtu = config('network-device-mtu') if net_dev_mtu: relation_data['network-device-mtu'] = net_dev_mtu identity_ctxt = IdentityServiceContext()() if not identity_ctxt: identity_ctxt = {} relation_data.update({ 'auth_host': identity_ctxt.get('auth_host'), 'auth_port': identity_ctxt.get('auth_port'), 'auth_protocol': identity_ctxt.get('auth_protocol'), 'service_protocol': identity_ctxt.get('service_protocol'), 'service_host': identity_ctxt.get('service_host'), 'service_port': identity_ctxt.get('service_port'), 'service_tenant': identity_ctxt.get('admin_tenant_name'), 'service_username': identity_ctxt.get('admin_user'), 'service_password': identity_ctxt.get('admin_password'), 'region': config('region'), }) dns_domain = get_dns_domain() if dns_domain: relation_data['dns-domain'] = dns_domain if is_api_ready(CONFIGS): relation_data['neutron-api-ready'] = "yes" else: relation_data['neutron-api-ready'] = "no" relation_set(relation_id=rid, **relation_data)
def neutron_plugin_api_subordinate_relation_joined(relid=None): ''' -changed handles relation data set by a subordinate. ''' relation_data = {'neutron-api-ready': 'no'} if is_api_ready(CONFIGS): relation_data['neutron-api-ready'] = "yes" relation_set(relation_id=relid, **relation_data) # there is no race condition with the neutron service restart # as juju propagates the changes done in relation_set only after # the hook exists CONFIGS.write(API_PASTE_INI)
def neutron_plugin_api_subordinate_relation_joined(relid=None): relation_data = {} if is_db_initialised(): db_migration_key = 'migrate-database-nonce' if not relid: relid = relation_id() leader_key = '{}-{}'.format(db_migration_key, relid) for unit in related_units(relid): nonce = relation_get(db_migration_key, rid=relid, unit=unit) if nonce: if is_leader() and leader_get(leader_key) != nonce: migrate_neutron_database(upgrade=True) # track nonce in leader storage to avoid superfluous # migrations leader_set({leader_key: nonce}) # set nonce back on relation to signal completion to other end # we do this regardless of leadership status so that # subordinates connected to non-leader units can proceed. relation_data[db_migration_key] = nonce relation_data['neutron-api-ready'] = 'no' if is_api_ready(CONFIGS): relation_data['neutron-api-ready'] = 'yes' if not manage_plugin(): neutron_cc_ctxt = NeutronCCContext()() plugin_instance = NeutronApiSDNContext() neutron_config_data = { k: v for k, v in neutron_cc_ctxt.items() if plugin_instance.is_allowed(k) } if neutron_config_data: relation_data['neutron_config_data'] = json.dumps( neutron_config_data) relation_set(relation_id=relid, **relation_data) # there is no race condition with the neutron service restart # as juju propagates the changes done in relation_set only after # the hook exists CONFIGS.write_all()
def neutron_plugin_api_subordinate_relation_joined(relid=None): relation_data = {'neutron-api-ready': 'no'} if is_api_ready(CONFIGS): relation_data['neutron-api-ready'] = "yes" relation_set(relation_id=relid, **relation_data)
def neutron_load_balancer_relation_joined(rid=None): relation_data = {} relation_data['neutron-api-ready'] = is_api_ready(CONFIGS) relation_set(relation_id=rid, **relation_data)
def neutron_plugin_api_relation_joined(rid=None): if config('neutron-plugin') == 'nsx': relation_data = { 'nsx-username': config('nsx-username'), 'nsx-password': config('nsx-password'), 'nsx-cluster-name': config('nsx-cluster-name'), 'nsx-tz-uuid': config('nsx-tz-uuid'), 'nsx-l3-uuid': config('nsx-l3-uuid'), 'nsx-controllers': config('nsx-controllers'), } else: relation_data = { 'neutron-security-groups': config('neutron-security-groups'), 'l2-population': get_l2population(), 'enable-dvr': get_dvr(), 'enable-l3ha': get_l3ha(), 'enable-qos': is_qos_requested_and_valid(), 'enable-vlan-trunking': is_vlan_trunking_requested_and_valid(), 'enable-nsg-logging': is_nsg_logging_enabled(), 'enable-nfg-logging': is_nfg_logging_enabled(), 'overlay-network-type': get_overlay_network_type(), 'addr': unit_get('private-address'), 'polling-interval': config('polling-interval'), 'rpc-response-timeout': config('rpc-response-timeout'), 'report-interval': config('report-interval'), 'global-physnet-mtu': config('global-physnet-mtu'), 'physical-network-mtus': config('physical-network-mtus'), } # Provide this value to relations since it needs to be set in multiple # places e.g. neutron.conf, nova.conf net_dev_mtu = config('network-device-mtu') if net_dev_mtu: relation_data['network-device-mtu'] = net_dev_mtu identity_ctxt = IdentityServiceContext()() if not identity_ctxt: identity_ctxt = {} relation_data.update({ 'auth_host': identity_ctxt.get('auth_host'), 'auth_port': identity_ctxt.get('auth_port'), 'auth_protocol': identity_ctxt.get('auth_protocol'), 'service_protocol': identity_ctxt.get('service_protocol'), 'service_host': identity_ctxt.get('service_host'), 'service_port': identity_ctxt.get('service_port'), 'service_tenant': identity_ctxt.get('admin_tenant_name'), 'service_username': identity_ctxt.get('admin_user'), 'service_password': identity_ctxt.get('admin_password'), 'region': config('region'), }) dns_domain = get_dns_domain() if dns_domain: relation_data['dns-domain'] = dns_domain if is_api_ready(CONFIGS): relation_data['neutron-api-ready'] = "yes" else: relation_data['neutron-api-ready'] = "no" relation_set(relation_id=rid, **relation_data)