示例#1
0
    def test_is_firmware_bundled_pass(self):
        """Determine whether firmware file is bundled."""
        self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
        with patch(builtin_path,
                   mock_open(read_data=b"firmwarexxxxxxxx")) as mock_file:
            firmware = NetAppESeriesFirmware()
            self.assertEqual(firmware.is_firmware_bundled(), False)

        self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
        with patch(builtin_path,
                   mock_open(read_data=self.BUNDLE_HEADER[:16])) as mock_file:
            firmware = NetAppESeriesFirmware()
            self.assertEqual(firmware.is_firmware_bundled(), True)
示例#2
0
 def test_check_firmware_compatibility_pass(self):
     """Verify proxy firmware compatibility."""
     self._set_args({
         "firmware": "test_firmware.dlp",
         "nvsram": "test_nvsram.dlp"
     })
     firmware = NetAppESeriesFirmware()
     with patch(self.SLEEP_FUNC, return_value=None):
         with patch(self.REQUEST_FUNC,
                    side_effect=[(200, {
                        "requestId": 1
                    }), (200, {
                        "checkRunning": True
                    }),
                                 (200, {
                                     "checkRunning":
                                     False,
                                     "results": [{
                                         "cfwFiles": [{
                                             "filename":
                                             "test_firmware.dlp"
                                         }]
                                     }]
                                 })]):
             firmware.proxy_check_firmware_compatibility()
示例#3
0
    def test_proxy_wait_for_upgrade_pass(self):
        """Verify proxy_wait_for_upgrade."""
        with patch(self.SLEEP_FUNC, return_value=None):
            self._set_args({
                "firmware": "test_firmware.dlp",
                "nvsram": "expected_nvsram.dlp"
            })
            firmware = NetAppESeriesFirmware()

            firmware.is_firmware_bundled = lambda: True
            with patch(self.REQUEST_FUNC,
                       side_effect=[(200, {
                           "status": "not_done"
                       }), (200, {
                           "status": "complete"
                       })]):
                firmware.proxy_wait_for_upgrade("1")

            firmware.is_firmware_bundled = lambda: False
            firmware.firmware_version = lambda: b"08.50.00.00"
            firmware.nvsram_version = lambda: b"expected_nvsram"
            with patch(self.REQUEST_FUNC,
                       side_effect=[(200, ["08.40.00.00"]),
                                    (200, ["not_expected_nvsram"]),
                                    (200, ["08.50.00.00"]),
                                    (200, ["expected_nvsram"])]):
                firmware.proxy_wait_for_upgrade("1")
示例#4
0
    def test_check_system_health_fail(self):
        """Validate check_system_health method throws proper exceptions."""
        self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
        firmware = NetAppESeriesFirmware()
        with patch("time.sleep", return_value=None):
            with self.assertRaisesRegexp(AnsibleFailJson,
                                         "Failed to initiate health check."):
                with patch(self.REQUEST_FUNC, return_value=(404, Exception())):
                    firmware.check_system_health()

            with self.assertRaisesRegexp(
                    AnsibleFailJson,
                    "Failed to retrieve health check status."):
                with patch(self.REQUEST_FUNC,
                           side_effect=[(200, {
                               "requestId": "1"
                           }), (404, Exception())]):
                    firmware.check_system_health()

            with self.assertRaisesRegexp(AnsibleFailJson,
                                         "Health check failed to complete."):
                with patch(self.REQUEST_FUNC,
                           side_effect=[(200, {
                               "requestId": "1"
                           }),
                                        (200, {
                                            "healthCheckRunning":
                                            True,
                                            "results": [{
                                                "processingTimeMS":
                                                120001
                                            }]
                                        })]):
                    firmware.check_system_health()
示例#5
0
    def test_proxy_wait_for_upgrade_fail(self):
        """Verify proxy_wait_for_upgrade throws expected exceptions."""
        with patch(self.SLEEP_FUNC, return_value=None):
            self._set_args({
                "firmware": "test_firmware.dlp",
                "nvsram": "test_nvsram.dlp"
            })
            firmware = NetAppESeriesFirmware()

            firmware.is_firmware_bundled = lambda: True
            with self.assertRaisesRegexp(
                    AnsibleFailJson,
                    "Failed to retrieve firmware upgrade status."):
                with patch(self.REQUEST_FUNC, return_value=Exception()):
                    firmware.proxy_wait_for_upgrade("1")

            firmware.is_firmware_bundled = lambda: False
            with self.assertRaisesRegexp(
                    AnsibleFailJson,
                    "Timed out waiting for firmware upgrade to complete."):
                with patch(self.REQUEST_FUNC, return_value=Exception()):
                    firmware.proxy_wait_for_upgrade("1")

            firmware.is_firmware_bundled = lambda: True
            with self.assertRaisesRegexp(
                    AnsibleFailJson, "Firmware upgrade failed to complete."):
                with patch(self.REQUEST_FUNC,
                           side_effect=[(200, {
                               "status": "not_done"
                           }), (200, {
                               "status": "failed"
                           })]):
                    firmware.proxy_wait_for_upgrade("1")
示例#6
0
    def test_nvsram_version(self):
        """Verify correct nvsram version is returned."""
        self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
        firmware = NetAppESeriesFirmware()

        with patch(builtin_path,
                   mock_open_with_iter(
                       read_data=self.NVSRAM_HEADER)) as mock_file:
            self.assertEqual(firmware.nvsram_version(), b"N280X-852834-D02")
示例#7
0
 def test_is_firmware_bundles_fail(self):
     """Verify non-firmware fails."""
     self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
     with patch(builtin_path,
                mock_open(read_data=b"xxxxxxxxxxxxxxxx")) as mock_file:
         firmware = NetAppESeriesFirmware()
         with self.assertRaisesRegexp(AnsibleFailJson,
                                      "Firmware file is invalid."):
             firmware.is_firmware_bundled()
示例#8
0
 def test_firmware_version(self):
     """Verify correct firmware version is returned."""
     self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
     firmware = NetAppESeriesFirmware()
     firmware.is_firmware_bundled = lambda: True
     with patch(builtin_path,
                mock_open_with_iter(
                    read_data=self.BUNDLE_HEADER)) as mock_file:
         self.assertEqual(firmware.firmware_version(), b"11.40.5")
示例#9
0
 def test_embedded_wait_for_upgrade_fail(self):
     """Verify controller reboot wait throws expected exceptions"""
     self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
     firmware = NetAppESeriesFirmware()
     with self.assertRaisesRegexp(
             AnsibleFailJson,
             "Timeout waiting for Santricity Web Services Embedded."):
         with patch(self.SLEEP_FUNC, return_value=None):
             with patch(self.BASE_REQUEST_FUNC, return_value=Exception()):
                 firmware.embedded_wait_for_upgrade()
示例#10
0
 def test_embedded_upgrade_fail(self):
     """Verify embedded upgrade throws expected exception."""
     self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
     firmware = NetAppESeriesFirmware()
     with self.assertRaisesRegexp(
             AnsibleFailJson, "Failed to upload and activate firmware."):
         with patch(self.CREATE_MULTIPART_FORMDATA_FUNC,
                    return_value=("", {})):
             with patch(self.REQUEST_FUNC, return_value=Exception()):
                 firmware.embedded_upgrade()
示例#11
0
    def test_proxy_check_upgrade_required_fail(self):
        """Verify proxy_check_upgrade_required throws expected exceptions."""
        self._set_args({
            "firmware": "test_firmware.dlp",
            "nvsram": "test_nvsram.dlp"
        })
        firmware = NetAppESeriesFirmware()

        firmware.firmware_version = lambda: b"08.42.50.00"
        firmware.nvsram_version = lambda: b"not_nvsram_version"
        with self.assertRaisesRegexp(
                AnsibleFailJson,
                "Failed to retrieve controller firmware information."):
            with patch(self.REQUEST_FUNC, return_value=Exception()):
                firmware.proxy_check_upgrade_required()

        with self.assertRaisesRegexp(
                AnsibleFailJson,
                "Failed to retrieve storage system's NVSRAM version."):
            with patch(self.REQUEST_FUNC,
                       side_effect=[(200, [{
                           "versionString": "08.42.50.00"
                       }]),
                                    Exception()]):
                firmware.is_firmware_bundled = lambda: True
                firmware.proxy_check_upgrade_required()

        with self.assertRaisesRegexp(
                AnsibleFailJson,
                "Failed to retrieve storage system's NVSRAM version."):
            with patch(self.REQUEST_FUNC,
                       side_effect=[(200, ["08.42.50.00"]),
                                    Exception()]):
                firmware.is_firmware_bundled = lambda: False
                firmware.proxy_check_upgrade_required()

        with self.assertRaisesRegexp(AnsibleFailJson,
                                     "Downgrades are not permitted."):
            with patch(self.REQUEST_FUNC,
                       side_effect=[(200, [{
                           "versionString": "08.42.50.00"
                       }]), (200, ["nvsram_version"])]):
                firmware.firmware_version = lambda: b"08.40.00.00"
                firmware.nvsram_version = lambda: "nvsram_version"
                firmware.is_firmware_bundled = lambda: True
                firmware.proxy_check_upgrade_required()

        with self.assertRaisesRegexp(AnsibleFailJson,
                                     "Downgrades are not permitted."):
            with patch(self.REQUEST_FUNC,
                       side_effect=[(200, ["08.42.50.00"]),
                                    (200, ["nvsram_version"])]):
                firmware.is_firmware_bundled = lambda: False
                firmware.proxy_check_upgrade_required()
示例#12
0
    def test_embedded_upgrade_pass(self):
        """Verify embedded upgrade function."""
        with patch(self.CREATE_MULTIPART_FORMDATA_FUNC, return_value=("", {})):
            with patch(self.SLEEP_FUNC, return_value=None):

                self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
                firmware = NetAppESeriesFirmware()
                with patch(self.REQUEST_FUNC, return_value=(200, "")):
                    with patch(
                            self.BASE_REQUEST_FUNC,
                            side_effect=[Exception(),
                                         Exception(), (200, "")]):
                        firmware.embedded_upgrade()
                        self.assertTrue(firmware.upgrade_in_progress)

                self._set_args({
                    "firmware": "test.dlp",
                    "nvsram": "test.dlp",
                    "wait_for_completion": True
                })
                firmware = NetAppESeriesFirmware()
                firmware.firmware_version = lambda: b"11.40.3R2"
                firmware.nvsram_version = lambda: b"N280X-842834-D02"
                with patch(self.REQUEST_FUNC,
                           return_value=(200, [{
                               "fwVersion": "08.42.30.05",
                               "nvsramVersion": "N280X-842834-D02",
                               "extendedSAData": {
                                   "codeVersions": [{
                                       "codeModule":
                                       "bundleDisplay",
                                       "versionString":
                                       "11.40.3R2"
                                   }]
                               }
                           }])):
                    firmware.embedded_upgrade()
                    self.assertFalse(firmware.upgrade_in_progress)
示例#13
0
    def test_embedded_check_nvsram_compatibility_fail(self):
        """Verify embedded nvsram compatibility fails with expected exceptions."""
        self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
        firmware = NetAppESeriesFirmware()

        with patch(self.CREATE_MULTIPART_FORMDATA_FUNC, return_value=("", {})):
            with self.assertRaisesRegexp(
                    AnsibleFailJson,
                    "Failed to retrieve NVSRAM compatibility results."):
                with patch(self.REQUEST_FUNC, return_value=Exception()):
                    firmware.embedded_check_nvsram_compatibility()

            with self.assertRaisesRegexp(AnsibleFailJson,
                                         "Invalid NVSRAM file."):
                with patch(self.REQUEST_FUNC,
                           return_value=(200, {
                               "signatureTestingPassed":
                               False,
                               "fileCompatible":
                               False,
                               "versionContents": [{
                                   "module":
                                   "nvsram",
                                   "bundledVersion":
                                   "N280X-842834-D02",
                                   "onboardVersion":
                                   "N280X-842834-D02"
                               }]
                           })):
                    firmware.embedded_check_nvsram_compatibility()

            with self.assertRaisesRegexp(AnsibleFailJson,
                                         "Incompatible NVSRAM file."):
                with patch(self.REQUEST_FUNC,
                           return_value=(200, {
                               "signatureTestingPassed":
                               True,
                               "fileCompatible":
                               False,
                               "versionContents": [{
                                   "module":
                                   "nvsram",
                                   "bundledVersion":
                                   "N280X-842834-D02",
                                   "onboardVersion":
                                   "N280X-842834-D02"
                               }]
                           })):
                    firmware.embedded_check_nvsram_compatibility()
示例#14
0
    def test_proxy_upload_and_check_compatibility_fail(self):
        """Verify proxy_upload_and_check_compatibility throws expected exceptions."""
        self._set_args({
            "firmware": "test_firmware.dlp",
            "nvsram": "test_nvsram.dlp"
        })
        firmware = NetAppESeriesFirmware()
        firmware.proxy_check_nvsram_compatibility = lambda: None
        with self.assertRaisesRegexp(
                AnsibleFailJson,
                "Failed to retrieve existing existing firmware files."):
            with patch(self.CREATE_MULTIPART_FORMDATA_FUNC,
                       return_value=("headers", "data")):
                with patch(self.REQUEST_FUNC, return_value=Exception()):
                    firmware.proxy_upload_and_check_compatibility()

        with self.assertRaisesRegexp(AnsibleFailJson,
                                     "Failed to upload NVSRAM file."):
            with patch(self.CREATE_MULTIPART_FORMDATA_FUNC,
                       return_value=("headers", "data")):
                with patch(self.REQUEST_FUNC,
                           side_effect=[(200, [{
                               "version": "XX.XX.XX.XX",
                               "filename": "test"
                           }, {
                               "version": "XXXXXXXXXX",
                               "filename": "test.dlp"
                           }]),
                                        Exception()]):
                    firmware.proxy_upload_and_check_compatibility()

        with self.assertRaisesRegexp(AnsibleFailJson,
                                     "Failed to upload firmware bundle file."):
            with patch(self.CREATE_MULTIPART_FORMDATA_FUNC,
                       return_value=("headers", "data")):
                with patch(self.REQUEST_FUNC,
                           side_effect=[(200, [{
                               "version": "XX.XX.XX.XX",
                               "filename": "test"
                           }, {
                               "version": "XXXXXXXXXX",
                               "filename": "test.dlp"
                           }]), (200, None),
                                        Exception()]):
                    firmware.proxy_upload_and_check_compatibility()
示例#15
0
    def test_embedded_check_firmware_compatibility_pass(self):
        """Verify embedded firmware compatibility."""
        self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
        firmware = NetAppESeriesFirmware()

        with patch(self.CREATE_MULTIPART_FORMDATA_FUNC, return_value=("", {})):
            with patch(self.REQUEST_FUNC,
                       return_value=(200, {
                           "signatureTestingPassed":
                           True,
                           "fileCompatible":
                           True,
                           "versionContents": [{
                               "module": "bundle",
                               "bundledVersion": "08.42.50.00.000",
                               "onboardVersion": "08.42.30.05"
                           }, {
                               "module": "bundleDisplay",
                               "bundledVersion": "11.40.5",
                               "onboardVersion": "11.40.3R2"
                           }, {
                               "module": "hypervisor",
                               "bundledVersion": "08.42.50.00",
                               "onboardVersion": "08.42.30.05"
                           }, {
                               "module": "raid",
                               "bundledVersion": "08.42.50.00",
                               "onboardVersion": "08.42.30.05"
                           }, {
                               "module":
                               "management",
                               "bundledVersion":
                               "11.42.0000.0028",
                               "onboardVersion":
                               "11.42.0000.0026"
                           }, {
                               "module":
                               "iom",
                               "bundledVersion":
                               "11.42.0G00.0003",
                               "onboardVersion":
                               "11.42.0G00.0001"
                           }]
                       })):
                firmware.embedded_check_bundle_compatibility()
示例#16
0
    def test_proxy_upgrade_fail(self):
        """Verify proxy_upgrade throws expected exceptions."""
        self._set_args({
            "firmware": "test_firmware.dlp",
            "nvsram": "test_nvsram.dlp"
        })
        firmware = NetAppESeriesFirmware()

        firmware.is_firmware_bundled = lambda: True
        with self.assertRaisesRegexp(AnsibleFailJson,
                                     "Failed to initiate firmware upgrade."):
            with patch(self.REQUEST_FUNC, return_value=Exception()):
                firmware.proxy_upgrade()

        firmware.is_firmware_bundled = lambda: False
        with self.assertRaisesRegexp(AnsibleFailJson,
                                     "Failed to initiate firmware upgrade."):
            with patch(self.REQUEST_FUNC, return_value=Exception()):
                firmware.proxy_upgrade()
示例#17
0
    def test_check_firmware_compatibility_fail(self):
        """Verify proxy firmware compatibility throws expected exceptions."""
        self._set_args({
            "firmware": "test_firmware.dlp",
            "nvsram": "test_nvsram.dlp"
        })
        firmware = NetAppESeriesFirmware()

        with patch(self.SLEEP_FUNC, return_value=None):
            with self.assertRaisesRegexp(
                    AnsibleFailJson,
                    "Failed to receive firmware compatibility information."):
                with patch(self.REQUEST_FUNC, return_value=Exception()):
                    firmware.proxy_check_firmware_compatibility()

            with self.assertRaisesRegexp(
                    AnsibleFailJson,
                    "Failed to retrieve firmware status update from proxy."):
                with patch(self.REQUEST_FUNC,
                           side_effect=[(200, {
                               "requestId": 1
                           }), Exception()]):
                    firmware.proxy_check_firmware_compatibility()

            with self.assertRaisesRegexp(AnsibleFailJson,
                                         "Firmware bundle is not compatible."):
                with patch(self.REQUEST_FUNC,
                           side_effect=[(200, {
                               "requestId": 1
                           }), (200, {
                               "checkRunning": True
                           }),
                                        (200, {
                                            "checkRunning":
                                            False,
                                            "results": [{
                                                "cfwFiles": [{
                                                    "filename":
                                                    "not_test_firmware.dlp"
                                                }]
                                            }]
                                        })]):
                    firmware.proxy_check_firmware_compatibility()
示例#18
0
 def test_embedded_wait_for_upgrade_pass(self):
     """Verify controller reboot wait succeeds."""
     self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
     firmware = NetAppESeriesFirmware()
     firmware.firmware_version = lambda: b"11.40.3R2"
     firmware.nvsram_version = lambda: b"N280X-842834-D02"
     with patch(self.SLEEP_FUNC, return_value=None):
         with patch(self.REQUEST_FUNC,
                    return_value=(200, [{
                        "fwVersion": "08.42.30.05",
                        "nvsramVersion": "N280X-842834-D02",
                        "extendedSAData": {
                            "codeVersions": [{
                                "codeModule": "bundleDisplay",
                                "versionString": "11.40.3R2"
                            }]
                        }
                    }])):
             firmware.embedded_wait_for_upgrade()
示例#19
0
 def test_check_system_health_pass(self):
     """Validate check_system_health method."""
     self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
     firmware = NetAppESeriesFirmware()
     with patch(self.REQUEST_FUNC,
                side_effect=[(200, {
                    "requestId": "1"
                }),
                             (200, {
                                 "healthCheckRunning": True,
                                 "results": [{
                                     "processingTimeMS": 0
                                 }]
                             }),
                             (200, {
                                 "healthCheckRunning": False,
                                 "results": [{
                                     "successful": True
                                 }]
                             })]):
         firmware.check_system_health()
示例#20
0
 def test_embedded_check_nvsram_compatibility_pass(self):
     """Verify embedded nvsram compatibility."""
     self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
     firmware = NetAppESeriesFirmware()
     with patch(self.CREATE_MULTIPART_FORMDATA_FUNC, return_value=("", {})):
         with patch(self.REQUEST_FUNC,
                    return_value=(200, {
                        "signatureTestingPassed":
                        True,
                        "fileCompatible":
                        True,
                        "versionContents": [{
                            "module":
                            "nvsram",
                            "bundledVersion":
                            "N280X-842834-D02",
                            "onboardVersion":
                            "N280X-842834-D02"
                        }]
                    })):
             firmware.embedded_check_nvsram_compatibility()
示例#21
0
    def test_proxy_upload_and_check_compatibility_pass(self):
        """Verify proxy_upload_and_check_compatibility"""
        self._set_args({
            "firmware": "test_firmware.dlp",
            "nvsram": "test_nvsram.dlp"
        })
        firmware = NetAppESeriesFirmware()
        firmware.proxy_check_nvsram_compatibility = lambda: None
        firmware.proxy_check_firmware_compatibility = lambda: None
        with patch(self.CREATE_MULTIPART_FORMDATA_FUNC,
                   return_value=("headers", "data")):
            with patch(self.REQUEST_FUNC,
                       side_effect=[(200, [{
                           "version": "XX.XX.XX.XX",
                           "filename": "test"
                       }, {
                           "version": "XXXXXXXXXX",
                           "filename": "test.dlp"
                       }]), (200, None), (200, None)]):
                firmware.proxy_upload_and_check_compatibility()

            with patch(self.REQUEST_FUNC,
                       return_value=(200, [{
                           "version": "XX.XX.XX.XX",
                           "filename": "test"
                       }, {
                           "version": "test_nvsram",
                           "filename": "test_nvsram.dlp"
                       }, {
                           "version": "test",
                           "filename": "test.dlp"
                       }, {
                           "filename": "test_firmware.dlp",
                           "version": "test_firmware"
                       }])):
                firmware.proxy_upload_and_check_compatibility()
示例#22
0
    def test_proxy_check_upgrade_required_pass(self):
        """Verify proxy_check_upgrade_required."""
        self._set_args({
            "firmware": "test_firmware.dlp",
            "nvsram": "test_nvsram.dlp"
        })
        firmware = NetAppESeriesFirmware()

        firmware.firmware_version = lambda: b"08.42.50.00"
        firmware.nvsram_version = lambda: b"nvsram_version"
        with patch(self.REQUEST_FUNC,
                   side_effect=[(200, [{
                       "versionString": "08.42.50.00"
                   }]), (200, ["nvsram_version"])]):
            firmware.is_firmware_bundled = lambda: True
            firmware.proxy_check_upgrade_required()
            self.assertFalse(firmware.upgrade_required)

        with patch(self.REQUEST_FUNC,
                   side_effect=[(200, ["08.42.50.00"]),
                                (200, ["nvsram_version"])]):
            firmware.is_firmware_bundled = lambda: False
            firmware.proxy_check_upgrade_required()
            self.assertFalse(firmware.upgrade_required)

        firmware.firmware_version = lambda: b"08.42.50.00"
        firmware.nvsram_version = lambda: b"not_nvsram_version"
        with patch(self.REQUEST_FUNC,
                   side_effect=[(200, [{
                       "versionString": "08.42.50.00"
                   }]), (200, ["nvsram_version"])]):
            firmware.is_firmware_bundled = lambda: True
            firmware.proxy_check_upgrade_required()
            self.assertTrue(firmware.upgrade_required)

        with patch(self.REQUEST_FUNC,
                   side_effect=[(200, ["08.42.50.00"]),
                                (200, ["nvsram_version"])]):
            firmware.is_firmware_bundled = lambda: False
            firmware.proxy_check_upgrade_required()
            self.assertTrue(firmware.upgrade_required)

        firmware.firmware_version = lambda: b"08.52.00.00"
        firmware.nvsram_version = lambda: b"nvsram_version"
        with patch(self.REQUEST_FUNC,
                   side_effect=[(200, [{
                       "versionString": "08.42.50.00"
                   }]), (200, ["nvsram_version"])]):
            firmware.is_firmware_bundled = lambda: True
            firmware.proxy_check_upgrade_required()
            self.assertTrue(firmware.upgrade_required)

        with patch(self.REQUEST_FUNC,
                   side_effect=[(200, ["08.42.50.00"]),
                                (200, ["nvsram_version"])]):
            firmware.is_firmware_bundled = lambda: False
            firmware.proxy_check_upgrade_required()
            self.assertTrue(firmware.upgrade_required)

        firmware.firmware_version = lambda: b"08.52.00.00"
        firmware.nvsram_version = lambda: b"not_nvsram_version"
        with patch(self.REQUEST_FUNC,
                   side_effect=[(200, [{
                       "versionString": "08.42.50.00"
                   }]), (200, ["nvsram_version"])]):
            firmware.is_firmware_bundled = lambda: True
            firmware.proxy_check_upgrade_required()
            self.assertTrue(firmware.upgrade_required)

        with patch(self.REQUEST_FUNC,
                   side_effect=[(200, ["08.42.50.00"]),
                                (200, ["nvsram_version"])]):
            firmware.is_firmware_bundled = lambda: False
            firmware.proxy_check_upgrade_required()
            self.assertTrue(firmware.upgrade_required)
示例#23
0
    def test_embedded_check_firmware_compatibility_fail(self):
        """Verify embedded firmware compatibility fails with expected exceptions."""
        self._set_args({"firmware": "test.dlp", "nvsram": "test.dlp"})
        firmware = NetAppESeriesFirmware()

        with self.assertRaisesRegexp(
                AnsibleFailJson,
                "Failed to retrieve bundle compatibility results."):
            with patch(self.CREATE_MULTIPART_FORMDATA_FUNC,
                       return_value=("", {})):
                with patch(self.REQUEST_FUNC, return_value=Exception()):
                    firmware.embedded_check_bundle_compatibility()

        with self.assertRaisesRegexp(AnsibleFailJson,
                                     "Invalid firmware bundle file."):
            with patch(self.CREATE_MULTIPART_FORMDATA_FUNC,
                       return_value=("", {})):
                with patch(self.REQUEST_FUNC,
                           return_value=(200, {
                               "signatureTestingPassed":
                               False,
                               "fileCompatible":
                               True,
                               "versionContents": [{
                                   "module":
                                   "bundle",
                                   "bundledVersion":
                                   "08.42.50.00.000",
                                   "onboardVersion":
                                   "08.42.30.05"
                               }, {
                                   "module":
                                   "bundleDisplay",
                                   "bundledVersion":
                                   "11.40.5",
                                   "onboardVersion":
                                   "11.40.3R2"
                               }, {
                                   "module":
                                   "hypervisor",
                                   "bundledVersion":
                                   "08.42.50.00",
                                   "onboardVersion":
                                   "08.42.30.05"
                               }, {
                                   "module":
                                   "raid",
                                   "bundledVersion":
                                   "08.42.50.00",
                                   "onboardVersion":
                                   "08.42.30.05"
                               }, {
                                   "module":
                                   "management",
                                   "bundledVersion":
                                   "11.42.0000.0028",
                                   "onboardVersion":
                                   "11.42.0000.0026"
                               }, {
                                   "module":
                                   "iom",
                                   "bundledVersion":
                                   "11.42.0G00.0003",
                                   "onboardVersion":
                                   "11.42.0G00.0001"
                               }]
                           })):
                    firmware.embedded_check_bundle_compatibility()

        with self.assertRaisesRegexp(AnsibleFailJson,
                                     "Incompatible firmware bundle file."):
            with patch(self.CREATE_MULTIPART_FORMDATA_FUNC,
                       return_value=("", {})):
                with patch(self.REQUEST_FUNC,
                           return_value=(200, {
                               "signatureTestingPassed":
                               True,
                               "fileCompatible":
                               False,
                               "versionContents": [{
                                   "module":
                                   "bundle",
                                   "bundledVersion":
                                   "08.42.50.00.000",
                                   "onboardVersion":
                                   "08.42.30.05"
                               }, {
                                   "module":
                                   "bundleDisplay",
                                   "bundledVersion":
                                   "11.40.5",
                                   "onboardVersion":
                                   "11.40.3R2"
                               }, {
                                   "module":
                                   "hypervisor",
                                   "bundledVersion":
                                   "08.42.50.00",
                                   "onboardVersion":
                                   "08.42.30.05"
                               }, {
                                   "module":
                                   "raid",
                                   "bundledVersion":
                                   "08.42.50.00",
                                   "onboardVersion":
                                   "08.42.30.05"
                               }, {
                                   "module":
                                   "management",
                                   "bundledVersion":
                                   "11.42.0000.0028",
                                   "onboardVersion":
                                   "11.42.0000.0026"
                               }, {
                                   "module":
                                   "iom",
                                   "bundledVersion":
                                   "11.42.0G00.0003",
                                   "onboardVersion":
                                   "11.42.0G00.0001"
                               }]
                           })):
                    firmware.embedded_check_bundle_compatibility()

        with self.assertRaisesRegexp(AnsibleFailJson,
                                     "Downgrades are not permitted."):
            with patch(self.CREATE_MULTIPART_FORMDATA_FUNC,
                       return_value=("", {})):
                with patch(self.REQUEST_FUNC,
                           return_value=(200, {
                               "signatureTestingPassed":
                               True,
                               "fileCompatible":
                               True,
                               "versionContents": [{
                                   "module":
                                   "bundle",
                                   "bundledVersion":
                                   "08.42.00.00.000",
                                   "onboardVersion":
                                   "08.50.30.05"
                               }, {
                                   "module":
                                   "bundleDisplay",
                                   "bundledVersion":
                                   "11.40.5",
                                   "onboardVersion":
                                   "11.40.3R2"
                               }, {
                                   "module":
                                   "hypervisor",
                                   "bundledVersion":
                                   "08.42.50.00",
                                   "onboardVersion":
                                   "08.42.30.05"
                               }, {
                                   "module":
                                   "raid",
                                   "bundledVersion":
                                   "08.42.50.00",
                                   "onboardVersion":
                                   "08.42.30.05"
                               }, {
                                   "module":
                                   "management",
                                   "bundledVersion":
                                   "11.42.0000.0028",
                                   "onboardVersion":
                                   "11.42.0000.0026"
                               }, {
                                   "module":
                                   "iom",
                                   "bundledVersion":
                                   "11.42.0G00.0003",
                                   "onboardVersion":
                                   "11.42.0G00.0001"
                               }]
                           })):
                    firmware.embedded_check_bundle_compatibility()
        with self.assertRaisesRegexp(AnsibleFailJson,
                                     "Downgrades are not permitted."):
            with patch(self.CREATE_MULTIPART_FORMDATA_FUNC,
                       return_value=("", {})):
                with patch(self.REQUEST_FUNC,
                           return_value=(200, {
                               "signatureTestingPassed":
                               True,
                               "fileCompatible":
                               True,
                               "versionContents": [{
                                   "module":
                                   "bundle",
                                   "bundledVersion":
                                   "08.42.00.00.000",
                                   "onboardVersion":
                                   "09.20.30.05"
                               }, {
                                   "module":
                                   "bundleDisplay",
                                   "bundledVersion":
                                   "11.40.5",
                                   "onboardVersion":
                                   "11.40.3R2"
                               }, {
                                   "module":
                                   "hypervisor",
                                   "bundledVersion":
                                   "08.42.50.00",
                                   "onboardVersion":
                                   "08.42.30.05"
                               }, {
                                   "module":
                                   "raid",
                                   "bundledVersion":
                                   "08.42.50.00",
                                   "onboardVersion":
                                   "08.42.30.05"
                               }, {
                                   "module":
                                   "management",
                                   "bundledVersion":
                                   "11.42.0000.0028",
                                   "onboardVersion":
                                   "11.42.0000.0026"
                               }, {
                                   "module":
                                   "iom",
                                   "bundledVersion":
                                   "11.42.0G00.0003",
                                   "onboardVersion":
                                   "11.42.0G00.0001"
                               }]
                           })):
                    firmware.embedded_check_bundle_compatibility()