def __init__(self, *args, **kwargs): super(Controller, self).__init__(*args, **kwargs) self.this_dc_id = 1 conf = DictionaryConfiguration(self.this_dc_id) # configurations for the system # arp table for different tenants self.arp_table = conf.arp_table # pmac -> tenant_id self.host_pmac = conf.host_pmac # tenant_id -> tenant_level self.tenant_level = conf.tenant_level # record all potential subnet self.subnets = conf.subnets # record all potential gateway # 'NAT' : port_no # datacenter_id : port_no self.potential_gateway = conf.potential_gateway # remote datacenter_id -> {dpid -> peer} # if there is no peer, then peer is -1 self.gateways_datacenter_port = conf.gateway_datacenter_port # record all potential gateway_ip # datacenter_id -> [gateway_ip]s self.gateway_ip = conf.gateway_ip # record speed for tenant # tenant_id -> speed self.tenant_speed = conf.tenant_speed # record all datacenter_id self.all_datacenter_id = conf.all_datacenter_id # record for system # data in controller self.vmac_to_pmac = { # {vmac -> vmac} } self.pmac_to_vmac = { # {pmac -> vmac} } self.dpid_to_vmac = {} # {dpid -> vmac} self.datapathes = {} # {dpid -> datapath} self.dpid_to_ports = {} # {dpid -> ports} self.dpid_to_dpid = {} # {(dpid, port_id) -> dpid} self.switch_topo = nx.Graph() # switch topo self.port_speed = { } # {dpid -> {remote_dpid -> 'max_speed' - 'cur_speed'}} self.meters = {} # {dpid -> {meter_id -> band_id}} self.gateways = {} # {dpid -> {port_no -> datacenter_id}} self.gateway_vmac = {} # {dpid -> vmac} self.host_queue = {} # gateway_id -> queue for host self.switch_gateway_connection = { } # (switch_id, gateway_id) -> (switch_port, gateway_port) self.host_gateway = {} # {vmac -> gateway_id} # components self.flow_manager = FlowManager(datapathes=self.datapathes, gateways=self.gateways) self.lldp_manager = LLDPListener( datapathes=self.datapathes, dpid_potrs=self.dpid_to_ports, dpid_to_dpid=self.dpid_to_dpid, topo=self.switch_topo, DEFAULT_TTL=self.DEFAULT_TTL, port_speed=self.port_speed, potential_gateways=self.potential_gateway) self.swtich_manager = SwitchManager( datapathes=self.datapathes, dpid_to_ports=self.dpid_to_ports, dpid_to_vmac=self.dpid_to_vmac, lldp_manager=self.lldp_manager, meters=self.meters, subnets=self.subnets, potential_gateway=self.potential_gateway) self.arp_manager = ArpManager( arp_table=self.arp_table, pmac_to_vmac=self.pmac_to_vmac, gateway_ip=self.gateway_ip, gateways=self.gateways, dpid_to_vmac=self.dpid_to_vmac, switch_gateway_connection=self.switch_gateway_connection, datapathes=self.datapathes, host_gateway=self.host_gateway) self.mac_manager = MacManager(tenant_level=self.tenant_level) self.meter_manager = MeterModifier(meters=self.meters) self.host_manager = HostManager(host_pmac=self.host_pmac, mac_manager=self.mac_manager, pmac_to_vmac=self.pmac_to_vmac, vmac_to_pmac=self.vmac_to_pmac, tenant_speed=self.tenant_speed, meter_manager=self.meter_manager) self.topo_manager = TopoManager(topo=self.switch_topo, dpid_to_dpid=self.dpid_to_dpid) self.gateway_manager = GatewayManager( gateways=self.gateways, potential_gateway=self.potential_gateway, gateway_flow_table_inquire_time=self.GATEWAY_FLOW_INQUIRY_TIME, datapathes=self.datapathes, gateway_port_inquire_time=self.GATEWAY_PORT_INQUIRY_TIME, gateway_datacenter_port_max_speed=self.DEFAULT_GG_BW, balance_time_interval=self.GATEWAY_BALANCE_TIME, all_datacenter_id=self.all_datacenter_id, topo_manager=self.topo_manager, meter_manager=self.meter_manager) # hub self.init_hub = hub.spawn(self.init_controller)
def __init__(self, *args, **kwargs): super(Controller, self).__init__(*args, **kwargs) # configurations for the system self.datacenter_id = 2 # arp table for different tenants self.arp_table = { # {tenant_id ->{ip -> mac}} 1: { # d1 '191.168.1.1': '00:00:00:00:00:01', '191.168.1.2': '00:00:00:00:00:02', '191.168.1.3': '00:00:00:00:00:03', '192.168.1.4': '00:00:00:00:00:04', '191.168.1.4': '00:00:00:00:00:05', '191.168.1.6': '00:00:00:00:00:09', # d2 '191.168.2.1': '00:00:00:00:01:01', '192.168.2.2': '00:00:00:00:01:02' }, 2: { # d1 '191.168.1.1': '00:00:00:00:00:0a', '191.168.1.2': '00:00:00:00:00:0b', '191.168.1.3': '00:00:00:00:00:0c', # d2 '191.168.2.1': '00:00:00:00:01:03', '192.168.2.2': '00:00:00:00:01:04' } } # pmac -> tenant_id self.host_pmac = { '00:00:00:00:00:01': 1, '00:00:00:00:00:02': 1, '00:00:00:00:00:03': 1, '00:00:00:00:00:04': 1, '00:00:00:00:00:05': 1, '10:00:00:00:00:00': 1, '00:00:00:00:04:00': 1, '00:00:00:00:00:09': 1, '00:00:00:00:01:00': 1, '00:00:00:00:02:00': 1, '00:00:00:00:00:0a': 2, '00:00:00:00:00:0b': 2, '00:00:00:00:00:0c': 2, '00:00:00:00:03:00': 2, '00:00:00:00:05:00': 2, '00:00:00:00:01:01': 1, '00:00:00:00:01:02': 1, '00:00:00:00:01:03': 2, '00:00:00:00:01:04': 2 } # tenant_id -> tenant_level self.tenant_level = {1: 1, 2: 2} # record all potential subnet self.subnets = ['191.0.0.0/8', '192.0.0.0/8', '10.0.0.0/8'] # record all potential gateway # 'NAT' : port_no # datacenter_id : port_no self.potential_gateway = {10: {'NAT': 5, 1: 3}, 11: {'NAT': 6, 1: 3}} # remote datacenter_id -> {dpid -> peer} # if there is no peer, then peer is -1 self.gateways_datacenter_port = {2: {10: -1, 11: 12, 12: 11}} # record all potential gateway_ip self.gateway_ip = ['191.0.0.1', '192.0.0.1'] # record speed for tenant # tenant_id -> speed self.tenant_speed = {1: 1024 * 8, 2: 1024 * 8} # record all datacenter_id self.all_datacenter_id = [1, 2] # record for system # data in controller self.vmac_to_pmac = { # {vmac -> vmac} '11:00:01:00:01:02': '00:00:00:00:00:02', '11:00:01:00:02:01': '00:00:00:00:00:03', '12:00:02:00:04:03': '00:00:00:00:00:0c', '11:00:01:00:03:01': '00:00:00:00:00:04', '12:00:02:00:01:06': '00:00:00:00:00:0a', '11:00:01:00:04:01': '00:00:00:00:00:05', '11:00:01:00:05:03': '00:00:00:00:00:09', '11:00:01:00:01:01': '00:00:00:00:00:01', '12:00:02:00:01:07': '00:00:00:00:00:0b' } self.pmac_to_vmac = { # {pmac -> vmac} '00:00:00:00:00:02': '11:00:01:00:01:02', '00:00:00:00:00:03': '11:00:01:00:02:01', '00:00:00:00:00:0c': '12:00:02:00:04:03', '00:00:00:00:00:04': '11:00:01:00:03:01', '00:00:00:00:00:0a': '12:00:02:00:01:06', '00:00:00:00:00:05': '11:00:01:00:04:01', '00:00:00:00:00:09': '11:00:01:00:05:03', '00:00:00:00:00:01': '11:00:01:00:01:01', '00:00:00:00:00:0b': '12:00:02:00:01:07' } self.dpid_to_vmac = {} # {dpid -> vmac} self.datapathes = {} # {dpid -> datapath} self.dpid_to_ports = {} # {dpid -> ports} self.dpid_to_dpid = {} # {(dpid, port_id) -> dpid} self.switch_topo = nx.Graph() # switch topo self.port_speed = { } # {dpid -> {remote_dpid -> 'max_speed' - 'cur_speed'}} self.gateway_port_speed = {} # {gateway_id -> {port_no -> speed}} self.meters = {} # {dpid -> {meter_id -> band_id}} self.gateways = {} # {dpid -> {port_no -> datacenter_id}} self.gateway_vmac = {} # {dpid -> vmac} self.host_queue = {} # gateway_id -> queue for host self.switch_gateway_connection = { } # (switch_id, gateway_id) -> (switch_port, gateway_port) self.host_gateway = {} # {vmac -> gateway_id} # components self.flow_manager = FlowManager(datapathes=self.datapathes, gateways=self.gateways) self.lldp_manager = LLDPListener( datapathes=self.datapathes, dpid_potrs=self.dpid_to_ports, dpid_to_dpid=self.dpid_to_dpid, topo=self.switch_topo, DEFAULT_TTL=self.DEFAULT_TTL, port_speed=self.port_speed, potential_gateways=self.potential_gateway) self.swtich_manager = SwitchManager( datapathes=self.datapathes, dpid_to_ports=self.dpid_to_ports, datacenter_id=self.datacenter_id, dpid_to_vmac=self.dpid_to_vmac, lldp_manager=self.lldp_manager, meters=self.meters, subnets=self.subnets, potential_gateway=self.potential_gateway) self.arp_manager = ArpManager( arp_table=self.arp_table, pmac_to_vmac=self.pmac_to_vmac, gateway_ip=self.gateway_ip, gateways=self.gateways, dpid_to_vmac=self.dpid_to_vmac, switch_gateway_connection=self.switch_gateway_connection, datapathes=self.datapathes, host_gateway=self.host_gateway, datacenter_id=self.datacenter_id) self.mac_manager = MacManager(tenant_level=self.tenant_level) self.meter_manager = MeterModifier(meters=self.meters) self.host_manager = HostManager(host_pmac=self.host_pmac, mac_manager=self.mac_manager, datacenter_id=self.datacenter_id, pmac_to_vmac=self.pmac_to_vmac, vmac_to_pmac=self.vmac_to_pmac, tenant_speed=self.tenant_speed, meter_manager=self.meter_manager) self.topo_manager = TopoManager(topo=self.switch_topo, dpid_to_dpid=self.dpid_to_dpid) self.gateway_manager = GatewayManager( gateways=self.gateways, potential_gateway=self.potential_gateway, datacenter_id=self.datacenter_id, gateway_flow_table_inquire_time=self.GATEWAY_FLOW_INQUIRY_TIME, datapathes=self.datapathes, gateway_port_inquire_time=self.GATEWAY_PORT_INQUIRY_TIME, gateway_datacenter_port_max_speed=self.DEFAULT_GG_BW, balance_time_interval=self.GATEWAY_BALANCE_TIME, all_datacenter_id=self.all_datacenter_id, topo_manager=self.topo_manager, meter_manager=self.meter_manager) # hub self.init_hub = hub.spawn(self.init_controller) self.gateway_statistics_inquiry_hub = hub.spawn( self.gateway_manager.inquiry_gateway_flow_table_info) self.gateways_datacenter_port_hub = hub.spawn( self.gateway_manager.inquiry_gateway_datacenter_port) self.gateway_banlance_hub = hub.spawn( self.gateway_manager.gateway_balance_hub) self.gateway_init_record_hub = hub.spawn( self.gateway_manager.init_gateway_record)