cobbler / cobbler

@@ -17,12 +17,12 @@
Loading
17 17
18 18
def _generate_append_line_standalone(data: dict, distro, descendant) -> str:
19 19
    """
20 -
    TODO
20 +
    Generates the append line for the kernel so the installation can be done unattended.
21 21
22 -
    :param data:
23 -
    :param distro:
24 -
    :param descendant:
25 -
    :return:
22 +
    :param data: The values for the append line. The key "kernel_options" must be present.
23 +
    :param distro: The distro object to generate the append line from.
24 +
    :param descendant: The profile or system which is underneath the distro.
25 +
    :return: The base append_line which we need for booting the built ISO. Contains initrd and autoinstall parameter.
26 26
    """
27 27
    append_line = "  append initrd=%s" % os.path.basename(distro.initrd)
28 28
    if distro.breed == "redhat":
@@ -41,16 +41,15 @@
Loading
41 41
42 42
class StandaloneBuildiso(buildiso.BuildIso):
43 43
    """
44 -
    TODO
44 +
    This class contains all functionality related to building self-contained installation images.
45 45
    """
46 46
47 47
    def _validate_standalone_args(self, distro_name: str, source: str):
48 48
        """
49 49
        If building standalone, we only want --distro and --profiles (optional), systems are disallowed
50 50
51 -
        :param distro_name:
52 -
        :param source:
53 -
        :return:
51 +
        :param distro_name: The name of the distribution we want to install.
52 +
        :param source: The source which we copy to the ISO as an installation base.
54 53
        """
55 54
        if not distro_name:
56 55
            raise ValueError("When building a standalone ISO, you must specify a --distro")
@@ -63,13 +62,13 @@
Loading
63 62
                if profile.distro != distro_name:
64 63
                    raise ValueError("When building a standalone ISO, all --profiles must be under --distro")
65 64
66 -
    def _sync_airgapped_repos(self, airgapped, repo_names_to_copy):
65 +
    def _sync_airgapped_repos(self, airgapped: bool, repo_names_to_copy: dict):
67 66
        """
68 -
        TODO
67 +
        Syncs all repositories locally available into the image if the is supposed to be airgapped.
69 68
70 -
        :param airgapped:
71 -
        :param repo_names_to_copy:
72 -
        :return:
69 +
        :param airgapped: If false this method is doing nothing.
70 +
        :param repo_names_to_copy: The names of the repositories which should be included.
71 +
        :raises RuntimeError: In case the rsync of the repository was not successful.
73 72
        """
74 73
        if airgapped:
75 74
            # copy any repos found in profiles or systems to the iso build
@@ -88,12 +87,13 @@
Loading
88 87
89 88
    def _validate_standalone_filesource(self, filesource: str, distro) -> str:
90 89
        """
91 -
        TODO
90 +
        Validate that the path to the installation sources is making sense. If they do then normalize the path and
91 +
        return it.
92 92
93 -
        :param filesource:
94 -
        :param distro:
93 +
        :param filesource: The path to the installation sources.
94 +
        :param distro: The distribution of which the kernel is used for booting the image.
95 95
        :raises ValueError: In case the installation source was not found.
96 -
        :return:
96 +
        :return: Normalized filesource which points to the absolute path of the source tree.
97 97
        """
98 98
        if filesource is None:
99 99
            # Try to determine the source from the distro kernel path
@@ -111,16 +111,17 @@
Loading
111 111
                             "--source if the distro install tree is not hosted locally")
112 112
        return filesource
113 113
114 -
    def _generate_autoinstall_data(self, descendant, distro, airgapped, data, repo_names_to_copy) -> str:
114 +
    def _generate_autoinstall_data(self, descendant, distro, airgapped: bool, data: dict,
115 +
                                   repo_names_to_copy: dict) -> str:
115 116
        """
116 -
        TODO
117 -
118 -
        :param descendant:
119 -
        :param distro:
120 -
        :param airgapped:
121 -
        :param data:
122 -
        :param repo_names_to_copy:
123 -
        :return:
117 +
        Generates the autoinstall script for the distro/profile/system we want to install.
118 +
119 +
        :param descendant: The descendant to generate the ISO for.
120 +
        :param distro: The distro to generate the ISO for.
121 +
        :param airgapped: Whether the ISO should be bootable in an airgapped environment or not.
122 +
        :param data: The data for the append line of the kernel.
123 +
        :param repo_names_to_copy: The repositories to include in case of an airgapped environment.
124 +
        :return: The generated script for the ISO.
124 125
        """
125 126
        autoinstall_data = ""
126 127
        if descendant.COLLECTION_TYPE == 'profile':
@@ -161,14 +162,13 @@
Loading
161 162
    def _generate_descendant(self, descendant, cfglines: List[str], distro, airgapped: bool,
162 163
                             repo_names_to_copy: dict):
163 164
        """
164 -
        TODO
165 -
166 -
        :param descendant:
167 -
        :param cfglines:
168 -
        :param distro:
169 -
        :param airgapped:
170 -
        :param repo_names_to_copy:
171 -
        :return:
165 +
        Generate the ISOLINUX cfg configuration file for the descendant.
166 +
167 +
        :param descendant: The descendant to generate the config file for. Must be a profile or system object.
168 +
        :param cfglines: The content of the file which has already been generated.
169 +
        :param distro: The parent distro.
170 +
        :param airgapped: Whether the generated ISO should be bootable in an airgapped environment or not.
171 +
        :param repo_names_to_copy: The repository names to copy in the case of an airgapped environment.
172 172
        """
173 173
        menu_indent = 0
174 174
        if descendant.COLLECTION_TYPE == 'system':

@@ -14,13 +14,13 @@
Loading
14 14
15 15
def _my_int_append_line(my_int, data: dict, dist, append_line: str) -> str:
16 16
    """
17 -
    TODO
17 +
    This generates the interface configuration for the system to boot for the append line.
18 18
19 -
    :param my_int:
20 -
    :param data:
21 -
    :param dist:
22 -
    :param append_line:
23 -
    :return:
19 +
    :param my_int: The interface where the information should be assigned to.
20 +
    :param data: The data which the append line is generated from.
21 +
    :param dist: The distribution to generate the append line for.
22 +
    :param append_line: The previously existing append line.
23 +
    :return: The append line with the interface configuration included.
24 24
    """
25 25
    if my_int is not None:
26 26
        intmac = "mac_address_" + my_int
@@ -39,14 +39,14 @@
Loading
39 39
    return append_line
40 40
41 41
42 -
def _my_ip_append_line(my_ip, dist, append_line) -> str:
42 +
def _my_ip_append_line(my_ip, dist, append_line: str) -> str:
43 43
    """
44 -
    TODO
44 +
    This generates the IP configuration for the system to boot for the append line.
45 45
46 -
    :param my_ip:
47 -
    :param dist:
48 -
    :param append_line:
49 -
    :return:
46 +
    :param my_ip: The IP address to add to the append line.
47 +
    :param dist: The distribution to generate the append line for.
48 +
    :param append_line: The previously existing append line.
49 +
    :return: The append line with the IP configuration included.
50 50
    """
51 51
    if my_ip is not None:
52 52
        if dist.breed == "suse":
@@ -58,14 +58,14 @@
Loading
58 58
    return append_line
59 59
60 60
61 -
def _my_mask_append_line(my_mask, dist, append_line) -> str:
61 +
def _my_mask_append_line(my_mask, dist, append_line: str) -> str:
62 62
    """
63 -
    TODO
63 +
    This generates the netmask configuration for the system to boot for the append line.
64 64
65 -
    :param my_mask:
66 -
    :param dist:
67 -
    :param append_line:
68 -
    :return:
65 +
    :param my_mask: The netmask to use for the installation process.
66 +
    :param dist: The distribution to generate the append line for.
67 +
    :param append_line: The previously existing append line.
68 +
    :return: The append line with the netmask configuration included.
69 69
    """
70 70
    if my_mask is not None:
71 71
        if dist.breed in ["suse", "redhat"]:
@@ -77,12 +77,12 @@
Loading
77 77
78 78
def _my_gw_append_line(my_gw, dist, append_line: str) -> str:
79 79
    """
80 -
    TODO
80 +
    This generates the gateway configuration for the system to boot for the append line.
81 81
82 -
    :param my_gw:
83 -
    :param dist:
84 -
    :param append_line:
85 -
    :return:
82 +
    :param my_gw: The gateway to use for the installation process
83 +
    :param dist: The distribution to generate the append line for.
84 +
    :param append_line: The previously existing append line.
85 +
    :return: The append line with the gateway configuration included.
86 86
    """
87 87
    if my_gw is not None:
88 88
        if dist.breed in ["suse", "redhat"]:
@@ -92,15 +92,15 @@
Loading
92 92
    return append_line
93 93
94 94
95 -
def _my_dns_append_line(my_dns, exclude_dns, dist, append_line) -> str:
95 +
def _my_dns_append_line(my_dns, exclude_dns: bool, dist, append_line: str) -> str:
96 96
    """
97 -
    TODO
97 +
    This generates the DNS configuration for the system to boot for the append line.
98 98
99 -
    :param my_dns:
100 -
    :param exclude_dns:
101 -
    :param dist:
102 -
    :param append_line:
103 -
    :return:
99 +
    :param my_dns: The nameservers to use during the installation process.
100 +
    :param exclude_dns: If this flag is set to True, the DNS configuration is skipped.
101 +
    :param dist: The distribution to generate the append line for.
102 +
    :param append_line: The previously existing append line.
103 +
    :return: The append line with the DNS configuration included.
104 104
    """
105 105
    if not exclude_dns or my_dns is not None:
106 106
        if dist.breed == "suse":
@@ -123,11 +123,11 @@
Loading
123 123
124 124
def _generate_static_ip_boot_interface(dist, data):
125 125
    """
126 -
    TODO
126 +
    The interface to use when the system boots.
127 127
128 -
    :param dist:
129 -
    :param data:
130 -
    :return:
128 +
    :param dist: The distribution to generate the append line for.
129 +
    :param data: The data which the append line is generated from.
130 +
    :return: The interface which is used during the installation process.
131 131
    """
132 132
    my_int = None
133 133
    if dist.breed == "redhat":
@@ -150,11 +150,11 @@
Loading
150 150
151 151
def _generate_static_ip_boot_ip(dist, data):
152 152
    """
153 -
    TODO
153 +
    Generate the IP which is used during the installation process. This respects overrides.
154 154
155 -
    :param dist:
156 -
    :param data:
157 -
    :return:
155 +
    :param dist: The distribution to generate the append line for.
156 +
    :param data: The data which the append line is generated from.
157 +
    :return: The IP address which is used during the installation process.
158 158
    """
159 159
    my_ip = None
160 160
    if dist.breed == "redhat":
@@ -175,11 +175,11 @@
Loading
175 175
176 176
def _generate_static_ip_boot_mask(dist, data):
177 177
    """
178 -
    TODO
178 +
    Generate the Netmask which is used during the installation process. This respects overrides.
179 179
180 -
    :param dist:
181 -
    :param data:
182 -
    :return:
180 +
    :param dist: The distribution to generate the append line for.
181 +
    :param data: The data which the append line is generated from.
182 +
    :return: The netmask to use during the installation process.
183 183
    """
184 184
    my_mask = None
185 185
    if dist.breed in ["suse", "redhat"]:
@@ -195,11 +195,11 @@
Loading
195 195
196 196
def _generate_static_ip_boot_gateway(dist, data):
197 197
    """
198 -
    TODO
198 +
    Generate the Gateway which is used during the installation process. This respects overrides.
199 199
200 -
    :param dist:
201 -
    :param data:
202 -
    :return:
200 +
    :param dist: The distribution to generate the append line for.
201 +
    :param data: The data which the append line is generated from.
202 +
    :return: The gateway to use during the installation process.
203 203
    """
204 204
    my_gw = None
205 205
    if dist.breed in ["suse", "redhat"]:
@@ -215,11 +215,11 @@
Loading
215 215
216 216
def _generate_static_ip_boot_dns(dist, data):
217 217
    """
218 -
    TODO
218 +
    Generates the static Boot DNS Server which is used for resolving Domains.
219 219
220 -
    :param dist:
221 -
    :param data:
222 -
    :return:
220 +
    :param dist: The distribution to generate the append line for.
221 +
    :param data: The data which the append line is generated from.
222 +
    :return: The DNS nameserver used for the distribution.
223 223
    """
224 224
    my_dns = None
225 225
    if dist.breed == "redhat":
@@ -238,14 +238,14 @@
Loading
238 238
    return my_dns
239 239
240 240
241 -
def _generate_static_ip_boot_options(dist, data: dict):
241 +
def _generate_static_ip_boot_options(dist, data: dict) -> tuple:
242 242
    """
243 243
    Try to add static ip boot options to avoid DHCP (interface/ip/netmask/gw/dns)
244 244
    Check for overrides first and clear them from kernel_options
245 245
246 -
    :param dist:
247 -
    :param data:
248 -
    :return:
246 +
    :param dist: The distribution to generate the append line for.
247 +
    :param data: The data which the append line is generated from.
248 +
    :return: The Tuple with the interface, IP, Netmask, Gateway and DNS information.
249 249
    """
250 250
    my_int = _generate_static_ip_boot_interface(dist, data)
251 251
    my_ip = _generate_static_ip_boot_ip(dist, data)
@@ -256,14 +256,14 @@
Loading
256 256
    return my_int, my_ip, my_mask, my_gw, my_dns
257 257
258 258
259 -
def _generate_append_redhat(data, dist, append_line) -> str:
259 +
def _generate_append_redhat(data: dict, dist, append_line: str) -> str:
260 260
    """
261 -
    TODO
261 +
    Generate additional content for the append line in case that dist is a RedHat based one.
262 262
263 -
    :param data:
264 -
    :param dist:
265 -
    :param append_line:
266 -
    :return:
263 +
    :param data: The data which the append line is generated from.
264 +
    :param dist: The distribution to generate the append line for.
265 +
    :param append_line: The previously existing append line.
266 +
    :return: The updated append line.
267 267
    """
268 268
    if dist.breed == "redhat":
269 269
        if "proxy" in data and data["proxy"] != "":
@@ -272,15 +272,15 @@
Loading
272 272
    return append_line
273 273
274 274
275 -
def _generate_append_debian(data, dist, system, append_line) -> str:
275 +
def _generate_append_debian(data: dict, dist, system, append_line: str) -> str:
276 276
    """
277 -
    TODO
277 +
    Generate additional content for the append line in case that dist is Ubuntu or Debian.
278 278
279 -
    :param data:
280 -
    :param dist:
281 -
    :param system:
282 -
    :param append_line:
283 -
    :return:
279 +
    :param data: The data which the append line is generated from.
280 +
    :param dist: The distribution to generate the append line for.
281 +
    :param system: The system which the append line should be generated for.
282 +
    :param append_line: The previously existing append line.
283 +
    :return: The updated append line.
284 284
    """
285 285
    if dist.breed in ["ubuntu", "debian"]:
286 286
        append_line += " auto-install/enable=true url=%s netcfg/disable_autoconfig=true" % data["autoinstall"]
@@ -308,16 +308,16 @@
Loading
308 308
    return append_line
309 309
310 310
311 -
def _adjust_interface_config(data: dict, my_int, my_ip, my_mask):
311 +
def _adjust_interface_config(data: dict, my_int, my_ip, my_mask) -> tuple:
312 312
    """
313 313
    If no kernel_options overrides are present find the management interface do nothing when zero or multiple
314 314
    management interfaces are found
315 315
316 -
    :param data:
317 -
    :param my_int:
318 -
    :param my_ip:
319 -
    :param my_mask:
320 -
    :return:
316 +
    :param data: The data to fed into the Tuple.
317 +
    :param my_int: The interface where the information should be assigned to.
318 +
    :param my_ip: The ip address to add to the Tuple.
319 +
    :param my_mask: The netmask to add to the Tuple.
320 +
    :return: The updated Tuple containing interface, IP and netmask.
321 321
    """
322 322
    if my_int is None:
323 323
        mgmt_ints = []
@@ -355,17 +355,17 @@
Loading
355 355
    return my_int, my_ip, my_mask
356 356
357 357
358 -
def _get_tcp_ip_config(data, my_ip, my_mask, my_gw, my_dns, my_int):
358 +
def _get_tcp_ip_config(data, my_ip, my_mask, my_gw, my_dns, my_int) -> tuple:
359 359
    """
360 -
    Lookup tcp/ip configuration data
360 +
    Lookup tcp/ip configuration data. If not present already present this adds it from the previously blenderd data.
361 361
362 -
    :param data:
363 -
    :param my_ip:
364 -
    :param my_mask:
365 -
    :param my_gw:
366 -
    :param my_dns:
367 -
    :param my_int:
368 -
    :return:
362 +
    :param data: The data to fed into the Tuple.
363 +
    :param my_ip: The ip address to add to the Tuple.
364 +
    :param my_mask: The netmask to add to the Tuple.
365 +
    :param my_gw: The gateway to add to the Tuple.
366 +
    :param my_dns: The name servers to add to the Tuple.
367 +
    :param my_int: The interface where the information should be assigned to.
368 +
    :return: The Tuple with the ip, netmask, gateway and dns.
369 369
    """
370 370
    if my_ip is None and my_int is not None:
371 371
        intip = "ip_address_" + my_int
@@ -386,17 +386,17 @@
Loading
386 386
387 387
class NetbootBuildiso(buildiso.BuildIso):
388 388
    """
389 -
    TODO
389 +
    This class contains all functionality related to building network installation images.
390 390
    """
391 391
392 -
    def _generate_append_suse(self, data, dist, append_line: str) -> str:
392 +
    def _generate_append_suse(self, data: dict, dist, append_line: str) -> str:
393 393
        """
394 -
        TODO
394 +
        Special adjustments for generating the append line for suse.
395 395
396 -
        :param data:
397 -
        :param dist:
398 -
        :param append_line:
399 -
        :return:
396 +
        :param data: The data to use for generating the append line.
397 +
        :param dist: The distribution to use for generation.
398 +
        :param append_line: The existing append line.
399 +
        :return: The updated append line. If the distribution is not SUSE, then nothing is changed.
400 400
        """
401 401
        if dist.breed == "suse":
402 402
            if "proxy" in data and data["proxy"] != "":
@@ -417,12 +417,12 @@
Loading
417 417
418 418
    def _generate_append_line_netboot(self, data: dict, distro_name: str, distro_breed: str) -> str:
419 419
        """
420 -
        TODO
420 +
        Generate the append line for the kernel for a network installation.
421 421
422 -
        :param data:
423 -
        :param distro_name:
424 -
        :param distro_breed:
425 -
        :return:
422 +
        :param data: The data to use for generating the append line.
423 +
        :param distro_name: The name of the distribution.
424 +
        :param distro_breed: The name of the distribution breed.
425 +
        :return: The generated append line.
426 426
        """
427 427
        append_line = " append initrd=%s.img" % distro_name
428 428
        if distro_breed == "suse":
@@ -485,11 +485,11 @@
Loading
485 485
486 486
    def _generate_netboot_system(self, system, cfglines: List[str], exclude_dns: bool):
487 487
        """
488 -
        TODO
488 +
        Generates the ISOLINUX cfg configuration for any systems included in the image.
489 489
490 -
        :param system:
491 -
        :param cfglines:
492 -
        :param exclude_dns:
490 +
        :param system: The system which the configuration should be generated for.
491 +
        :param cfglines: The already existing lines of the configuration.
492 +
        :param exclude_dns: If DNS configuration should be excluded or not.
493 493
        """
494 494
        self.logger.info("processing system: %s", system.name)
495 495
        profile = system.get_conceptual_parent()
@@ -530,10 +530,10 @@
Loading
530 530
531 531
    def _generate_netboot_profile(self, profile, cfglines: List[str]):
532 532
        """
533 -
        TODO
533 +
        Generates the ISOLINUX cfg configuration for any profiles included in the image.
534 534
535 -
        :param profile:
536 -
        :param cfglines:
535 +
        :param profile: The profile which the configuration should be generated for.
536 +
        :param cfglines: The already existing lines of the configuration.
537 537
        """
538 538
        self.logger.info("Processing profile: \"%s\"", profile.name)
539 539
        dist = profile.get_conceptual_parent()

@@ -164,14 +164,14 @@
Loading
164 164
            self.logger.error("The following files were not found: \"%s\"", grub_efi)
165 165
            raise FileNotFoundError("Required file(s) not found. Please check your GRUB 2 installation")
166 166
167 -
    def __validate_buildisodir(self, buildisodir: str) -> str:
167 +
    def __prepare_buildisodir(self, buildisodir: str) -> str:
168 168
        """
169 -
        TODO
169 +
        This validated the path and type of the buildiso directory and then (re-)creates the apropiate directories.
170 170
171 -
        :param buildisodir:
171 +
        :param buildisodir: The directory in which the build of the ISO takes place.
172 172
        :raises ValueError: In case the specified directory does not exist.
173 173
        :raises TypeError: In case the specified argument is not of type str.
174 -
        :return:
174 +
        :return: The validated and normalized directory with appropriate subfolders provisioned.
175 175
        """
176 176
        if not isinstance(buildisodir, str):
177 177
            raise TypeError("buildisodir needs to be of type str!")
@@ -203,25 +203,24 @@
Loading
203 203
204 204
    def _prepare_iso(self, buildisodir: str, profiles: Optional[Union[str, list]]):
205 205
        """
206 -
        TODO
206 +
        Validates the directories we use for building the ISO and copies files to the right place.
207 207
208 -
        :param buildisodir:
209 -
        :param profiles:
210 -
        :return:
208 +
        :param buildisodir: The directory to use for building the ISO.
209 +
        :param profiles: The profiles to generate the ISO for.
210 +
        :return: The normalized directory for further processing.
211 211
        """
212 -
        buildisodir = self.__validate_buildisodir(buildisodir)
212 +
        buildisodir = self.__prepare_buildisodir(buildisodir)
213 213
        self.__copy_files()
214 214
        self.profiles = utils.input_string_or_list_no_inherit(profiles)
215 215
        return buildisodir
216 216
217 217
    def _generate_iso(self, xorrisofs_opts: str, iso: str, buildisodir: str):
218 218
        """
219 -
        TODO
219 +
        Build the final xorrisofs command which is then executed on the disk.
220 220
221 -
        :param xorrisofs_opts:
222 -
        :param iso:
223 -
        :param buildisodir:
224 -
        :return:
221 +
        :param xorrisofs_opts: The additional options for xorrisofs.
222 +
        :param iso: The name of the output iso.
223 +
        :param buildisodir: The directory in which we build the ISO.
225 224
        """
226 225
        running_on, _ = utils.os_release()
227 226
        if running_on == "suse":
Files Coverage
cobbler 46.08%
Project Totals (101 files) 46.08%
Untitled

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading