def set_attribute_value(self, cs_address, attribute_name, attribute_value): """ Set attribute value to the device :param cs_address: address, '192.168.42.240/1/21' :type cs_address: str :param attribute_name: attribute name, "Port Speed" :type attribute_name: str :param attribute_value: value, "10000" :type attribute_value: str :return: attribute value :rtype: cloudshell.layer_one.core.response.response_info.AttributeValueResponseInfo :raises Exception: if command failed Example: with self._cli_handler.config_mode_service() as session: command = AttributeCommandFactory.set_attribute_command(cs_address, attribute_name, attribute_value) session.send_command(command) return AttributeValueResponseInfo(attribute_value) """ if attribute_name == 'Auto Negotiation': with self._cli_handler.default_mode_service() as session: with ActionsManager(self._system_actions, session) as system_actions: system_actions.set_auto_negotiation( self._convert_port_address(cs_address), attribute_value) else: raise LayerOneDriverException( self.__class__.__name__, 'SetAttributeValue for address {} is not supported'.format( cs_address))
def map_clear_to(self, src_port, dst_ports): """ Remove simplex/multi-cast/duplex connection ending on the destination port :param src_port: src port address, '192.168.42.240/1/21' :type src_port: str :param dst_ports: list of dst ports addresses, ['192.168.42.240/1/21', '192.168.42.240/1/22'] :type dst_ports: list :return: None :raises Exception: if command failed Example: with self._cli_handler.config_mode_service() as session: _src_port = convert_port(src_port) for port in dst_ports: _dst_port = convert_port(port) session.send_command('map clear-to {0} {1}'.format(_src_port, _dst_port)) """ self._logger.info('MapClearTo, SrcPort: {0}, DstPorts: {1}'.format( src_port, ','.join(dst_ports))) with self._cli_handler.default_mode_service() as session: with ActionsManager(self._mapping_actions, session) as mapping_actions: mapping_actions.map_clear_to( self._convert_port_address(src_port), [self._convert_port_address(port) for port in dst_ports])
def map_clear(self, ports): """ Remove simplex/multi-cast/duplex connection ending on the destination port :param ports: ports, ['192.168.42.240/1/21', '192.168.42.240/1/22'] :type ports: list :return: None :raises Exception: if command failed Example: exceptions = [] with self._cli_handler.config_mode_service() as session: for port in ports: try: session.send_command('map clear {}'.format(convert_port(port))) except Exception as e: exceptions.append(str(e)) if exceptions: raise Exception('self.__class__.__name__', ','.join(exceptions)) """ self._logger.info('MapClear, Ports: {}'.format(','.join(ports))) with self._cli_handler.default_mode_service() as session: with ActionsManager(self._mapping_actions, session) as mapping_actions: mapping_actions.map_clear( [self._convert_port_address(port) for port in ports])
def map_tap(self, src_port, dst_ports): self._logger.info('MapTap, SrcPort: {0}, DstPorts: {1}'.format( src_port, ','.join(dst_ports))) with self._cli_handler.default_mode_service() as session: with ActionsManager(self._mapping_actions, session) as mapping_actions: mapping_actions.map_tap( self._convert_port_address(src_port), [self._convert_port_address(port) for port in dst_ports])
def set_state_id(self, state_id): """ Set synchronization state id to the device, called after Autoload or SyncFomDevice commands :param state_id: synchronization ID :type state_id: str :return: None :raises Exception: if command failed Example: # Obtain cli session with self._cli_handler.config_mode_service() as session: # Execute command session.send_command('set chassis name {}'.format(state_id)) """ with self._cli_handler.default_mode_service() as session: with ActionsManager(self._system_actions, session) as system_actions: system_actions.set_state_id(state_id)
def get_state_id(self): """ Check if CS synchronized with the device. :return: Synchronization ID, GetStateIdResponseInfo(-1) if not used :rtype: cloudshell.layer_one.core.response.response_info.GetStateIdResponseInfo :raises Exception: if command failed Example: # Obtain cli session with self._cli_handler.default_mode_service() as session: # Execute command chassis_name = session.send_command('show chassis name') return chassis_name """ with self._cli_handler.default_mode_service() as session: with ActionsManager(self._system_actions, session) as system_actions: return GetStateIdResponseInfo(system_actions.get_state_id())
def map_uni(self, src_port, dst_ports): """ Unidirectional mapping of two ports :param src_port: src port address, '192.168.42.240/1/21' :type src_port: str :param dst_ports: list of dst ports addresses, ['192.168.42.240/1/22', '192.168.42.240/1/23'] :type dst_ports: list :return: None :raises Exception: if command failed Example: with self._cli_handler.config_mode_service() as session: for dst_port in dst_ports: session.send_command('map {0} also-to {1}'.format(convert_port(src_port), convert_port(dst_port))) """ self._logger.info('MapUni, SrcPort: {0}, DstPorts: {1}'.format( src_port, ','.join(dst_ports))) with self._cli_handler.default_mode_service() as session: with ActionsManager(self._mapping_actions, session) as mapping_actions: mapping_actions.map_uni( self._convert_port_address(src_port), [self._convert_port_address(port) for port in dst_ports])
def map_bidi(self, src_port, dst_port): """ Create a bidirectional connection between source and destination ports :param src_port: src port address, '192.168.42.240/1/21' :type src_port: str :param dst_port: dst port address, '192.168.42.240/1/22' :type dst_port: str :return: None :raises Exception: if command failed Example: with self._cli_handler.config_mode_service() as session: session.send_command('map bidir {0} {1}'.format(convert_port(src_port), convert_port(dst_port))) """ self._logger.info('MapBidi, SrcPort: {0}, DstPort: {1}'.format( src_port, dst_port)) with self._cli_handler.default_mode_service() as session: with ActionsManager(self._mapping_actions, session) as mapping_actions: src_logical_port = self._convert_port_address(src_port) dst_logical_port = self._convert_port_address(dst_port) mapping_actions.map_bidi(src_logical_port, dst_logical_port)