Exemplo n.º 1
0
    def get_nodes_dict_for_rspec(self, geni_available):
        component_id_prefix = self.component_id_prefix
        component_manager_prefix = self.component_manager_prefix

        # get data from db - TODO: refactor into function
        self.configured_interfaces = db_sync_manager.get_resources()

        configured_interfaces = self.configured_interfaces

        nodes = [
            {
                'component_manager_id': component_manager_prefix,
                'exclusive':'false',
                'interfaces': [],
#                'component_id': component_id_prefix,
                'component_id': component_id_prefix + '+datapath+' + self.dpid,
                'sliver_type_name':None
            }
        ]

        # Prepare nodes
        for iface in configured_interfaces:
            vlans_on_iface = configured_interfaces[iface]
            for vlan in vlans_on_iface:
                current_vlan_status = vlans_on_iface[vlan]
                if current_vlan_status is not False or geni_available is False:
                    available_iface = {
                        'component_id': component_id_prefix + '+datapath+' + self.dpid + "_" + iface,
                        'vlan':[
                        ]
                    }
                    nodes[0]['interfaces'].append(available_iface)
                    break

        return nodes
Exemplo n.º 2
0
    def get_nodes_dict_for_rspec(self, geni_available):
        component_id_prefix = self.component_id_prefix
        component_manager_prefix = self.component_manager_prefix

        # get data from db - TODO: refactor into function
        self.configured_interfaces = db_sync_manager.get_resources()

        configured_interfaces = self.configured_interfaces

        nodes = [{
            'component_manager_id': component_manager_prefix,
            'exclusive': 'false',
            'interfaces': [],
            #                'component_id': component_id_prefix,
            'component_id': component_id_prefix + '+datapath+' + self.dpid,
            'sliver_type_name': None
        }]

        # Prepare nodes
        for iface in configured_interfaces:
            vlans_on_iface = configured_interfaces[iface]
            for vlan in vlans_on_iface:
                current_vlan_status = vlans_on_iface[vlan]
                if current_vlan_status is not False or geni_available is False:
                    available_iface = {
                        'component_id':
                        component_id_prefix + '+datapath+' + self.dpid + "_" +
                        iface,
                        'vlan': []
                    }
                    nodes[0]['interfaces'].append(available_iface)
                    break

        return nodes
Exemplo n.º 3
0
    def check_available_resources(self, resources):

        # get data from db - TODO: refactor into function
        self.configured_interfaces = db_sync_manager.get_resources()

        for resource in resources:
            try:
                r_splited = resource['port'].rsplit("_", 1)
                vlan = resource['vlan']
                component_id = r_splited[0]
                port = r_splited[1]
                vlans_result = self.get_concrete_port_status(port)
                result = vlans_result[vlan]
                # if (result is False) or (component_id != self.component_id_prefix):
                if (result is False) or (self.component_id_prefix not in resource["port"]):
                    return False
            except KeyError:
                return False
        return True
Exemplo n.º 4
0
    def check_available_resources(self, resources):

        # get data from db - TODO: refactor into function
        self.configured_interfaces = db_sync_manager.get_resources()

        for resource in resources:
            try:
                r_splited = resource['port'].rsplit("_", 1)
                vlan = resource['vlan']
                component_id = r_splited[0]
                port = r_splited[1]
                vlans_result = self.get_concrete_port_status(port)
                result = vlans_result[vlan]
                # if (result is False) or (component_id != self.component_id_prefix):
                if (result is False) or (self.component_id_prefix
                                         not in resource["port"]):
                    return False
            except KeyError:
                return False
        return True
Exemplo n.º 5
0
 def __init__(self):
     # TODO: change this to minimise the query result size
     self.getVlansForPorts = db_sync_manager.get_resources()
     self.vlansForStaticLinks = {}
Exemplo n.º 6
0
 def __init__(self):
     self.getVlansForPorts = db_sync_manager.get_resources()
     self.vlansForStaticLinks = {}
     self.SEResources = SEConfigurator.seConfigurator()
Exemplo n.º 7
0
    def get_links_dict_for_rspec(self, geni_available):
        component_id_prefix = self.component_id_prefix
        component_manager_prefix = self.component_manager_prefix

        # get data from db - TODO: refactor into function
        self.configured_interfaces = db_sync_manager.get_resources()

        configured_interfaces = self.configured_interfaces
        vlan_trans = self.vlan_trans
        qinq = self.qinq
        capacity = self.capacity

        # Prepare link capability translations
        # TODO: Check if this should provide VLAN trans params or not
        link_trans_capability = 'urn:felix'

        links_se = [
            {
                'component_id': component_id_prefix + ':link',
                'component_manager_name': component_manager_prefix,
                'interface_ref':[
                    {
                        'component_id':'*'
                    },
                    {
                        'component_id':'*'
                    }
                ],
                'property':[
                    {
                        'source_id':'*',
                        'dest_id':'*',
                        'capacity': capacity
                    }
                ],
                'link_type': link_trans_capability
            }
        ]

        # Prepare links
        config = self.initial_configured_interfaces
        for interface in config:
            endpoints = config[interface]["remote_endpoints"]
            for endpoint in endpoints:
                found = False
                for vlan in endpoint["vlans"]:
                    if found == False:
                        if isinstance(vlan, int ):
                            if configured_interfaces[interface][str(vlan)] == True or geni_available is False:
                                new_static_link =  {
                                    'component_id':component_id_prefix + '+link+' + self.dpid + "_" + interface + "_" + endpoint["name"].rsplit("+", 1)[1],
                                    'component_manager_name': component_id_prefix + "+authority+cm",
                                    'interface_ref':[
                                        {
                                            'component_id': component_id_prefix + '+datapath+' + self.dpid + "_" + interface
                                        },
                                        {
                                            'component_id': endpoint["name"]
                                        }
                                    ],
                                    'property':[

                                    ],
                                    'link_type':'urn:felix+' + endpoint["type"]
                                }
                                links_se.append(new_static_link)
                                found = True
                                break
                        else:
                            try:
                                v_start, v_end = vlan.split("-")
                                v_range = range(int(v_start), int(v_end)+1, 1)
                                for v in v_range:
                                    if configured_interfaces[interface][str(v)] == True or geni_available is False:
                                        new_static_link =  {
                                            'component_id':component_id_prefix + '+link+' + self.dpid + "_" + interface + "_" + endpoint["name"].rsplit("+", 1)[1],
                                            'component_manager_name': component_id_prefix + "+authority+cm",
                                            'interface_ref':[
                                                {
                                                    'component_id': component_id_prefix + '+datapath+' + self.dpid + "_" + interface
                                                },
                                                {
                                                    'component_id': endpoint["name"]
                                                }
                                            ],
                                            'property':[

                                            ],
                                            'link_type':'urn:felix+' + endpoint["type"]
                                        }
                                        links_se.append(new_static_link)
                                        found = True
                                        break
                            except:
                                pass

        return links_se
Exemplo n.º 8
0
    def get_links_dict_for_rspec(self, geni_available):
        component_id_prefix = self.component_id_prefix
        component_manager_prefix = self.component_manager_prefix

        # get data from db - TODO: refactor into function
        self.configured_interfaces = db_sync_manager.get_resources()

        configured_interfaces = self.configured_interfaces
        vlan_trans = self.vlan_trans
        qinq = self.qinq
        capacity = self.capacity

        # Prepare link capability translations
        # TODO: Check if this should provide VLAN trans params or not
        link_trans_capability = 'urn:felix'

        links_se = [{
            'component_id':
            component_id_prefix + ':link',
            'component_manager_name':
            component_manager_prefix,
            'interface_ref': [{
                'component_id': '*'
            }, {
                'component_id': '*'
            }],
            'property': [{
                'source_id': '*',
                'dest_id': '*',
                'capacity': capacity
            }],
            'link_type':
            link_trans_capability
        }]

        # Prepare links
        config = self.initial_configured_interfaces
        for interface in config:
            endpoints = config[interface]["remote_endpoints"]
            for endpoint in endpoints:
                found = False
                for vlan in endpoint["vlans"]:
                    if found == False:
                        if isinstance(vlan, int):
                            if configured_interfaces[interface][str(
                                    vlan)] == True or geni_available is False:
                                new_static_link = {
                                    'component_id':
                                    component_id_prefix + '+link+' +
                                    self.dpid + "_" + interface + "_" +
                                    endpoint["name"].rsplit("+", 1)[1],
                                    'component_manager_name':
                                    component_id_prefix + "+authority+cm",
                                    'interface_ref': [{
                                        'component_id':
                                        component_id_prefix + '+datapath+' +
                                        self.dpid + "_" + interface
                                    }, {
                                        'component_id':
                                        endpoint["name"]
                                    }],
                                    'property': [],
                                    'link_type':
                                    'urn:felix+' + endpoint["type"]
                                }
                                links_se.append(new_static_link)
                                found = True
                                break
                        else:
                            try:
                                v_start, v_end = vlan.split("-")
                                v_range = range(int(v_start),
                                                int(v_end) + 1, 1)
                                for v in v_range:
                                    if configured_interfaces[interface][str(
                                            v
                                    )] == True or geni_available is False:
                                        new_static_link = {
                                            'component_id':
                                            component_id_prefix + '+link+' +
                                            self.dpid + "_" + interface + "_" +
                                            endpoint["name"].rsplit("+", 1)[1],
                                            'component_manager_name':
                                            component_id_prefix +
                                            "+authority+cm",
                                            'interface_ref': [{
                                                'component_id':
                                                component_id_prefix +
                                                '+datapath+' + self.dpid +
                                                "_" + interface
                                            }, {
                                                'component_id':
                                                endpoint["name"]
                                            }],
                                            'property': [],
                                            'link_type':
                                            'urn:felix+' + endpoint["type"]
                                        }
                                        links_se.append(new_static_link)
                                        found = True
                                        break
                            except:
                                pass

        return links_se
Exemplo n.º 9
0
 def __init__(self):
     # TODO: change this to minimise the query result size
     self.getVlansForPorts = db_sync_manager.get_resources()
     self.vlansForStaticLinks = {}