def test_resource_map_metadata(self, net_man, _plugin, _metadata):
     _metadata.return_value = (True, None)
     net_man.return_value = 'bob'
     _plugin.return_value = 'ovs'
     self.relation_ids.return_value = []
     result = utils.resource_map()['/etc/nova/nova.conf']['services']
     self.assertTrue('nova-api-metadata' in result)
    def test_resource_map_nova_network(self, net_man, en_meta):

        en_meta.return_value = (False, None)
        self.test_config.set('multi-host', 'yes')
        net_man.return_value = 'flatdhcpmanager'
        result = utils.resource_map()

        ex = {
            '/etc/default/libvirt-bin': {
                'contexts': [],
                'services': ['libvirt-bin']
            },
            '/etc/libvirt/qemu.conf': {
                'contexts': [],
                'services': ['libvirt-bin']
            },
            '/etc/nova/nova.conf': {
                'contexts': [],
                'services': ['nova-compute', 'nova-api', 'nova-network']
            },
            '/etc/ceph/secret.xml': {
                'contexts': [],
                'services': []
            },
            '/var/lib/charm/nova_compute/ceph.conf': {
                'contexts': [],
                'services': ['nova-compute']
            },
            '/etc/default/qemu-kvm': {
                'contexts': [],
                'services': ['qemu-kvm']
            },
            '/etc/init/libvirt-bin.override': {
                'contexts': [],
                'services': ['libvirt-bin']
            },
            '/etc/libvirt/libvirtd.conf': {
                'contexts': [],
                'services': ['libvirt-bin']
            },
            '/etc/apparmor.d/usr.bin.nova-network': {
                'contexts': [],
                'services': ['nova-network']
            },
            '/etc/apparmor.d/usr.bin.nova-compute': {
                'contexts': [],
                'services': ['nova-compute']
            },
            '/etc/apparmor.d/usr.bin.nova-api': {
                'contexts': [],
                'services': ['nova-api']
            },
        }
        # Mocking contexts is tricky but we can still test that
        # the correct files are monitored and the correct services
        # will be started
        self.assertEquals(set(ex.keys()), set(result.keys()))
        for k in ex.keys():
            self.assertEquals(set(ex[k]['services']),
                              set(result[k]['services']))
    def test_resource_map_quantum_ovs(self, net_man, _plugin):
        self.skipTest('skipped until contexts are properly mocked.')
        net_man.return_value = 'Quantum'
        _plugin.return_value = 'ovs'
        result = utils.resource_map()
        ex = {
            '/etc/default/libvirt-bin': {
                'contexts': [],
                'services': ['libvirt-bin']
            },
            '/etc/libvirt/qemu.conf': {
                'contexts': [],
                'services': ['libvirt-bin']
            },
            '/etc/nova/nova-compute.conf': {
                'contexts': [],
                'services': ['nova-compute']
            },
            '/etc/nova/nova.conf': {
                'contexts': [],
                'services': ['nova-compute']
            },
            '/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini': {
                'contexts': [],
                'services': ['quantum-plugin-openvswitch-agent']
            },
            '/etc/quantum/quantum.conf': {
                'contexts': [],
                'services': ['quantum-plugin-openvswitch-agent']}
        }

        self.assertEquals(ex, result)
Example #4
0
 def test_resource_map_ironic(self, _metadata):
     _metadata.return_value = (True, None)
     self.relation_ids.return_value = []
     self.os_release.return_value = 'victoria'
     self.test_config.set('virt-type', 'ironic')
     result = utils.resource_map()
     self.assertTrue(utils.NOVA_COMPUTE_CONF not in result)
 def test_resource_map_neutron_ovs_plugin(self, net_man, _plugin):
     self.skipTest('skipped until contexts are properly mocked.')
     self.is_relation_made = True
     net_man.return_value = 'Neutron'
     _plugin.return_value = 'ovs'
     result = utils.resource_map()
     self.assertTrue('/etc/neutron/neutron.conf' not in result)
Example #6
0
 def test_resource_map_ironic_pre_victoria(self, _metadata):
     _metadata.return_value = (True, None)
     self.relation_ids.return_value = []
     self.os_release.return_value = 'train'
     self.test_config.set('virt-type', 'ironic')
     result = utils.resource_map()
     self.assertTrue(utils.NOVA_COMPUTE_CONF in result)
     self.assertEqual(result[utils.NOVA_COMPUTE_CONF]["services"],
                      ["nova-compute"])
     self.assertEqual(result[utils.NOVA_COMPUTE_CONF]["contexts"], [])
 def test_resource_map_nova_network_no_multihost(self, net_man, en_meta,
                                                 _os):
     self.os_release.return_value = 'icehouse'
     self.test_config.set('multi-host', 'no')
     en_meta.return_value = (False, None)
     net_man.return_value = 'flatdhcpmanager'
     _os.path.exists.return_value = True
     result = utils.resource_map()
     ex = {
         '/etc/default/libvirt-bin': {
             'contexts': [],
             'services': ['libvirt-bin']
         },
         '/etc/libvirt/qemu.conf': {
             'contexts': [],
             'services': ['libvirt-bin']
         },
         '/etc/nova/nova.conf': {
             'contexts': [],
             'services': ['nova-compute']
         },
         '/etc/ceph/secret.xml': {
             'contexts': [],
             'services': []
         },
         '/var/lib/charm/nova_compute/ceph.conf': {
             'contexts': [],
             'services': ['nova-compute']
         },
         '/etc/default/qemu-kvm': {
             'contexts': [],
             'services': ['qemu-kvm']
         },
         '/etc/init/libvirt-bin.override': {
             'contexts': [],
             'services': ['libvirt-bin']
         },
         '/etc/libvirt/libvirtd.conf': {
             'contexts': [],
             'services': ['libvirt-bin']
         },
         '/etc/apparmor.d/usr.bin.nova-compute': {
             'contexts': [],
             'services': ['nova-compute']
         },
     }
     # Mocking contexts is tricky but we can still test that
     # the correct files are monitored and the correct services
     # will be started
     self.assertEqual(set(ex.keys()), set(result.keys()))
     for k in ex.keys():
         self.assertEqual(set(ex[k]['services']),
                          set(result[k]['services']))
    def _test_resource_map_neutron(self, net_man, en_meta,
                                   libvirt_daemon):
        en_meta.return_value = (False, None)
        self.test_config.set('multi-host', 'yes')
        net_man.return_value = 'neutron'
        result = utils.resource_map()

        ex = {
            '/etc/default/libvirt-bin': {
                'contexts': [],
                'services': [libvirt_daemon]
            },
            '/etc/libvirt/qemu.conf': {
                'contexts': [],
                'services': [libvirt_daemon]
            },
            '/etc/nova/nova.conf': {
                'contexts': [],
                'services': ['nova-compute']
            },
            '/etc/ceph/secret.xml': {
                'contexts': [],
                'services': []
            },
            '/var/lib/charm/nova_compute/ceph.conf': {
                'contexts': [],
                'services': ['nova-compute']
            },
            '/etc/default/qemu-kvm': {
                'contexts': [],
                'services': ['qemu-kvm']
            },
            '/etc/init/libvirt-bin.override': {
                'contexts': [],
                'services': [libvirt_daemon]
            },
            '/etc/libvirt/libvirtd.conf': {
                'contexts': [],
                'services': [libvirt_daemon]
            },
            '/etc/apparmor.d/usr.bin.nova-compute': {
                'contexts': [],
                'services': ['nova-compute']
            },
        }
        # Mocking contexts is tricky but we can still test that
        # the correct files are monitored and the correct services
        # will be started
        self.assertEqual(set(ex.keys()), set(result.keys()))
        for k in ex.keys():
            self.assertEqual(set(ex[k]['services']),
                             set(result[k]['services']))
Example #9
0
 def test_resource_map_nova_network_ocata(self, net_man, en_meta, _os):
     self.os_release.return_value = 'ocata'
     self.test_config.set('multi-host', 'yes')
     en_meta.return_value = (False, None)
     net_man.return_value = 'flatdhcpmanager'
     _os.path.exists.return_value = False
     result = utils.resource_map()
     ex = {
         '/etc/default/libvirt-bin': {
             'contexts': [],
             'services': ['libvirtd']
         },
         '/etc/libvirt/qemu.conf': {
             'contexts': [],
             'services': ['libvirtd']
         },
         '/etc/nova/nova.conf': {
             'contexts': [],
             'services': ['nova-compute']
         },
         '/etc/nova/vendor_data.json': {
             'contexts': [],
             'services': []
         },
         '/etc/ceph/secret.xml': {
             'contexts': [],
             'services': []
         },
         '/var/lib/charm/nova_compute/ceph.conf': {
             'contexts': [],
             'services': ['nova-compute']
         },
         '/etc/default/qemu-kvm': {
             'contexts': [],
             'services': ['qemu-kvm']
         },
         '/etc/libvirt/libvirtd.conf': {
             'contexts': [],
             'services': ['libvirtd']
         },
         '/etc/apparmor.d/usr.bin.nova-compute': {
             'contexts': [],
             'services': ['nova-compute']
         },
     }
     # Mocking contexts is tricky but we can still test that
     # the correct files are monitored and the correct services
     # will be started
     self.assertEqual(set(ex.keys()), set(result.keys()))
     for k in ex.keys():
         self.assertEqual(set(ex[k]['services']),
                          set(result[k]['services']))
    def test_resource_map_nova_network(self, net_man):

        self.skipTest('skipped until contexts are properly mocked')
        net_man.return_value = 'FlatDHCPManager'
        result = utils.resource_map()
        ex = {
            '/etc/default/libvirt-bin': {
                'contexts': [], 'services': ['libvirt-bin']
            },
            '/etc/libvirt/qemu.conf': {
                'contexts': [],
                'services': ['libvirt-bin']
            },
            '/etc/nova/nova-compute.conf': {
                'contexts': [],
                'services': ['nova-compute']
            },
            '/etc/nova/nova.conf': {
                'contexts': [],
                'services': ['nova-compute', 'nova-api', 'nova-network']
            }
        }
        self.assertEquals(ex, result)