Exemplo n.º 1
0
 def test_get_logger_returns_the_same_logger_for_a_given_name(
         self, logger_name):
     # -----------------------------------------------------------------------
     # WHEN
     # -----------------------------------------------------------------------
     logger1 = log.get_logger(logger_name)
     logger2 = log.get_logger(logger_name)
     # -----------------------------------------------------------------------
     # THEN
     # -----------------------------------------------------------------------
     self.assertIs(logger1, logger2)
Exemplo n.º 2
0
 def test_get_logger_returns_the_same_logger_for_a_given_name(
         self, logger_name):
     # -----------------------------------------------------------------------
     # WHEN
     # -----------------------------------------------------------------------
     logger1 = log.get_logger(logger_name)
     logger2 = log.get_logger(logger_name)
     # -----------------------------------------------------------------------
     # THEN
     # -----------------------------------------------------------------------
     self.assertIs(logger1, logger2)
Exemplo n.º 3
0
 def test_get_logger_returns_the_base_logger_for_no_name(self):
     # -----------------------------------------------------------------------
     # GIVEN
     # -----------------------------------------------------------------------
     base_logger = log.get_logger('proliantutils')
     # -----------------------------------------------------------------------
     # WHEN
     # -----------------------------------------------------------------------
     logger1 = log.get_logger(None)
     logger2 = log.get_logger('')
     # -----------------------------------------------------------------------
     # THEN
     # -----------------------------------------------------------------------
     self.assertIs(logger1, base_logger)
     self.assertIs(logger2, base_logger)
Exemplo n.º 4
0
 def test_get_logger_returns_the_base_logger_for_no_name(self):
     # -----------------------------------------------------------------------
     # GIVEN
     # -----------------------------------------------------------------------
     base_logger = log.get_logger('proliantutils')
     # -----------------------------------------------------------------------
     # WHEN
     # -----------------------------------------------------------------------
     logger1 = log.get_logger(None)
     logger2 = log.get_logger('')
     # -----------------------------------------------------------------------
     # THEN
     # -----------------------------------------------------------------------
     self.assertIs(logger1, base_logger)
     self.assertIs(logger2, base_logger)
Exemplo n.º 5
0
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

"""Common functionalities used by both RIBCL and RIS."""

import os
import re
import stat
import time

from proliantutils import exception
from proliantutils import log


LOG = log.get_logger(__name__)

ILO_VER_STR_PATTERN = r"\d+\.\d+"


def wait_for_operation_to_complete(
        has_operation_completed, retries=10, delay_bw_retries=5,
        delay_before_attempts=10, failover_exc=exception.IloError,
        failover_msg=("Operation did not complete even after multiple "
                      "attempts."), is_silent_loop_exit=False):
    """Attempts the provided operation for a specified number of times.

    If it runs out of attempts, then it raises an exception. On success,
    it breaks out of the loop.
    :param has_operation_completed: the method to retry and it needs to return
                                    a boolean to indicate success or failure.
Exemplo n.º 6
0
from proliantutils import log


POWER_STATE = {
    'ON': 'Yes',
    'OFF': 'No',
}

BOOT_MODE_CMDS = [
    'GET_CURRENT_BOOT_MODE',
    'GET_PENDING_BOOT_MODE',
    'GET_SUPPORTED_BOOT_MODE',
    'SET_PENDING_BOOT_MODE'
]

LOG = log.get_logger(__name__)


class MaskedRequestData(object):
    def __init__(self, request_data):
        self.request_data = request_data

    def __str__(self):
        request_data_copy = copy.deepcopy(self.request_data)
        xml_data = request_data_copy.get('data')
        if xml_data:
            xml_data = re.sub(r'USER_LOGIN="******"', r'USER_LOGIN="******"',
                              xml_data)
            xml_data = re.sub(r'PASSWORD="******"', r'PASSWORD="******"',
                              xml_data)
            request_data_copy['data'] = xml_data