def get_attribute_value(self, cs_address, attribute_name):
        """
        Retrieve attribute value from 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
        :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.get_attribute_command(cs_address, attribute_name)
                value = session.send_command(command)
                return AttributeValueResponseInfo(value)
        """
        if attribute_name == 'Serial Number':
            if len(cs_address.split('/')) == 1:
                with self._cli_handler.default_mode_service() as session:
                    autoload_actions = AutoloadActions(session, self._logger)
                    board_table = autoload_actions.board_table()
                    return AttributeValueResponseInfo(
                        board_table.get('chassis-serial'))
            else:
                return AttributeValueResponseInfo('NA')
        else:
            raise LayerOneDriverException(
                self.__class__.__name__,
                'GetAttributeValue command is not supported')
Beispiel #2
0
    def get_attribute_value(self, cs_address, attribute_name):
        """
        Retrieve attribute value from 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
        :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.get_attribute_command(cs_address, attribute_name)
                value = session.send_command(command)
                return AttributeValueResponseInfo(value)
        """
        serial_number = 'Serial Number'
        if len(cs_address.split('/')) == 1 and attribute_name == serial_number:
            return AttributeValueResponseInfo(self.chassis_sn)
        else:
            raise Exception(
                self.__class__.__name__,
                'Attribute {0} for {1} is not available'.format(
                    attribute_name, cs_address))
 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
     """
     address = Address.from_cs_address(cs_address)
     if address.is_chassis() or address.is_slot():
         raise LayerOneDriverException(
             self.__class__.__name__,
             'SetAttributeValue for Chassis or Slot/Blade is not supported')
     else:
         attribute_setter = self._ports_attributes_setters.get(
             attribute_name)
         if attribute_setter:
             attribute_setter(address, attribute_value)
         else:
             raise LayerOneDriverException(
                 self.__class__.__name__,
                 'SetAttributeValue is not supported for attribute {}'.
                 format(attribute_name))
         return AttributeValueResponseInfo(attribute_value)
Beispiel #4
0
    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)
        """
        return AttributeValueResponseInfo(attribute_value)
Beispiel #5
0
    def get_attribute_value(self, cs_address, attribute_name):
        """
        Retrieve attribute value from 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
        :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.get_attribute_command(cs_address, attribute_name)
                value = session.send_command(command)
                return AttributeValueResponseInfo(value)
        """
        self._logger.info("@get_attribute_value {0} for {1}".format(
            attribute_name, cs_address))
        # TODO: Need to implement
        return AttributeValueResponseInfo("")
Beispiel #6
0
    def get_attribute_value(self, cs_address, attribute_name):
        """Retrieve attribute value from the device.

        :param cs_address: address, '192.168.42.240:A/A/21'
        :type cs_address: str
        :param attribute_name: attribute name, "Port Speed"
        :type attribute_name: str
        :return: attribute value
        :rtype: cloudshell.layer_one.core.response.response_info.AttributeValueResponseInfo
        :raises Exception: if command failed
        """
        serial_number = 'Serial Number'
        if len(cs_address.split('/')) == 1 and attribute_name == serial_number:
            with self._get_cli_services_lst() as cli_services_lst:
                system_actions = SystemActions(cli_services_lst, self._logger)
                board_tables_map = system_actions.get_board_tables_map()
            return AttributeValueResponseInfo(
                board_tables_map.values()[0].get('serial_number'))
        else:
            msg = 'Attribute {} for {} is not available'.format(
                attribute_name, cs_address)
            raise BaseRomeException(msg)