Example #1
0
    def test_remove_image_from_swift(self, swift_api_mock):
        # | GIVEN |
        self.config(swift_ilo_container="ilo_container", group="ilo")
        container = CONF.ilo.swift_ilo_container

        swift_obj_mock = swift_api_mock.return_value
        object_name = "object_name"
        # | WHEN |
        ilo_common.remove_image_from_swift(object_name)
        # | THEN |
        swift_obj_mock.delete_object.assert_called_once_with(container, object_name)
Example #2
0
    def test_remove_image_from_swift(self, swift_api_mock):
        # | GIVEN |
        self.config(swift_ilo_container='ilo_container', group='ilo')
        container = CONF.ilo.swift_ilo_container

        swift_obj_mock = swift_api_mock.return_value
        object_name = 'object_name'
        # | WHEN |
        ilo_common.remove_image_from_swift(object_name)
        # | THEN |
        swift_obj_mock.delete_object.assert_called_once_with(
            container, object_name)
Example #3
0
    def test_remove_image_from_swift_suppresses_notfound_exc(self, swift_api_mock, LOG_mock):
        # | GIVEN |
        self.config(swift_ilo_container="ilo_container", group="ilo")
        container = CONF.ilo.swift_ilo_container

        swift_obj_mock = swift_api_mock.return_value
        object_name = "object_name"
        raised_exc = exception.SwiftObjectNotFoundError(
            operation="delete_object", object=object_name, container=container
        )
        swift_obj_mock.delete_object.side_effect = raised_exc
        # | WHEN |
        ilo_common.remove_image_from_swift(object_name)
        # | THEN |
        LOG_mock.warning.assert_called_once_with(mock.ANY, {"associated_with_msg": "", "err": raised_exc})
Example #4
0
    def test_remove_image_from_swift_suppresses_notfound_exc(
            self, swift_api_mock, LOG_mock):
        # | GIVEN |
        self.config(swift_ilo_container='ilo_container', group='ilo')
        container = CONF.ilo.swift_ilo_container

        swift_obj_mock = swift_api_mock.return_value
        object_name = 'object_name'
        raised_exc = exception.SwiftObjectNotFoundError(
            operation='delete_object', object=object_name, container=container)
        swift_obj_mock.delete_object.side_effect = raised_exc
        # | WHEN |
        ilo_common.remove_image_from_swift(object_name)
        # | THEN |
        LOG_mock.warning.assert_called_once_with(
            mock.ANY, {'associated_with_msg': "", 'err': raised_exc})
Example #5
0
    def test_remove_image_from_swift_suppresses_operror_exc(
            self, swift_api_mock, LOG_mock):
        # | GIVEN |
        self.config(swift_ilo_container='ilo_container', group='ilo')
        container = CONF.ilo.swift_ilo_container

        swift_obj_mock = swift_api_mock.return_value
        object_name = 'object_name'
        raised_exc = exception.SwiftOperationError(operation='delete_object',
                                                   error='failed')
        swift_obj_mock.delete_object.side_effect = raised_exc
        # | WHEN |
        ilo_common.remove_image_from_swift(object_name, 'alice_in_wonderland')
        # | THEN |
        LOG_mock.exception.assert_called_once_with(
            mock.ANY, {'object_name': object_name, 'container': container,
                       'associated_with_msg': ("associated with "
                                               "alice_in_wonderland"),
                       'err': raised_exc})
Example #6
0
    def test_remove_image_from_swift_suppresses_operror_exc(
            self, swift_api_mock, LOG_mock):
        # | GIVEN |
        self.config(swift_ilo_container='ilo_container', group='ilo')
        container = CONF.ilo.swift_ilo_container

        swift_obj_mock = swift_api_mock.return_value
        object_name = 'object_name'
        raised_exc = exception.SwiftOperationError(operation='delete_object',
                                                   error='failed')
        swift_obj_mock.delete_object.side_effect = raised_exc
        # | WHEN |
        ilo_common.remove_image_from_swift(object_name, 'alice_in_wonderland')
        # | THEN |
        LOG_mock.exception.assert_called_once_with(
            mock.ANY, {'object_name': object_name, 'container': container,
                       'associated_with_msg': ("associated with "
                                               "alice_in_wonderland"),
                       'err': raised_exc})
Example #7
0
    def test_remove_image_from_swift_suppresses_operror_exc(self, swift_api_mock, LOG_mock):
        # | GIVEN |
        self.config(swift_ilo_container="ilo_container", group="ilo")
        container = CONF.ilo.swift_ilo_container

        swift_obj_mock = swift_api_mock.return_value
        object_name = "object_name"
        raised_exc = exception.SwiftOperationError(operation="delete_object", error="failed")
        swift_obj_mock.delete_object.side_effect = raised_exc
        # | WHEN |
        ilo_common.remove_image_from_swift(object_name, "alice_in_wonderland")
        # | THEN |
        LOG_mock.exception.assert_called_once_with(
            mock.ANY,
            {
                "object_name": object_name,
                "container": container,
                "associated_with_msg": ("associated with " "alice_in_wonderland"),
                "err": raised_exc,
            },
        )
Example #8
0
def _remove_swift_based_me(self):
    """Removes swift based firmware image location (by its object name)"""
    ilo_common.remove_image_from_swift(self.fw_image_filename,
                                       "firmware update")
Example #9
0
def _remove_swift_based_me(self):
    """Removes swift based firmware image location (by its object name)"""
    ilo_common.remove_image_from_swift(self.fw_image_filename,
                                       "firmware update")