Ejemplo n.º 1
0
 def test_crud(self):
     cluster = Cluster.instance()
     node = Node(hostname='testhost')
     cluster.store(node)
     on_report(IFConfigReport.create(node.oid, raw_data=IFCONFIG_DATA))
     network = Network(title='TestNetwork')
     virbr2 = node.get_host_nic('virbr2')
     network.add_host_nic(virbr2)
     self.assertTrue(virbr2.oid in network.host_nics)
     eth2 = node.get_host_nic('eth2')
     self.assertEqual(len(network.host_nics), 1)
     self.assertFalse(eth2.oid in network.host_nics) # only bridge should be added
Ejemplo n.º 2
0
 def on_mngr_msg(client, body, routing_key):
     report = Entity.from_json(body)
     on_report(report)
     self.assertEqual(report.reporter_oid, self.node_oid)
     if report.__class__.__name__ == 'NodeOnlineReport':
         on_report(IFConfigReport.create(self.node_oid, 
                                         raw_data=IFCONFIG_DATA))
         client.send_task(VMInventoryTask(node_oid=self.node_oid))
     if report.__class__.__name__ == 'VmXMLReport':
         cluster = Cluster.instance()
         vm_config = cluster.entities_by_class('VmConfig')[0]
         self.assertEqual(vm_config.oid, 'c2127a40-eb4c-4e3c-af5b-ab455fd8bb40')
         self.stop()
Ejemplo n.º 3
0
 def test_report_arrived(self):
     node_oid = str(uuid.uuid1())
     on_report(NodeOnlineReport.create(node_oid, hostname='testhost'))
     on_report(IFConfigReport.create(node_oid, raw_data=IFCONFIG_DATA))
     on_report(BrctlShowReport.create(node_oid, raw_data=BRCTL_SHOW_DATA))
     cluster = Cluster.instance()
     node = cluster.get(node_oid)
     self.assertTrue(node)
     eth2 = node.get_host_nic('eth2')
     self.assertTrue(eth2)
     self.assertEqual(eth2.in_bridge, 'virbr2')
     virbr2 = node.get_host_nic('virbr2')
     self.assertEqual(virbr2.bridge_for,
                      ['eth2', 'vnet0', 'vnet1'])
Ejemplo n.º 4
0
        def on_mngr_msg(client, body, routing_key):
            inst = self.entity_from_json(body)
            default_callback(client, body, routing_key)

            if isinstance(inst, NodeOnlineReport):
                self.node.publish_report(
                    IFConfigReport.create(self.node_oid, raw_data=RAW_DATA))

            if isinstance(inst, IFConfigReport):
                self.assertEqual(inst.raw_data, RAW_DATA)
                cluster = Cluster.instance()
                node = cluster.get(self.node_oid)
                self.assertTrue(node)
                self.assertEqual(node.get_host_nic('eth1').inet_addr,
                                 '10.0.1.1')
                self.assertEqual(node.get_host_nic('vnet0').rx_bytes,
                                 11546476)
                self.stop()
Ejemplo n.º 5
0
def load_fixtures(node_oid):
    "Load demo data for development"
    from swarm.scenarios import on_report
    from swarm.tests import fixtures
    from swarm.reports import (NodeOnlineReport, VmXMLReport, IFConfigReport,
                               BrctlShowReport, DFReport)
    log.debug('Loading test data')
    storage_oid = str(uuid.uuid4())
    on_report(NodeOnlineReport.create(node_oid,
                                      hostname='testhost',
                                      storages = [dict(
                    storage_oid=storage_oid, path='/home/vgdcloud/storage1')]))
                    
    on_report(IFConfigReport.create(node_oid,
                                    raw_data=fixtures.IFCONFIG_DATA))
    on_report(BrctlShowReport.create(node_oid,
                                     raw_data=fixtures.BRCTL_SHOW_DATA))
    on_report(VmXMLReport.create(node_oid, raw_data=fixtures.LIBVIRT_XML))
    on_report(DFReport.create(node_oid, raw_data=fixtures.DF_RAW))