def _load_customers(self, controller): customers = self._config.items("Customers") for customer in customers: citems = customer[1].split(',') if len(citems) > 7: customer_name = customer[0] (private_ip_subnet, ingress_interface, ip_datapath, router, next_hop, name_server, out_port, datapath_to_router_ip, datapath_to_router_interface, ns_domain_name) = citems c = Customer(customer_name, private_ip_subnet, ingress_interface, ip_datapath, router, next_hop, out_port, datapath_to_router_ip, datapath_to_router_interface, ns_domain_name) if name_server != "": print name_server + "NS" c.set_name_server(name_server) else: customer_name = customer[0] (private_ip_subnet, ingress_interface, ip_datapath, router, next_hop, name_server) = citems c = CustomerAlg1(customer_name, private_ip_subnet, ingress_interface, ip_datapath, router, next_hop) if name_server != "": print name_server + "NS" c.set_name_server(name_server) self._customers.append(c) controller.set_customers(c)
def _load_customers(self, controller, config_file): conf = XmlParser.parse(config_file) root = conf.getroot() myself = root.find('federation').find('myself').find('isp') myself_id = myself.attrib.get('id') vpns = root.find('federation').find('vpns') for vpn in vpns: vpn_id = vpn.attrib.get('id') # Take all customers in this vpn isps = vpn.findall('isp') #isp = isps[0] for isp in isps: if myself_id == isp.attrib.get('id'): customers = isp.findall('customer') for customer in customers: c = Customer( customer.attrib.get('name'), customer.find('site').find('subnet').attrib.get( 'private_network'), customer.find('site').find('datapath').attrib.get( 'in_port'), customer.find('site').find('datapath').attrib.get( 'ip'), customer.attrib.get('pe'), customer.find('site').attrib.get('ce'), #customer.attrib.get('of_port'), customer.attrib.get('of_ip'), out_port=customer.find('site').find( 'datapath').attrib.get('out_port')) ns_ip = customer.find('site').find('ns').attrib.get( 'ip') if ns_ip == '': ns_ip = None c.set_name_server(ns_ip) ns_domain = customer.find('site').find( 'ns').attrib.get('domain') if ns_domain == '': ns_domain = None c.set_ns_domain_name(ns_domain) # Add to the list of vpns self._vpns.get(vpn_id).append(c) self._customers.append(c) controller.set_customers(c)