salt-ext-modules-vmware icon indicating copy to clipboard operation
salt-ext-modules-vmware copied to clipboard

tests.integration.modules.test_esxi : test_advanced_config

Open waynew opened this issue 3 years ago • 0 comments

Integration test failed

    def test_advanced_config(service_instance):
        """
        Test advanced config on esxi host
        """
>       ret = esxi.set_advanced_config(
            config_name="Annotations.WelcomeMessage",
            config_value="testing",
            service_instance=service_instance,
            datacenter_name="Datacenter",
            cluster_name="Cluster",
        )

service_instance = 'vim.ServiceInstance:ServiceInstance'

tests/integration/modules/test_esxi.py:276: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/saltext/vmware/modules/esxi.py:639: in set_advanced_config
    return set_advanced_configs(
        cluster_name = 'Cluster'
        config_name = 'Annotations.WelcomeMessage'
        config_value = 'testing'
        datacenter_name = 'Datacenter'
        host_name  = None
        service_instance = 'vim.ServiceInstance:ServiceInstance'
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

config_dict = {'Annotations.WelcomeMessage': 'testing'}, datacenter_name = 'Datacenter', cluster_name = 'Cluster', host_name = None
service_instance = 'vim.ServiceInstance:ServiceInstance'

    def set_advanced_configs(
        config_dict,
        datacenter_name=None,
        cluster_name=None,
        host_name=None,
        service_instance=None,
    ):
        """
        Set multiple advanced configurations on matching EXSI hosts.
    
        config_dict
            Set the configuration key to the configuration value. Eg: {"Annotations.WelcomeMessage": "Hello"}
    
        datacenter_name
            Filter by this datacenter name (required when cluster is specified)
    
        cluster_name
            Filter by this cluster name (optional)
    
        host_name
            Filter by this ESXi hostname (optional)
    
        service_instance
            Use this vCenter service connection instance instead of creating a new one. (optional).
    
        .. code-block:: bash
    
            salt '*' vmware_esxi.set_advanced_config config_name=Annotations.WelcomeMessage config_value=Hello
    
        Returns:
    
        .. code-block:: json
    
            {
                "host1": {
                    "Annotations.WelcomeMessage": "HelloDemo"
                },
            }
    
        """
        log.debug("Running vmware_esxi.set_advanced_configs")
        ret = {}
        if not service_instance:
            service_instance = get_service_instance(opts=__opts__, pillar=__pillar__)
        hosts = utils_esxi.get_hosts(
            service_instance=service_instance,
            host_names=[host_name] if host_name else None,
            cluster_name=cluster_name,
            datacenter_name=datacenter_name,
            get_all_hosts=host_name is None,
        )
    
        try:
            for h in hosts:
                config_manager = h.configManager.advancedOption
                ret[h.name] = {}
                if not config_manager:
                    continue
    
                supported_configs = {}
                for opt in config_manager.supportedOption:
                    if opt.key not in config_dict:
                        continue
                    supported_configs[opt.key] = opt.optionType
    
                advanced_configs = []
                for opt in config_dict:
>                   opt_type = supported_configs[opt]
E                   KeyError: 'Annotations.WelcomeMessage'

waynew avatar Dec 01 '21 22:12 waynew