def load_config(self, context, xena_configs_folder):

        reservation_id = context.reservation.reservation_id
        my_api = CloudShellSessionContext(context).get_api()

        reservation_ports = get_reservation_resources(
            my_api, reservation_id,
            'Xena Chassis Shell 2G.GenericTrafficGeneratorPort')
        for reserved_port in reservation_ports:
            config = get_family_attribute(my_api, reserved_port,
                                          'Logical Name').Value.strip()
            address = get_address(reserved_port)
            self.logger.debug(
                'Configuration {} will be loaded on Physical location {}'.
                format(config, address))
            chassis = my_api.GetResourceDetails(
                reserved_port.Name.split('/')[0])
            encripted_password = my_api.GetAttributeValue(
                chassis.Name, 'Xena Chassis Shell 2G.Password').Value
            password = CloudShellSessionContext(
                context).get_api().DecryptPassword(encripted_password).Value
            tcp_port = my_api.GetAttributeValue(
                chassis.Name,
                'Xena Chassis Shell 2G.Controller TCP Port').Value
            if not tcp_port:
                tcp_port = '22611'
            ip, module, port = address.split('/')
            self.xm.session.add_chassis(ip, int(tcp_port), password)
            xena_port = XenaPort(self.xm.session.chassis_list[ip],
                                 '{}/{}'.format(module, port))
            xena_port.reserve(force=True)
            xena_port.load_config(
                path.join(xena_configs_folder, config) + '.xpc')
示例#2
0
def load_config(parsed_args):
    chassis = connect(parsed_args.log, parsed_args.chassis)

    with open(parsed_args.input) as f:
        commands = f.read().splitlines()

    for command in commands:
        if command.startswith(';'):
            port = XenaPort(chassis, command.split(':')[1].strip())
            port.reserve(force=True)
        elif command.startswith('P_LPTXMODE'):
            pass
        else:
            if not command.startswith('P_LPTXMODE'):
                port.send_command(command)

    for port in chassis.ports.values():
        port.release()
示例#3
0
    def reserve_ports(self, locations, force=False, reset=True):
        """ Reserve ports and reset factory defaults.

        XenaManager-2G -> Reserve/Relinquish Port.
        XenaManager-2G -> Reset port.

        :param locations: list of ports locations in the form <module/port> to reserve
        :param force: True - take forcefully, False - fail if port is reserved by other user
        :param reset: True - reset port, False - leave port configuration
        :return: ports dictionary (index: object)
        """

        for location in locations:
            port = XenaPort(parent=self, index=location)
            port.reserve(force)
            if reset:
                port.reset()

        return self.ports