コード例 #1
0
 def get_port_uuid(self,port,inputs=None):
     phy_device_fixture=PhysicalDeviceFixture(self.name,self.mgmt_ip,inputs=inputs)
     phy_device_fixture.setUp()
     phy_device_uuid = phy_device_fixture.phy_device.uuid
     pif_fixture=PhysicalInterfaceFixture(port,device_id=phy_device_uuid,inputs=inputs)
     pif_fixture.setUp()
     return pif_fixture.uuid
コード例 #2
0
 def get_port_uuid(self,port,inputs=None):
     phy_device_fixture=PhysicalDeviceFixture(self.name,self.mgmt_ip,inputs=inputs)
     phy_device_fixture.setUp()
     phy_device_uuid = phy_device_fixture.phy_device.uuid
     pif_fixture=PhysicalInterfaceFixture(name=port,device_id=phy_device_uuid,inputs=inputs)
     pif_fixture.setUp()
     return pif_fixture.uuid
コード例 #3
0
 def get_port_uuid(self, port):
     phy_device_fixture = PhysicalDeviceFixture(self.name, self.mgmt_ip)
     phy_device_fixture.setUp()
     phy_device_uuid = phy_device_fixture.phy_device.uuid
     pif_fixture = PhysicalInterfaceFixture(port, device_id=phy_device_uuid)
     pif_fixture.setUp()
     return pif_fixture.uuid
コード例 #4
0
ファイル: base.py プロジェクト: vvelpula/tf-test
    def setup_tor_port(self,
                       tor_fixture,
                       port_index=0,
                       vlan_id=0,
                       vmi_objs=[],
                       cleanup=True):
        device_id = tor_fixture.phy_device.uuid
        tor_ip = tor_fixture.mgmt_ip
        pif_name = self.inputs.tor_hosts_data[tor_ip][port_index]['tor_port']
        lif_name = pif_name + '.' + str(vlan_id)
        pif_fixture = PhysicalInterfaceFixture(name=pif_name,
                                               device_id=device_id,
                                               connections=self.connections)
        pif_fixture.setUp()
        if cleanup:
            self.addCleanup(pif_fixture.cleanUp)

        lif_fixture = LogicalInterfaceFixture(
            name=lif_name,
            pif_id=pif_fixture.uuid,
            vlan_id=vlan_id,
            vmi_ids=[x.uuid for x in vmi_objs],
            connections=self.connections)
        lif_fixture.setUp()
        if cleanup:
            self.addCleanup(lif_fixture.cleanUp)
        return (pif_fixture, lif_fixture)
コード例 #5
0
 def add_physical_port(self, port_name):
     pif_fixture = PhysicalInterfaceFixture(port_name,
                                            device_id=self.phy_device.uuid,
                                            connections=self.connections,
                                            cfgm_ip=self.cfgm_ip,
                                            auth_server_ip=self.auth_server_ip)
     pif_fixture.setUp()
     return pif_fixture
コード例 #6
0
 def add_physical_port(self, port_name):
     pif_fixture = PhysicalInterfaceFixture(port_name,
                                            device_id=self.phy_device.uuid,
                                            connections=self.connections,
                                            cfgm_ip=self.cfgm_ip,
                                            auth_server_ip=self.auth_server_ip)
     pif_fixture.setUp()
     return pif_fixture
コード例 #7
0
    def onboard_existing_fabric(self,
                                fabric_dict,
                                wait_for_finish=True,
                                name=None,
                                cleanup=False):
        interfaces = {'physical': [], 'logical': []}
        devices = list()

        name = get_random_name(name) if name else get_random_name('fabric')

        fq_name = [
            'default-global-system-config', 'existing_fabric_onboard_template'
        ]
        payload = {'fabric_fq_name': ["default-global-system-config", name],
                   'node_profiles': [{"node_profile_name": profile}
                       for profile in fabric_dict.get('node_profiles')\
                                      or NODE_PROFILES],
                   'device_auth': [{"username": cred['username'],
                                    "password": cred['password']}
                       for cred in fabric_dict['credentials']],
                   'overlay_ibgp_asn': fabric_dict['namespaces']['asn'][0]['min'],
                   'management_subnets': [{"cidr": mgmt["cidr"]}
                       for mgmt in fabric_dict['namespaces']['management']]
                  }
        self.logger.info('Onboarding existing fabric %s %s' % (name, payload))
        execution_id = self.vnc_h.execute_job(fq_name, payload)
        status, fabric = self._get_fabric_fixture(name)
        assert fabric, 'Create fabric seems to have failed'
        if cleanup:
            self.addCleanup(self.cleanup_fabric, fabric, devices, interfaces)
        if wait_for_finish:
            try:
                status = self.wait_for_job_to_finish(':'.join(fq_name),
                                                     execution_id)
            except AssertionError:
                self.cleanup_fabric(fabric, verify=False)
                raise
            assert status, 'job %s to create fabric failed' % execution_id
            for device in fabric.fetch_associated_devices() or []:
                device_fixture = PhysicalDeviceFixture(
                    connections=self.connections, name=device)
                device_fixture.read()
                device_fixture.add_csn()
                devices.append(device_fixture)
            for device in devices:
                for port in device.get_physical_ports():
                    pif = PhysicalInterfaceFixture(
                        uuid=port, connections=self.connections)
                    pif.read()
                    interfaces['physical'].append(pif)
            for pif in interfaces['physical']:
                for port in pif.get_logical_ports():
                    lif = LogicalInterfaceFixture(uuid=port,
                                                  connections=self.connections)
                    lif.read()
                    interfaces['logical'].append(lif)
        return (fabric, devices, interfaces)
コード例 #8
0
ファイル: fabric_utils.py プロジェクト: Juniper/contrail-test
    def onboard_existing_fabric(self, fabric_dict, wait_for_finish=True,
                                name=None, cleanup=False):
        interfaces = {'physical': [], 'logical': []}
        devices = list()
        
        name = get_random_name(name) if name else get_random_name('fabric')

        fq_name = ['default-global-system-config',
                   'existing_fabric_onboard_template']
        payload = {'fabric_fq_name': ["default-global-system-config", name],
                   'node_profiles': [{"node_profile_name": profile}
                       for profile in fabric_dict.get('node_profiles')\
                                      or NODE_PROFILES],
                   'device_auth': [{"username": cred['username'],
                                    "password": cred['password']}
                       for cred in fabric_dict['credentials']],
                   'overlay_ibgp_asn': fabric_dict['namespaces']['asn'][0]['min'],
                   'management_subnets': [{"cidr": mgmt["cidr"]}
                       for mgmt in fabric_dict['namespaces']['management']]
                  }
        self.logger.info('Onboarding existing fabric %s %s'%(name, payload))
        execution_id = self.vnc_h.execute_job(fq_name, payload)
        status, fabric = self._get_fabric_fixture(name)
        assert fabric, 'Create fabric seems to have failed'
        if cleanup:
            self.addCleanup(self.cleanup_fabric, fabric, devices, interfaces)
        if wait_for_finish:
            try:
                status = self.wait_for_job_to_finish(':'.join(fq_name), execution_id)
            except AssertionError:
                self.cleanup_fabric(fabric, verify=False)
                raise
            assert status, 'job %s to create fabric failed'%execution_id
            for device in fabric.fetch_associated_devices() or []:
                device_fixture = PhysicalDeviceFixture(connections=self.connections,
                                                       name=device)
                device_fixture.read()
                device_fixture.add_csn()
                devices.append(device_fixture)
            for device in devices:
                for port in device.get_physical_ports():
                    pif = PhysicalInterfaceFixture(uuid=port, connections=self.connections)
                    pif.read()
                    interfaces['physical'].append(pif)
            for pif in interfaces['physical']:
                for port in pif.get_logical_ports():
                    lif = LogicalInterfaceFixture(uuid=port, connections=self.connections)
                    lif.read()
                    interfaces['logical'].append(lif)
        return (fabric, devices, interfaces)
コード例 #9
0
ファイル: fabric_utils.py プロジェクト: absurya4/tf-test
 def onboard(self, devices, filters=None, wait_for_finish=True):
     interfaces = {'physical': [], 'logical': []}
     fq_name = ['default-global-system-config', 'device_import_template']
     payload = self.get_filters(filters)
     device_list = [device.uuid for device in devices]
     execution_id = self.vnc_h.execute_job(fq_name, payload, device_list)
     self.logger.info('Started onboarding devices %s' % devices)
     if wait_for_finish:
         status = self.wait_for_job_to_finish(':'.join(fq_name),
                                              execution_id)[0]
         assert status, 'job %s to onboard devices failed' % execution_id
         for device in devices:
             for port in device.get_physical_ports():
                 pif = PhysicalInterfaceFixture(
                     uuid=port, connections=self.connections)
                 pif._clear_cleanups()
                 pif.read()
                 interfaces['physical'].append(pif)
         for pif in interfaces['physical']:
             for port in pif.get_logical_ports():
                 lif = LogicalInterfaceFixture(uuid=port,
                                               connections=self.connections)
                 lif._clear_cleanups()
                 lif.read()
                 interfaces['logical'].append(lif)
         return execution_id, interfaces
     return execution_id, None
コード例 #10
0
def createPhysicalInterface(self, config_topo):
    self.pif_fixture = {}
    if not hasattr(self.topo, 'pif_list'):
        return self
    for pif_name in self.topo.pif_list:
        self.pif_fixture[pif_name] = self.useFixture(
            PhysicalInterfaceFixture(
                name=pif_name,
                device_id=config_topo['pr'][self.pr_name].uuid,
                int_type=self.topo.pif_params[pif_name]['int_type'],
                connections=self.project_connections))
    return self
コード例 #11
0
ファイル: base.py プロジェクト: aswanikumar90/contrail-test
    def setup_tor_port(self, tor_fixture, port_index=0, vlan_id=0, vmi_objs=[], cleanup=True):
        device_id = tor_fixture.phy_device.uuid
        tor_ip = tor_fixture.mgmt_ip
        pif_name = self.inputs.tor_hosts_data[tor_ip][port_index]["tor_port"]
        lif_name = pif_name + "." + str(vlan_id)
        pif_fixture = PhysicalInterfaceFixture(pif_name, device_id=device_id, connections=self.connections)
        pif_fixture.setUp()
        if cleanup:
            self.addCleanup(pif_fixture.cleanUp)

        lif_fixture = LogicalInterfaceFixture(
            lif_name,
            pif_id=pif_fixture.uuid,
            vlan_id=vlan_id,
            vmi_ids=[x.uuid for x in vmi_objs],
            connections=self.connections,
        )
        lif_fixture.setUp()
        if cleanup:
            self.addCleanup(lif_fixture.cleanUp)
        return (pif_fixture, lif_fixture)
コード例 #12
0
ファイル: fabric_utils.py プロジェクト: Juniper/contrail-test
 def onboard(self, devices, filters=None, wait_for_finish=True):
     interfaces = {'physical': [], 'logical': []}
     fq_name = ['default-global-system-config', 'device_import_template']
     payload = self.get_filters(filters)
     device_list = [device.uuid for device in devices]
     execution_id = self.vnc_h.execute_job(fq_name, payload, device_list)
     self.logger.info('Started onboarding devices %s'%devices)
     if wait_for_finish:
         status = self.wait_for_job_to_finish(':'.join(fq_name), execution_id)
         assert status, 'job %s to onboard devices failed'%execution_id
         for device in devices:
             for port in device.get_physical_ports():
                 pif = PhysicalInterfaceFixture(uuid=port, connections=self.connections)
                 pif._clear_cleanups()
                 pif.read()
                 interfaces['physical'].append(pif)
         for pif in interfaces['physical']:
             for port in pif.get_logical_ports():
                 lif = LogicalInterfaceFixture(uuid=port, connections=self.connections)
                 lif._clear_cleanups()
                 lif.read()
                 interfaces['logical'].append(lif)
         return execution_id, interfaces
     return execution_id, None
コード例 #13
0
    def delete_virtual_machine_interface(self, vmi_id):
        self.logger.info('Deleting VMI %s from logical interface %s' %
                         (vmi_id, self.fq_name))
        vmi_obj = self.vnc_api_h.virtual_machine_interface_read(id=vmi_id)
        self.obj.del_virtual_machine_interface(vmi_obj)
        self.vnc_api_h.logical_interface_update(self.obj)


# end LogicalInterfaceFixture

if __name__ == "__main__":
    device_id = 'e122f6b2-5d5c-4f2e-b665-d69dba447bdf'
    from pif_fixture import PhysicalInterfaceFixture
    from port_fixture import PortFixture
    pif_obj = PhysicalInterfaceFixture(name='ge-0/0/0', device_id=device_id)
    pif_obj.setUp()

    vn_id = '1c83bed1-7d24-4414-9aa2-9d92975bc86f'
    subnet_id = '49fea486-57ab-4056-beb3-d311a385814e'
    port_fixture = PortFixture(vn_id=vn_id,
                               api_type='contrail',
                               mac_address="00:00:00:00:00:01",
                               fixed_ips=[{
                                   'subnet_id': subnet_id,
                                   'ip_address': '10.1.1.20'
                               }])
    port_fixture.setUp()
    lif_obj = LogicalInterfaceFixture(name='ge-0/0/0.0',
                                      pif_id=pif_obj.uuid,
                                      vmi_ids=[port_fixture.uuid])
コード例 #14
0
ファイル: fabric_utils.py プロジェクト: absurya4/tf-test
    def onboard_fabric(self,
                       fabric_dict,
                       wait_for_finish=True,
                       name=None,
                       cleanup=False,
                       enterprise_style=True,
                       dc_asn=None,
                       serList=None):
        interfaces = {'physical': [], 'logical': []}
        devices = list()
        name = name if name else get_random_name('fabric')

        fq_name = ['default-global-system-config', 'fabric_onboard_template']
        if 'image_upgrade_os_version' in list(
                fabric_dict['namespaces'].keys()):
            self.logger.info("ZTP with image upgrade")
            os_version = fabric_dict['namespaces']['image_upgrade_os_version']
        else:
            self.logger.info("ZTP without image upgrade")
            os_version = ''

        payload = {'fabric_fq_name': ["default-global-system-config", name],
                   'fabric_display_name': name,
                   "supplemental_day_0_cfg":[{"name": dct["supplemental_day_0_cfg"]["name"],\
                                              "cfg": dct["supplemental_day_0_cfg"]["cfg"]}
                        for dct in list(self.inputs.physical_routers_data.values()) \
                           if dct.get('supplemental_day_0_cfg') \
                               if serList is None or dct["serial_number"] in serList],
                   'device_to_ztp': [{"serial_number": dct['serial_number'], \
                                      "hostname": dct['name'], \
                                      "supplemental_day_0_cfg": dct.get("supplemental_day_0_cfg",{}).get('name','')} \
                       for dct in list(self.inputs.physical_routers_data.values()) \
                           if dct.get('serial_number') \
                               if serList is None or dct["serial_number"] in serList],
                   'node_profiles': [{"node_profile_name": profile}
                       for profile in fabric_dict.get('node_profiles')\
                                      or NODE_PROFILES],
                   'device_auth': {"root_password": fabric_dict['credentials'][0]['password']},
                   'loopback_subnets': fabric_dict['namespaces']['loopback_subnets'],
                   'management_subnets': fabric_dict['namespaces']['management_subnets'],
                   'fabric_subnets': fabric_dict['namespaces']['fabric_subnets'],
                   'overlay_ibgp_asn': dc_asn or fabric_dict['namespaces']['overlay_ibgp_asn'],
                   'fabric_asn_pool': [{"asn_max": fabric_dict['namespaces']['asn'][0]['max'],
                                       "asn_min": fabric_dict['namespaces']['asn'][0]['min']}]
                   }
        if os_version:
            payload['os_version'] = os_version
        self.logger.info('Onboarding new fabric %s %s' % (name, payload))
        execution_id = self.vnc_h.execute_job(fq_name, payload)
        status, fabric = self._get_fabric_fixture(name)
        assert fabric, 'Create fabric seems to have failed'
        if cleanup:
            self.addCleanup(self.cleanup_fabric, fabric, devices, interfaces)
        if wait_for_finish:
            try:
                status = self.wait_for_job_to_finish(':'.join(fq_name),
                                                     execution_id)[0]
            except AssertionError:
                self.cleanup_fabric(fabric, verify=False)
                raise
            assert status, 'job %s to create fabric failed' % execution_id
            for device in fabric.fetch_associated_devices() or []:
                device_dict = self.get_prouter_dict(device)
                device_fixture = PhysicalDeviceFixture(
                    connections=self.connections, name=device)
                device_fixture.read()
                device_fixture.add_csn()
                devices.append(device_fixture)
            for device in devices:
                for port in device.get_physical_ports():
                    pif = PhysicalInterfaceFixture(
                        uuid=port, connections=self.connections)
                    pif.read()
                    interfaces['physical'].append(pif)
            for pif in interfaces['physical']:
                for port in pif.get_logical_ports():
                    lif = LogicalInterfaceFixture(uuid=port,
                                                  connections=self.connections)
                    lif.read()
                    interfaces['logical'].append(lif)
        return (fabric, devices, interfaces)
コード例 #15
0
 def add_physical_port(self, port_name):
     pif_fixture = PhysicalInterfaceFixture(port_name,
                                            device_id=self.phy_device.uuid,
                                            connections=self.connections)
     pif_fixture.setUp()
     return pif_fixture
コード例 #16
0
ファイル: lif_fixture.py プロジェクト: Ankitja/contrail-test
            vmi_id, self.fq_name))
        vmi_obj = self.vnc_api_h.virtual_machine_interface_read(id=vmi_id)
        self.obj.add_virtual_machine_interface(vmi_obj)
        self.vnc_api_h.logical_interface_update(self.obj)

    def delete_virtual_machine_interface(self, vmi_id):
        self.logger.info('Deleting VMI %s from logical interface %s' % (
            vmi_id, self.fq_name))
        vmi_obj = self.vnc_api_h.virtual_machine_interface_read(id=vmi_id)
        self.obj.del_virtual_machine_interface(vmi_obj)
        self.vnc_api_h.logical_interface_update(self.obj)

# end LogicalInterfaceFixture

if __name__ == "__main__":
    device_id = 'e122f6b2-5d5c-4f2e-b665-d69dba447bdf'
    from pif_fixture import PhysicalInterfaceFixture
    from port_fixture import PortFixture
    pif_obj = PhysicalInterfaceFixture(name='ge-0/0/0', device_id=device_id)
    pif_obj.setUp()

    vn_id = '1c83bed1-7d24-4414-9aa2-9d92975bc86f'
    subnet_id = '49fea486-57ab-4056-beb3-d311a385814e'
    port_fixture = PortFixture(
        vn_id=vn_id, api_type='contrail', mac_address="00:00:00:00:00:01",
        fixed_ips=[{'subnet_id': subnet_id, 'ip_address': '10.1.1.20'}])
    port_fixture.setUp()
    lif_obj = LogicalInterfaceFixture(
        name='ge-0/0/0.0', pif_id=pif_obj.uuid, vmi_ids=[port_fixture.uuid])
    lif_obj.setUp()
コード例 #17
0
 def add_physical_port(self, port_name):
     pif_fixture = PhysicalInterfaceFixture(port_name,
                                            device_id=self.phy_device.uuid,
                                            connections=self.connections)
     pif_fixture.setUp()
     return pif_fixture
コード例 #18
0
 def create_physical_interface(self, connections=None, **kwargs):
     ''' Refer PhysicalInterfaceFixture for params info '''
     connections = connections or self.connections
     return self.useFixture(
         PhysicalInterfaceFixture(connections=connections, **kwargs))