Beispiel #1
0
 def test_update_name_pass(self):
     """Verify update_name passes successfully."""
     self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 90, "default_host_type": "Windows", "automatic_load_balancing": "disabled",
                     "host_connectivity_reporting": "disabled", "name": "array2"})
     instance = NetAppESeriesGlobalSettings()
     instance.get_current_configuration = lambda: {"autoload_capable": True, "autoload_enabled": True, "cache_block_size_options": [16384, 32768],
                                                   "cache_settings": {"cache_block_size": 32768, "cache_flush_threshold": 80},
                                                   "default_host_type_index": 28, "host_connectivity_reporting_enabled": True,
                                                   "host_type_options": {"windows": 1, "linux": 28}, "name": 'array1'}
     with patch(self.REQ_FUNC, return_value=(200, None)):
         instance.update_name()
Beispiel #2
0
 def test_change_name_required_fail(self):
     """Verify change_name_required throws expected exceptions"""
     self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 90, "default_host_type": "NotAHostType", "automatic_load_balancing": "enabled",
                     "host_connectivity_reporting": "enabled", "name": "A" * 31})
     instance = NetAppESeriesGlobalSettings()
     instance.get_current_configuration = lambda: {"autoload_capable": False, "autoload_enabled": True, "cache_block_size_options": [16384, 32768],
                                                   "cache_settings": {"cache_block_size": 32768, "cache_flush_threshold": 80},
                                                   "default_host_type_index": 28, "host_connectivity_reporting_enabled": True,
                                                   "host_type_options": {"windows": 1, "linux": 28}, "name": 'array1'}
     with self.assertRaisesRegexp(AnsibleFailJson, r"The provided name is invalid, it must be less than or equal to 30 characters in length."):
         self.assertTrue(instance.change_name_required())
Beispiel #3
0
 def test_cache_block_size_fail(self):
     """Verify cache_block_size throws expected exceptions."""
     self._set_args({"cache_block_size": 16384, "cache_flush_threshold": 80, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled",
                     "host_connectivity_reporting": "enabled", "name": "array1"})
     instance = NetAppESeriesGlobalSettings()
     instance.get_current_configuration = lambda: {"autoload_capable": False, "autoload_enabled": True, "cache_block_size_options": [32768],
                                                   "cache_settings": {"cache_block_size": 32768, "cache_flush_threshold": 90},
                                                   "default_host_type_index": 28, "host_connectivity_reporting_enabled": True,
                                                   "host_type_options": {}, "name": 'array1'}
     with self.assertRaisesRegexp(AnsibleFailJson, r"Invalid cache block size."):
         self.assertTrue(instance.change_cache_block_size_required())
Beispiel #4
0
 def test_get_current_configuration_pass(self):
     """Ensure get_current_configuration method succeeds."""
     self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 80, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled",
                     "host_connectivity_reporting": "enabled", "name": "array1"})
     instance = NetAppESeriesGlobalSettings()
     with patch(self.REQ_FUNC, side_effect=[(200, {"productCapabilities": [], "featureParameters": {"cacheBlockSizes": []}}), (200, []),
                                            (200, [{"defaultHostTypeIndex": 28, "cache": {"cacheBlkSize": 32768, "demandFlushThreshold": 90}}]),
                                            (200, {"autoLoadBalancingEnabled": True, "hostConnectivityReportingEnabled": True, "name": "array1"})]):
         self.assertEqual(instance.get_current_configuration(), {"autoload_capable": False, "autoload_enabled": True, "cache_block_size_options": [],
                                                                 "cache_settings": {"cache_block_size": 32768, "cache_flush_threshold": 90},
                                                                 "default_host_type_index": 28, "host_connectivity_reporting_enabled": True,
                                                                 "host_type_options": {}, "name": 'array1'})
Beispiel #5
0
 def test_update_name_fail(self):
     """Verify update_name throws expected exceptions"""
     self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 90, "default_host_type": "Windows", "automatic_load_balancing": "disabled",
                     "host_connectivity_reporting": "disabled", "name": "array2"})
     instance = NetAppESeriesGlobalSettings()
     instance.get_current_configuration = lambda: {"autoload_capable": True, "autoload_enabled": True, "cache_block_size_options": [16384, 32768],
                                                   "cache_settings": {"cache_block_size": 32768, "cache_flush_threshold": 80},
                                                   "default_host_type_index": 28, "host_connectivity_reporting_enabled": True,
                                                   "host_type_options": {"windows": 1, "linux": 28}, "name": 'array1'}
     with self.assertRaisesRegexp(AnsibleFailJson, r"Failed to set the storage array name!"):
         with patch(self.REQ_FUNC, return_value=Exception()):
             instance.update_name()
Beispiel #6
0
    def test_init_pass(self):
        """Verify module instantiates successfully."""
        self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 80, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled",
                        "host_connectivity_reporting": "enabled", "name": "array1"})
        instance = NetAppESeriesGlobalSettings()

        self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 80, "default_host_type": "linux dm-mp", "automatic_load_balancing": "disabled",
                        "host_connectivity_reporting": "disabled", "name": "array1"})
        instance = NetAppESeriesGlobalSettings()

        self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 80, "default_host_type": "linux dm-mp", "automatic_load_balancing": "disabled",
                        "host_connectivity_reporting": "enabled", "name": "array1"})
        instance = NetAppESeriesGlobalSettings()
Beispiel #7
0
    def test_cache_block_size_pass(self):
        """Verify cache_block_size passes successfully."""
        self._set_args({"cache_flush_threshold": 80, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled",
                        "host_connectivity_reporting": "enabled", "name": "array1"})
        instance = NetAppESeriesGlobalSettings()
        instance.get_current_configuration = lambda: {"autoload_capable": False, "autoload_enabled": True, "cache_block_size_options": [16384, 32768],
                                                      "cache_settings": {"cache_block_size": 32768, "cache_flush_threshold": 90},
                                                      "default_host_type_index": 28, "host_connectivity_reporting_enabled": True,
                                                      "host_type_options": {}, "name": 'array1'}
        self.assertFalse(instance.change_cache_block_size_required())

        self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 80, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled",
                        "host_connectivity_reporting": "enabled", "name": "array1"})
        instance = NetAppESeriesGlobalSettings()
        instance.get_current_configuration = lambda: {"autoload_capable": False, "autoload_enabled": True, "cache_block_size_options": [16384, 32768],
                                                      "cache_settings": {"cache_block_size": 32768, "cache_flush_threshold": 90},
                                                      "default_host_type_index": 28, "host_connectivity_reporting_enabled": True,
                                                      "host_type_options": {}, "name": 'array1'}
        self.assertFalse(instance.change_cache_block_size_required())

        self._set_args({"cache_block_size": 16384, "cache_flush_threshold": 80, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled",
                        "host_connectivity_reporting": "enabled", "name": "array1"})
        instance = NetAppESeriesGlobalSettings()
        instance.get_current_configuration = lambda: {"autoload_capable": False, "autoload_enabled": True, "cache_block_size_options": [16384, 32768],
                                                      "cache_settings": {"cache_block_size": 32768, "cache_flush_threshold": 90},
                                                      "default_host_type_index": 28, "host_connectivity_reporting_enabled": True,
                                                      "host_type_options": {}, "name": 'array1'}
        self.assertTrue(instance.change_cache_block_size_required())
Beispiel #8
0
    def test_get_current_configuration_fail(self):
        """Ensure exceptions are thrown when current configuration requests fail."""
        self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 80, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled",
                        "host_connectivity_reporting": "enabled", "name": "array1"})
        instance = NetAppESeriesGlobalSettings()
        with self.assertRaisesRegexp(AnsibleFailJson, r"Failed to retrieve storage array capabilities."):
            with patch(self.REQ_FUNC, side_effect=[Exception()]):
                instance.get_current_configuration()

        self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 80, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled",
                        "host_connectivity_reporting": "enabled", "name": "array1"})
        instance = NetAppESeriesGlobalSettings()
        with self.assertRaisesRegexp(AnsibleFailJson, r"Failed to retrieve storage array host options."):
            with patch(self.REQ_FUNC, side_effect=[(200, {"productCapabilities": [], "featureParameters": {"cacheBlockSizes": []}}), Exception()]):
                instance.get_current_configuration()

        self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 80, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled",
                        "host_connectivity_reporting": "enabled", "name": "array1"})
        instance = NetAppESeriesGlobalSettings()
        with self.assertRaisesRegexp(AnsibleFailJson, r"Failed to retrieve cache settings."):
            with patch(self.REQ_FUNC, side_effect=[(200, {"productCapabilities": [], "featureParameters": {"cacheBlockSizes": []}}), (200, []), Exception()]):
                instance.get_current_configuration()

        self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 80, "default_host_type": "linux dm-mp", "automatic_load_balancing": "enabled",
                        "host_connectivity_reporting": "enabled", "name": "array1"})
        instance = NetAppESeriesGlobalSettings()
        with self.assertRaisesRegexp(AnsibleFailJson, r"Failed to determine current configuration."):
            with patch(self.REQ_FUNC, side_effect=[(200, {"productCapabilities": [], "featureParameters": {"cacheBlockSizes": []}}), (200, []),
                                                   (200, [{"defaultHostTypeIndex": 28, "cache": {"cacheBlkSize": 32768, "demandFlushThreshold": 90}}]),
                                                   Exception()]):
                instance.get_current_configuration()
Beispiel #9
0
    def test_update_pass(self):
        """Verify update passes successfully."""
        self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 90, "default_host_type": "Windows", "automatic_load_balancing": "disabled",
                        "host_connectivity_reporting": "disabled", "name": "array2"})
        instance = NetAppESeriesGlobalSettings()

        instance.change_autoload_enabled_required = lambda: False
        instance.change_cache_block_size_required = lambda: False
        instance.change_cache_flush_threshold_required = lambda: False
        instance.change_host_type_required = lambda: False
        instance.change_name_required = lambda: False
        instance.change_host_connectivity_reporting_enabled_required = lambda: False
        with self.assertRaisesRegexp(AnsibleExitJson, r"'changed': False"):
            with patch(self.REQ_FUNC, side_effect=[(200, {"productCapabilities": [], "featureParameters": {"cacheBlockSizes": []}}), (200, []),
                                                   (200, [{"defaultHostTypeIndex": 28, "cache": {"cacheBlkSize": 32768, "demandFlushThreshold": 90}}]),
                                                   (200, {"autoLoadBalancingEnabled": True, "hostConnectivityReportingEnabled": True, "name": "array1"})] * 2):
                instance.update()

        self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 90, "default_host_type": "Windows", "automatic_load_balancing": "disabled",
                        "host_connectivity_reporting": "disabled", "name": "array2"})
        instance = NetAppESeriesGlobalSettings()
        instance.change_autoload_enabled_required = lambda: True
        instance.change_cache_block_size_required = lambda: False
        instance.change_cache_flush_threshold_required = lambda: False
        instance.change_host_type_required = lambda: False
        instance.change_name_required = lambda: False
        instance.change_host_connectivity_reporting_enabled_required = lambda: False
        instance.update_autoload = lambda: None
        with self.assertRaisesRegexp(AnsibleExitJson, r"'changed': True"):
            with patch(self.REQ_FUNC, side_effect=[(200, {"productCapabilities": [], "featureParameters": {"cacheBlockSizes": []}}), (200, []),
                                                   (200, [{"defaultHostTypeIndex": 28, "cache": {"cacheBlkSize": 32768, "demandFlushThreshold": 90}}]),
                                                   (200, {"autoLoadBalancingEnabled": True, "hostConnectivityReportingEnabled": True, "name": "array1"})] * 2):
                instance.update()
Beispiel #10
0
 def test_init_fail(self):
     """Verify module fails when autoload is enabled but host connectivity reporting is not."""
     self._set_args({"automatic_load_balancing": "enabled", "host_connectivity_reporting": "disabled"})
     with self.assertRaisesRegexp(AnsibleFailJson, r"Option automatic_load_balancing requires host_connectivity_reporting to be enabled."):
         instance = NetAppESeriesGlobalSettings()