Esempio n. 1
0
def prepare_netconfig(machine_file, config_file):
    tree_init = XmlDomTreeInit()
    data = prepare_machine_config(machine_file)

    dom = tree_init.parse_file(config_file)
    config_dom = dom.getElementsByTagName("netconfig")[0]

    config_parse = NetConfigParse()
    config_parse.disable_events()
    config_parse.set_recipe(data)
    config_parse.set_machine(0, data)
    config_parse.parse(config_dom)

    netconfig = NetConfig()
    for key, entry in data["netconfig"].iteritems():
        netconfig.add_interface_config(key, entry)

    return netconfig
Esempio n. 2
0
def prepare_netconfig(machine_file, config_file):
    tree_init = XmlDomTreeInit()
    data = prepare_machine_config(machine_file)

    dom = tree_init.parse_file(config_file)
    config_dom = dom.getElementsByTagName("netconfig")[0]

    config_parse = NetConfigParse()
    config_parse.disable_events()
    config_parse.set_recipe(data)
    config_parse.set_machine(0, data)
    config_parse.parse(config_dom)

    netconfig = NetConfig()
    for key, entry in data["netconfig"].iteritems():
        netconfig.add_interface_config(key, entry)

    return netconfig
Esempio n. 3
0
    def _reinit(self):
        if self._nc:
            self._nc.deconfigure_all()
        net_config = NetConfig(self._machine_config_xml)
        net_config.configure_all()

        self._nc = net_config
        self.vlan_add("default", DEFAULT_VLAN)

        dump = net_config.dump_config()
        for dev_id in dump:
            netdev = dump[dev_id]
            if netdev["type"] != "eth":
                continue
            net_config.set_notes(dev_id, {NOTE_EXTID: dev_id})
            self.port_vlan_add(dev_id, DEFAULT_VLAN, False)
        return True