def get_termination_status()

in source/ecs/workspaces_helper.py [0:0]


    def get_termination_status(self, workspace_id, billable_time, tags):
        """
        This method returns whether the workspace needs to be terminated.
        :param workspace_id:
        :param billable_time:
        :param tags:
        :return: 'Yes' if the workspace is terminated and '' if not.
        """

        log.debug("Today is {}".format(today))
        log.debug("Last day is {}".format(last_day))
        log.debug("Getting the termination status for workspace: {}, billable time: {} and tags {}".
                  format(workspace_id, billable_time, tags))
        log.debug("Terminate unused workspaces parameter is set to {}".format(TERMINATE_UNUSED_WORKSPACES))
        log.debug("Current month first day is {}".format(current_month_first_day))
        workspace_terminated = ''
        try:  # change this back after testing
            if (TERMINATE_UNUSED_WORKSPACES == "Yes" or TERMINATE_UNUSED_WORKSPACES == "Dry Run") and today == last_day:
                log.debug("Today is the last day of the month. Processing further.")
                last_known_user_connection_timestamp = self.get_last_known_user_connection_timestamp(workspace_id)
                workspace_used_in_current_month = self.check_workspace_usage_for_current_month(
                    last_known_user_connection_timestamp)
                workspace_available_on_first_day_of_month = self.check_if_workspace_available_on_first_day(workspace_id)
                log.debug(
                    "For workspace {}, billable time is {}, tags are {}, workspace_available_on_first_day_of_month"
                    " is {}, workspace_used_in_current_month is {}".format(workspace_id, billable_time, tags,
                                                                           workspace_available_on_first_day_of_month,
                                                                           workspace_used_in_current_month))
                if not workspace_used_in_current_month and workspace_available_on_first_day_of_month and billable_time == 0:
                    log.debug("The workspace {} was not used in current month. Checking other criteria for "
                              "termination.".format(workspace_id))
                    workspace_terminated = self.check_if_workspace_needs_to_be_terminated(workspace_id)
        except Exception as error:
            log.error("Error {} while checking the workspace termination status for workspace : {}".format(error,
                                                                                                           workspace_id))
        log.debug("Returning the termination status as {}".format(workspace_terminated))
        return workspace_terminated