Create a data map of what to execute on
(self, cached=False)
| 1875 | return level |
| 1876 | |
| 1877 | def map_data(self, cached=False): |
| 1878 | """ |
| 1879 | Create a data map of what to execute on |
| 1880 | """ |
| 1881 | ret = {"create": {}} |
| 1882 | pmap = self.map_providers_parallel(cached=cached) |
| 1883 | exist = set() |
| 1884 | defined = set() |
| 1885 | rendered_map = copy.deepcopy(self.rendered_map) |
| 1886 | for profile_name, nodes in rendered_map.items(): |
| 1887 | if profile_name not in self.opts["profiles"]: |
| 1888 | msg = ( |
| 1889 | "The required profile, '{}', defined in the map " |
| 1890 | "does not exist. The defined nodes, {}, will not " |
| 1891 | "be created.".format( |
| 1892 | profile_name, ", ".join(f"'{node}'" for node in nodes) |
| 1893 | ) |
| 1894 | ) |
| 1895 | log.error(msg) |
| 1896 | if "errors" not in ret: |
| 1897 | ret["errors"] = {} |
| 1898 | ret["errors"][profile_name] = msg |
| 1899 | continue |
| 1900 | |
| 1901 | profile_data = self.opts["profiles"].get(profile_name) |
| 1902 | |
| 1903 | for nodename, overrides in nodes.items(): |
| 1904 | # Get associated provider data, in case something like size |
| 1905 | # or image is specified in the provider file. See issue #32510. |
| 1906 | if ( |
| 1907 | "provider" in overrides |
| 1908 | and overrides["provider"] != profile_data["provider"] |
| 1909 | ): |
| 1910 | alias, driver = overrides.get("provider").split(":") |
| 1911 | else: |
| 1912 | alias, driver = profile_data.get("provider").split(":") |
| 1913 | |
| 1914 | provider_details = copy.deepcopy(self.opts["providers"][alias][driver]) |
| 1915 | del provider_details["profiles"] |
| 1916 | |
| 1917 | # Update the provider details information with profile data |
| 1918 | # Profile data and node overrides should override provider data, if defined. |
| 1919 | # This keeps map file data definitions consistent with -p usage. |
| 1920 | salt.utils.dictupdate.update(provider_details, profile_data) |
| 1921 | nodedata = copy.deepcopy(provider_details) |
| 1922 | |
| 1923 | # Update profile data with the map overrides |
| 1924 | for setting in ("grains", "master", "minion", "volumes", "requires"): |
| 1925 | deprecated = f"map_{setting}" |
| 1926 | if deprecated in overrides: |
| 1927 | log.warning( |
| 1928 | "The use of '%s' on the '%s' mapping has " |
| 1929 | "been deprecated. The preferred way now is to " |
| 1930 | "just define '%s'. For now, salt-cloud will do " |
| 1931 | "the proper thing and convert the deprecated " |
| 1932 | "mapping into the preferred one.", |
| 1933 | deprecated, |
| 1934 | nodename, |