Exemple #1
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()
Exemple #2
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())
Exemple #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())