Exemplo n.º 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()
Exemplo n.º 2
0
    def test_change_host_connectivity_reporting_enabled_required_pass(self):
        """Verify change_host_connectivity_reporting_enabled_required passes successfully."""
        self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 90, "default_host_type": "Windows", "automatic_load_balancing": "disabled",
                        "name": "array1"})
        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'}
        self.assertFalse(instance.change_host_connectivity_reporting_enabled_required())

        self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 90, "default_host_type": "Windows", "automatic_load_balancing": "disabled",
                        "host_connectivity_reporting": "enabled", "name": "array1"})
        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'}
        self.assertFalse(instance.change_host_connectivity_reporting_enabled_required())

        self._set_args({"cache_block_size": 32768, "cache_flush_threshold": 90, "default_host_type": "Windows", "automatic_load_balancing": "disabled",
                        "host_connectivity_reporting": "disabled", "name": "array1"})
        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'}
        self.assertTrue(instance.change_host_connectivity_reporting_enabled_required())