Beispiel #1
0
    def load_config(self, context, ixia_config_file_name):

        self.ixl.load_config(ixia_config_file_name)
        self.ixl.repository.test.set_attributes(enableForceOwnership=False)
        config_elements = self.ixl.repository.get_elements()

        reservation_ports = {}
        for port in get_resources_from_reservation(context,
                                                   'Generic Traffic Generator Port',
                                                   f'{PERFECT_STORM_CHASSIS_MODEL}.GenericTrafficGeneratorPort',
                                                   f'{IXIA_CHASSIS_MODEL}.GenericTrafficGeneratorPort',
                                                   'IxVM Virtual Traffic Chassis 2G.VirtualTrafficGeneratorPort'):
            reservation_ports[get_family_attribute(context, port.Name, 'Logical Name').strip()] = port

        perfectstorms = [ps.FullAddress for ps in get_resources_from_reservation(context, PERFECT_STORM_CHASSIS_MODEL)]

        for name, element in config_elements.items():
            if name in reservation_ports:
                location = get_location(reservation_ports[name])
                ip, module, port = location.split('/')
                if ip in perfectstorms:
                    location = f'{ip}/{module}/{int(port) + 1}'
                self.logger.debug(f'Logical Port {name} will be reserved on Physical location {location}')
                element.reserve(location)
            else:
                elements = reservation_ports.keys()
                raise TgnError(f'Configuration element "{element}" not found in reservation elements {elements}')

        self.logger.info('Port Reservation Completed')
Beispiel #2
0
 def test_negative(self, driver: StcControllerShell2GDriver,
                   context: ResourceCommandContext) -> None:
     reservation_ports = get_resources_from_reservation(
         context, "STC Chassis Shell 2G.GenericTrafficGeneratorPort")
     assert len(reservation_ports) == 2
     set_family_attribute(context, reservation_ports[0].Name,
                          "Logical Name", "Port 1")
     set_family_attribute(context, reservation_ports[1].Name,
                          "Logical Name", "")
     with pytest.raises(TgnError):
         driver.load_config(
             context,
             Path(__file__).parent.joinpath("test_config.tcc"))
     set_family_attribute(context, reservation_ports[1].Name,
                          "Logical Name", "Port 1")
     with pytest.raises(TgnError):
         driver.load_config(
             context,
             Path(__file__).parent.joinpath("test_config.tcc"))
     set_family_attribute(context, reservation_ports[1].Name,
                          "Logical Name", "Port x")
     with pytest.raises(TgnError):
         driver.load_config(
             context,
             Path(__file__).parent.joinpath("test_config.tcc"))
     set_family_attribute(context, reservation_ports[1].Name,
                          "Logical Name", "Port 2")
    def load_config(self, context, stc_config_file_name):

        self.stc.load_config(stc_config_file_name)
        config_ports = self.stc.project.get_ports()

        reservation_ports = {}
        for port in get_resources_from_reservation(
                context, f"{STC_CHASSIS_MODEL}.GenericTrafficGeneratorPort"):
            reservation_ports[get_family_attribute(context, port.Name,
                                                   "Logical Name")] = port

        for name, port in config_ports.items():
            if name in reservation_ports:
                address = get_location(reservation_ports[name])
                self.logger.debug(
                    f"Logical Port {name} will be reserved on Physical location {address}"
                )
                if "offline-debug" not in reservation_ports[name].Name:
                    port.reserve(address, force=True, wait_for_up=False)
                else:
                    self.logger.debug(
                        f"Offline debug port {address} - no actual reservation"
                    )
            else:
                raise TgnError(
                    f'Configuration port "{port}" not found in reservation ports {reservation_ports.keys()}'
                )

        self.logger.info("Port Reservation Completed")
Beispiel #4
0
def context(session: CloudShellAPISession, test_helpers: TestHelpers,
            server: list) -> ResourceCommandContext:
    controller_address, controller_version, apikey, ports = server
    attributes = [
        AttributeNameValue(f'{IXLOAD_CONTROLLER_MODEL}.Address',
                           controller_address),
        AttributeNameValue(f'{IXLOAD_CONTROLLER_MODEL}.Controller Version',
                           controller_version),
        AttributeNameValue(f'{IXLOAD_CONTROLLER_MODEL}.ApiKey', apikey),
        AttributeNameValue(f'{IXLOAD_CONTROLLER_MODEL}.License Server',
                           '192.168.42.61'),
        AttributeNameValue(f'{IXLOAD_CONTROLLER_MODEL}.Licensing Mode',
                           'Perpetual')
    ]
    session.AddServiceToReservation(test_helpers.reservation_id,
                                    IXLOAD_CONTROLLER_MODEL, ALIAS, attributes)
    context = test_helpers.resource_command_context(service_name=ALIAS)
    session.AddResourcesToReservation(test_helpers.reservation_id, ports)
    reservation_ports = get_resources_from_reservation(
        context, f'{IXIA_CHASSIS_MODEL}.GenericTrafficGeneratorPort')
    set_family_attribute(context, reservation_ports[0].Name, 'Logical Name',
                         'Traffic1@Network1')
    set_family_attribute(context, reservation_ports[1].Name, 'Logical Name',
                         'Traffic2@Network2')
    yield context
Beispiel #5
0
 def _load_config(
     self,
     driver: StcControllerShell2GDriver,
     context: ResourceCommandContext,
     config_file: Path,
 ) -> None:
     reservation_ports = get_resources_from_reservation(
         context, f"{STC_CHASSIS_MODEL}.GenericTrafficGeneratorPort")
     set_family_attribute(context, reservation_ports[0].Name,
                          "Logical Name", "Port 1")
     set_family_attribute(context, reservation_ports[1].Name,
                          "Logical Name", "Port 2")
     driver.load_config(context, config_file.as_posix())
Beispiel #6
0
 def _load_config(
     self,
     session: CloudShellAPISession,
     context: ResourceCommandContext,
     config: Path,
 ) -> None:
     reservation_ports = get_resources_from_reservation(
         context, "STC Chassis Shell 2G.GenericTrafficGeneratorPort")
     set_family_attribute(context, reservation_ports[0].Name,
                          "Logical Name", "Port 1")
     set_family_attribute(context, reservation_ports[1].Name,
                          "Logical Name", "Port 2")
     cmd_inputs = [
         InputNameValue("config_file_location", config.as_posix())
     ]
     session.ExecuteCommand(get_reservation_id(context), ALIAS, "Service",
                            "load_config", cmd_inputs)
Beispiel #7
0
def context(session: CloudShellAPISession, test_helpers: TestHelpers,
            server: list) -> ResourceCommandContext:
    controller_address, controller_port, ports = server
    attributes = [
        AttributeNameValue(f"{STC_CONTROLLER_MODEL}.Address",
                           controller_address),
        AttributeNameValue(f"{STC_CONTROLLER_MODEL}.Controller TCP Port",
                           controller_port),
    ]
    session.AddServiceToReservation(test_helpers.reservation_id,
                                    STC_CONTROLLER_MODEL, ALIAS, attributes)
    context = test_helpers.resource_command_context(service_name=ALIAS)
    session.AddResourcesToReservation(test_helpers.reservation_id, ports)
    reservation_ports = get_resources_from_reservation(
        context, f"{STC_CHASSIS_MODEL}.GenericTrafficGeneratorPort")
    set_family_attribute(context, reservation_ports[0].Name, "Logical Name",
                         "Port 1")
    set_family_attribute(context, reservation_ports[1].Name, "Logical Name",
                         "Port 2")
    yield context