示例#1
0
    def health_check(self, context):
        """Checks if the device is up and connectable
        :param ResourceCommandContext context: ResourceCommandContext object with all Resource
            Attributes inside
        :return: Success or fail message
        :rtype: str
        """

        logger = get_logger_with_thread_id(context)
        api = get_api(context)

        logger.info("CONTEXT: {}".format(context))
        logger.info("SHELL_NAME: {}".format(self.SHELL_NAME))
        logger.info("SUPPORTED_OS: {}".format(self.SUPPORTED_OS))

        resource_config = create_firewall_resource_from_context(
            shell_name=self.SHELL_NAME,
            supported_os=self.SUPPORTED_OS,
            context=context)

        logger.info("RESOURCE_CONFIG: {}".format(resource_config.__dict__))

        cli_handler = CliHandler(self._cli, resource_config, logger, api)

        state_operations = StateRunner(logger, api, resource_config,
                                       cli_handler)

        return state_operations.health_check()
    def health_check(self, context):
        """Checks if the device is up and connectable.

        :param ResourceCommandContext context: ResourceCommandContext object
         with all Resource Attributes inside
        :return: Success or fail message
        :rtype: str
        """
        logger = get_logger_with_thread_id(context)
        logger.info("Health check command started")

        with ErrorHandlingContext(logger):
            resource_config = create_firewall_resource_from_context(
                self.SHELL_NAME, self.SUPPORTED_OS, context
            )
            cs_api = get_api(context)

            cli_handler = F5CliHandler(self._cli, resource_config, logger, cs_api)

            state_operations = StateRunner(
                logger=logger,
                api=cs_api,
                resource_config=resource_config,
                cli_handler=cli_handler,
            )

            response = state_operations.health_check()
            logger.info("Health check command ended with response: {}".format(response))

            return response
    def shutdown(self, context):
        """Sends a graceful shutdown to the device.

        :param ResourceCommandContext context: The context object
         for the command with resource and reservation info
        """
        logger = get_logger_with_thread_id(context)
        logger.info("Shutdown command started")

        with ErrorHandlingContext(logger):
            resource_config = create_firewall_resource_from_context(
                self.SHELL_NAME, self.SUPPORTED_OS, context
            )
            cs_api = get_api(context)

            cli_handler = F5CliHandler(self._cli, resource_config, logger, cs_api)

            state_operations = StateRunner(
                logger=logger,
                api=cs_api,
                resource_config=resource_config,
                cli_handler=cli_handler,
            )

            response = state_operations.shutdown()
            logger.info("Shutdown command completed with response: {}".format(response))

            return response
示例#4
0
    def shutdown(self, context):
        logger = get_logger_with_thread_id(context)
        api = get_api(context)

        resource_config = create_networking_resource_from_context(shell_name=self.SHELL_NAME,
                                                                  supported_os=self.SUPPORTED_OS,
                                                                  context=context)
        cli_handler = JuniperCliHandler(self._cli, resource_config, logger, api)

        state_operations = StateRunner(logger, api, resource_config, cli_handler)
        return state_operations.shutdown()
    def shutdown(self, context):
        """Sends a graceful shutdown to the device

        :param ResourceCommandContext context: The context object for the command with resource and
            reservation info
        """

        logger = get_logger_with_thread_id(context)
        api = get_api(context)

        resource_config = create_resource_from_context(self.SHELL_NAME, self.SUPPORTED_OS, context)
        cli_handler = CliHandler(self._cli, resource_config, logger, api)

        state_operations = StateRunner(logger, api, resource_config, cli_handler)
        return state_operations.shutdown()
    def health_check(self, context):
        """Checks if the device is up and connectable

        :param ResourceCommandContext context: ResourceCommandContext object with all Resource
            Attributes inside
        :return: Success or fail message
        :rtype: str
        """

        logger = get_logger_with_thread_id(context)
        api = get_api(context)

        resource_config = create_resource_from_context(self.SHELL_NAME, self.SUPPORTED_OS, context)
        cli_handler = CliHandler(self._cli, resource_config, logger, api)

        state_operations = StateRunner(logger, api, resource_config, cli_handler)
        return state_operations.health_check()
示例#7
0
    def shutdown(self, context):
        """ Shutdown device

        :param ResourceCommandContext context: ResourceCommandContext object with all Resource Attributes inside
        :return:
        """

        logger = get_logger_with_thread_id(context)
        api = get_api(context)

        resource_config = create_networking_resource_from_context(shell_name=self.SHELL_NAME,
                                                                  supported_os=self.SUPPORTED_OS,
                                                                  context=context)

        cli_handler = CliHandler(self._cli, resource_config, logger, api)
        state_operations = StateRunner(logger=logger, api=api, resource_config=resource_config, cli_handler=cli_handler)

        return state_operations.shutdown()
示例#8
0
    def health_check(self, context):
        """Performs device health check

        :param ResourceCommandContext context: ResourceCommandContext object with all Resource Attributes inside
        :return: Success or Error message
        :rtype: str
        """

        logger = get_logger_with_thread_id(context)
        api = get_api(context)

        resource_config = create_networking_resource_from_context(shell_name=self.SHELL_NAME,
                                                                  supported_os=self.SUPPORTED_OS,
                                                                  context=context)
        cli_handler = CliHandler(self._cli, resource_config, logger, api)

        state_operations = StateRunner(logger=logger, api=api, resource_config=resource_config, cli_handler=cli_handler)
        return state_operations.health_check()
示例#9
0
    def health_check(self, context):
        """Performs device health check

        :param ResourceCommandContext context: ResourceCommandContext object with all Resource Attributes inside
        :return: Success or Error message
        :rtype: str
        """

        logger = get_logger_with_thread_id(context)
        api = get_api(context)

        resource_config = create_networking_resource_from_context(shell_name=self.SHELL_NAME,
                                                                  supported_os=self.SUPPORTED_OS,
                                                                  context=context)
        cli_handler = JuniperCliHandler(self._cli, resource_config, logger, api)

        state_operations = StateRunner(logger, api, resource_config, cli_handler)
        return state_operations.health_check()
    def shutdown(self, context):
        """ Shutdown device

        :param ResourceCommandContext context: ResourceCommandContext object with all Resource
            Attributes inside
        :return:
        """

        logger = get_logger_with_thread_id(context)
        api = get_api(context)

        resource_config = create_networking_resource_from_context(
            self.SHELL_NAME, self.SUPPORTED_OS, context)
        cli_handler = CliHandler(self._cli, resource_config, logger, api)

        state_operations = StateRunner(logger, api, resource_config,
                                       cli_handler)
        return state_operations.shutdown()