コード例 #1
0
 def test_manage_plugin(self, mock_get_os_install_release):
     mock_get_os_install_release.return_value = ''
     self.assertTrue(nutils.manage_plugin())
     mock_get_os_install_release.return_value = 'ussuri'
     self.assertFalse(nutils.manage_plugin())
     self.test_config.set('manage-neutron-plugin-legacy-mode', True)
     self.assertTrue(nutils.manage_plugin())
     self.test_config.set('manage-neutron-plugin-legacy-mode', False)
     self.assertFalse(nutils.manage_plugin())
     mock_get_os_install_release.return_value = ''
     self.assertFalse(nutils.manage_plugin())
コード例 #2
0
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()
コード例 #3
0
 def test_manage_plugin_false(self):
     self.test_config.set('manage-neutron-plugin-legacy-mode', False)
     manage = nutils.manage_plugin()
     self.assertFalse(manage)
コード例 #4
0
 def test_manage_plugin_false(self):
     self.test_config.set('manage-neutron-plugin-legacy-mode', False)
     manage = nutils.manage_plugin()
     self.assertFalse(manage)