Ejemplo n.º 1
0
    def test_read_zookeeper(self):
        cfg_map = {
            "bridges": [],
            "computes": [],
            "vlans": [],
            "hosts": [],
            "hosted_vms": [],
            "routers": [],
            "cassandras": [],
            "zookeepers": [{
                "interface_list": [{
                    "bridge_link": {
                        "name": "br0"
                    },
                    "name":
                    "eth0",
                    "ip_list": [{
                        "ip": "10.0.0.2",
                        "subnet": "24"
                    }]
                }],
                "name":
                "zoo1"
            }]
        }
        mcr = MapConfigReader()

        ptc = mcr.get_physical_topology_config(cfg_map)
        self.assertEqual(len(ptc.zookeeper_config), 1)
        self.assertEqual(ptc.zookeeper_config[0].name, "zoo1")
        self.assertEqual(ptc.zookeeper_config[0].options, "")
        self.assertEqual(len(ptc.zookeeper_config[0].interface_list), 1)
Ejemplo n.º 2
0
    def test_read_bridges(self):
        cfg_map = {
            "bridges": [{
                "name": "br0",
                "host": "host1",
                "ip_list": [{
                    "ip": "10.0.0.240",
                    "subnet": "24"
                }],
                "options": "stp"
            }],
            "computes": [],
            "vlans": [],
            "hosts": [],
            "hosted_vms": [],
            "routers": [],
            "cassandras": [],
            "zookeepers": []
        }
        mcr = MapConfigReader()

        ptc = mcr.get_physical_topology_config(cfg_map)
        self.assertEqual(len(ptc.bridge_config), 1)
        self.assertEqual(ptc.bridge_config[0].host, 'host1')
        self.assertEqual(ptc.bridge_config[0].name, 'br0')
        self.assertEqual(ptc.bridge_config[0].options, 'stp')
        self.assertEqual(len(ptc.bridge_config[0].ip_list), 1)
        self.assertEqual(ptc.bridge_config[0].ip_list[0].ip_address,
                         "10.0.0.240")
        self.assertEqual(ptc.bridge_config[0].ip_list[0].subnet_mask, "24")
Ejemplo n.º 3
0
    def test_read_cassandra(self):
        cfg_map = {
            "bridges": [],
            "computes": [],
            "vlans": [],
            "hosts": [],
            "hosted_vms": [],
            "routers": [],
            "cassandras": [{
                "interface_list": [{
                    "bridge_link": {
                        "name": "br0"
                    },
                    "name":
                    "eth0",
                    "ip_list": [{
                        "ip": "10.0.0.5",
                        "subnet": "24"
                    }]
                }],
                "name":
                "cass1",
                "options":
                "56713727820156410577229101238628035242"
            }],
            "zookeepers": []
        }
        mcr = MapConfigReader()

        ptc = mcr.get_physical_topology_config(cfg_map)
        self.assertEqual(len(ptc.cassandra_config), 1)
        self.assertEqual(ptc.cassandra_config[0].name, "cass1")
        self.assertEqual(ptc.cassandra_config[0].options,
                         "56713727820156410577229101238628035242")
        self.assertEqual(len(ptc.cassandra_config[0].interface_list), 1)
Ejemplo n.º 4
0
    def test_read_routers(self):
        cfg_map = {
            "bridges": [],
            "computes": [],
            "vlans": [],
            "hosts": [],
            "hosted_vms": [],
            "routers": [{
                "peer_interface_list": [{
                    "interface_name": "eth0",
                    "target_host": "cmp1",
                    "target_interface": {
                        "name": "eth1",
                        "ip_list": [{
                            "ip": "10.0.1.240",
                            "subnet": "16"
                        }]
                    }
                }, {
                    "interface_name": "eth1",
                    "target_host": "cmp2",
                    "target_interface": {
                        "name": "eth1",
                        "ip_list": [{
                            "ip": "10.0.1.240",
                            "subnet": "16"
                        }]
                    }
                }],
                "name":
                "quagga"
            }],
            "cassandras": [],
            "zookeepers": []
        }
        mcr = MapConfigReader()

        ptc = mcr.get_physical_topology_config(cfg_map)
        self.assertEqual(len(ptc.router_config), 1)
        self.assertEqual(ptc.router_config[0].name, 'quagga')
        self.assertEqual(len(ptc.router_config[0].peer_interface_list), 2)
        self.assertEqual(
            ptc.router_config[0].peer_interface_list[0].interface_name, "eth0")
        self.assertEqual(
            ptc.router_config[0].peer_interface_list[1].interface_name, "eth1")
        self.assertEqual(
            ptc.router_config[0].peer_interface_list[0].target_host, "cmp1")
        self.assertEqual(
            ptc.router_config[0].peer_interface_list[1].target_host, "cmp2")
        self.assertEqual(
            ptc.router_config[0].peer_interface_list[0].target_interface.name,
            "eth1")
        self.assertEqual(
            ptc.router_config[0].peer_interface_list[1].target_interface.name,
            "eth1")
Ejemplo n.º 5
0
    def test_read_vms(self):
        cfg_map = {
            "bridges": [],
            "computes": [],
            "vlans": [],
            "hosts": [],
            "hosted_vms": [],
            "routers": [],
            "cassandras": [],
            "zookeepers": []
        }
        mcr = MapConfigReader()

        ptc = mcr.get_physical_topology_config(cfg_map)
        self.assertEqual(True, True)
Ejemplo n.º 6
0
    def test_print_config(self):
        with open('../../config.json', 'r') as f:
            config_obj = json.load(f)

        config = MapConfigReader.get_physical_topology_config(config_obj)
        test_server2 = RootServer.create_from_physical_topology_config(config)
        test_server2.init()
        test_server2.print_config()
Ejemplo n.º 7
0
    def test_create_test_server_from_json(self):
        with open('../../config.json', 'r') as f:
            config_obj = json.load(f)

        config = MapConfigReader.get_physical_topology_config(config_obj)
        test_server2 = RootServer.create_from_physical_topology_config(config)
        test_server2.init()
        self.assertEqual(True, True)
Ejemplo n.º 8
0
    def test_read_hosts(self):
        cfg_map = {
            "bridges": [],
            "computes": [],
            "vlans": [],
            "hosts": [{
                "name":
                "v1.1",
                "interface_list": [{
                    "bridge_link": {
                        "name": "brv0"
                    },
                    "name": "eth0"
                }]
            }, {
                "name":
                "v1.2",
                "interface_list": [{
                    "bridge_link": {
                        "name": "brv0"
                    },
                    "name": "eth0"
                }]
            }],
            "hosted_vms": [],
            "routers": [],
            "cassandras": [],
            "zookeepers": []
        }
        mcr = MapConfigReader()

        ptc = mcr.get_physical_topology_config(cfg_map)
        self.assertEqual(len(ptc.host_config), 2)
        self.assertEqual(ptc.host_config[0].name, "v1.1")
        self.assertEqual(ptc.host_config[1].name, "v1.2")
        self.assertEqual(len(ptc.host_config[0].interface_list), 1)
        self.assertEqual(len(ptc.host_config[1].interface_list), 1)
        self.assertEqual(ptc.host_config[0].interface_list[0].name, "eth0")
        self.assertEqual(ptc.host_config[1].interface_list[0].name, "eth0")
Ejemplo n.º 9
0
    def test_read_vlans(self):
        cfg_map = {
            "bridges": [],
            "computes": [],
            "vlans": [{
                "host_list": [{
                    "interface_list": [{
                        "name":
                        "eth0",
                        "ip_list": [{
                            "ip": "172.16.0.224",
                            "subnet": "24"
                        }]
                    }, {
                        "name":
                        "eth1",
                        "ip_list": [{
                            "ip": "172.16.0.223",
                            "subnet": "24"
                        }]
                    }],
                    "name":
                    "v1.1"
                }, {
                    "interface_list": [{
                        "name":
                        "eth0",
                        "ip_list": [{
                            "ip": "172.16.0.225",
                            "subnet": "24"
                        }]
                    }],
                    "name":
                    "v2.1"
                }],
                "vlan_id":
                "1"
            }],
            "hosts": [],
            "hosted_vms": [],
            "routers": [],
            "cassandras": [],
            "zookeepers": []
        }
        mcr = MapConfigReader()

        ptc = mcr.get_physical_topology_config(cfg_map)
        self.assertEqual(len(ptc.vlan_config), 1)
        self.assertEqual(ptc.vlan_config[0].vlan_id, "1")
        self.assertEqual(len(ptc.vlan_config[0].host_list), 2)
        self.assertEqual(ptc.vlan_config[0].host_list[0].name, "v1.1")
        self.assertEqual(ptc.vlan_config[0].host_list[1].name, "v2.1")
        self.assertEqual(len(ptc.vlan_config[0].host_list[0].interface_list),
                         2)
        self.assertEqual(len(ptc.vlan_config[0].host_list[1].interface_list),
                         1)
        self.assertEqual(
            ptc.vlan_config[0].host_list[0].interface_list[0].name, "eth0")
        self.assertEqual(
            ptc.vlan_config[0].host_list[0].interface_list[1].name, "eth1")
        self.assertEqual(
            ptc.vlan_config[0].host_list[1].interface_list[0].name, "eth0")
Ejemplo n.º 10
0
def usage(exceptClass):
    print 'Usage: ' + CONTROL_CMD_NAME + ' {boot|init|start|stop|shutdown|config} [options]'
    print 'Usage: ' + CONTROL_CMD_NAME + ' neutron {install} [options]'
    if exceptClass is not None:
        raise exceptClass()

try:

    if len(sys.argv) < 2:
        usage(ExitCleanException)
    else:
        cmd = sys.argv[1]
        with open('config.json', 'r') as f:
            config_obj = json.load(f)

        config = MapConfigReader.get_physical_topology_config(config_obj)
        os_host = RootServer.create_from_physical_topology_config(config)
        os_host.init()

        if cmd == 'neutron':
            if len(sys.argv) < 3:
                usage(ExitCleanException)
            if sys.argv[2] == 'install':
                EnvSetup.install_neutron_client()
        elif cmd == 'boot':
            os_host.setup()
        elif cmd == 'init':
            os_host.prepare_files()
        elif cmd == 'start':
            os_host.start()
        elif cmd == 'stop':