-
Notifications
You must be signed in to change notification settings - Fork 117
/
logvol.py
937 lines (751 loc) · 38.6 KB
/
logvol.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
#
# Chris Lumens <clumens@redhat.com>
#
# Copyright 2005, 2006, 2007, 2008, 2012 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use, modify,
# copy, or redistribute it subject to the terms and conditions of the GNU
# General Public License v.2. This program is distributed in the hope that it
# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
# trademarks that are incorporated in the source code or documentation are not
# subject to the GNU General Public License and may only be used or replicated
# with the express permission of Red Hat, Inc.
#
from pykickstart.version import FC3, FC4, F9, F12, F14, F15, F17, F18, F20, F21, F29
from pykickstart.version import F23, RHEL5, RHEL6, RHEL7, RHEL8, versionToLongString
from pykickstart.base import BaseData, KickstartCommand
from pykickstart.errors import KickstartParseError, KickstartParseWarning
from pykickstart.options import KSOptionParser, commaSplit, mountpoint
import warnings
from pykickstart.i18n import _
class FC3_LogVolData(BaseData):
removedKeywords = BaseData.removedKeywords
removedAttrs = BaseData.removedAttrs
def __init__(self, *args, **kwargs):
BaseData.__init__(self, *args, **kwargs)
self.fstype = kwargs.get("fstype", "")
self.grow = kwargs.get("grow", False)
self.maxSizeMB = kwargs.get("maxSizeMB", 0)
self.name = kwargs.get("name", "")
self.format = kwargs.get("format", True)
self.percent = kwargs.get("percent", 0)
self.recommended = kwargs.get("recommended", False)
self.size = kwargs.get("size", None)
self.preexist = kwargs.get("preexist", False)
self.vgname = kwargs.get("vgname", "")
self.mountpoint = kwargs.get("mountpoint", "")
def __eq__(self, y):
if not y:
return False
return self.vgname == y.vgname and self.name == y.name
def __ne__(self, y):
return not self == y
def _getArgsAsStr(self):
retval = ""
if self.fstype:
retval += " --fstype=\"%s\"" % self.fstype
if self.grow:
retval += " --grow"
if self.maxSizeMB:
retval += " --maxsize=%d" % self.maxSizeMB
if not self.format:
retval += " --noformat"
if self.percent:
retval += " --percent=%d" % self.percent
if self.recommended:
retval += " --recommended"
if self.size:
retval += " --size=%d" % self.size
if self.preexist:
retval += " --useexisting"
return retval
def __str__(self):
retval = BaseData.__str__(self)
args = self._getArgsAsStr()
args += " --name=%s" % self.name
args += " --vgname=%s" % self.vgname
retval += "logvol %s%s\n" % (self.mountpoint, args)
return retval
class FC4_LogVolData(FC3_LogVolData):
removedKeywords = FC3_LogVolData.removedKeywords
removedAttrs = FC3_LogVolData.removedAttrs
def __init__(self, *args, **kwargs):
FC3_LogVolData.__init__(self, *args, **kwargs)
self.bytesPerInode = kwargs.get("bytesPerInode", 4096)
self.fsopts = kwargs.get("fsopts", "")
def _getArgsAsStr(self):
retval = FC3_LogVolData._getArgsAsStr(self)
if hasattr(self, "bytesPerInode") and self.bytesPerInode:
retval += " --bytes-per-inode=%d" % self.bytesPerInode
if self.fsopts:
retval += " --fsoptions=\"%s\"" % self.fsopts
return retval
class RHEL5_LogVolData(FC4_LogVolData):
removedKeywords = FC4_LogVolData.removedKeywords
removedAttrs = FC4_LogVolData.removedAttrs
def __init__(self, *args, **kwargs):
FC4_LogVolData.__init__(self, *args, **kwargs)
self.encrypted = kwargs.get("encrypted", False)
self.passphrase = kwargs.get("passphrase", "")
def _getArgsAsStr(self):
retval = FC4_LogVolData._getArgsAsStr(self)
if self.encrypted:
retval += " --encrypted"
if self.passphrase:
retval += " --passphrase=\"%s\"" % self.passphrase
return retval
class F9_LogVolData(FC4_LogVolData):
removedKeywords = FC4_LogVolData.removedKeywords + ["bytesPerInode"]
removedAttrs = FC4_LogVolData.removedAttrs + ["bytesPerInode"]
def __init__(self, *args, **kwargs):
FC4_LogVolData.__init__(self, *args, **kwargs)
self.deleteRemovedAttrs()
self.fsopts = kwargs.get("fsopts", "")
self.fsprofile = kwargs.get("fsprofile", "")
self.encrypted = kwargs.get("encrypted", False)
self.passphrase = kwargs.get("passphrase", "")
def _getArgsAsStr(self):
retval = FC4_LogVolData._getArgsAsStr(self)
if self.fsprofile:
retval += " --fsprofile=\"%s\"" % self.fsprofile
if self.encrypted:
retval += " --encrypted"
if self.passphrase:
retval += " --passphrase=\"%s\"" % self.passphrase
return retval
class F12_LogVolData(F9_LogVolData):
removedKeywords = F9_LogVolData.removedKeywords
removedAttrs = F9_LogVolData.removedAttrs
def __init__(self, *args, **kwargs):
F9_LogVolData.__init__(self, *args, **kwargs)
self.deleteRemovedAttrs()
self.escrowcert = kwargs.get("escrowcert", "")
self.backuppassphrase = kwargs.get("backuppassphrase", False)
def _getArgsAsStr(self):
retval = F9_LogVolData._getArgsAsStr(self)
if self.encrypted and self.escrowcert:
retval += " --escrowcert=\"%s\"" % self.escrowcert
if self.backuppassphrase:
retval += " --backuppassphrase"
return retval
class RHEL6_LogVolData(F12_LogVolData):
removedKeywords = F12_LogVolData.removedKeywords
removedAttrs = F12_LogVolData.removedAttrs
def __init__(self, *args, **kwargs):
F12_LogVolData.__init__(self, *args, **kwargs)
self.cipher = kwargs.get("cipher", "")
self.hibernation = kwargs.get("hibernation", False)
self.thin_pool = kwargs.get("thin_pool", False)
self.thin_volume = kwargs.get("thin_volume", False)
self.pool_name = kwargs.get("pool_name", "")
self.chunk_size = kwargs.get("chunk_size", None) # kilobytes
self.metadata_size = kwargs.get("metadata_size", None) # megabytes
self.profile = kwargs.get("profile", "")
def _getArgsAsStr(self):
retval = F12_LogVolData._getArgsAsStr(self)
if self.encrypted and self.cipher:
retval += " --cipher=\"%s\"" % self.cipher
if self.hibernation:
retval += " --hibernation"
# these are only for thin pools
if self.thin_pool:
retval += " --thinpool"
if self.metadata_size:
retval += " --metadatasize=%d" % self.metadata_size
if self.chunk_size:
retval += " --chunksize=%d" % self.chunk_size
if self.thin_volume:
retval += " --thin --poolname=%s" % self.pool_name
if self.profile:
retval += " --profile=%s" % self.profile
return retval
class F14_LogVolData(F12_LogVolData):
pass
class F15_LogVolData(F14_LogVolData):
removedKeywords = F14_LogVolData.removedKeywords
removedAttrs = F14_LogVolData.removedAttrs
def __init__(self, *args, **kwargs):
F14_LogVolData.__init__(self, *args, **kwargs)
self.label = kwargs.get("label", "")
def _getArgsAsStr(self):
retval = F14_LogVolData._getArgsAsStr(self)
if self.label:
retval += " --label=\"%s\"" % self.label
return retval
class F17_LogVolData(F15_LogVolData):
removedKeywords = F15_LogVolData.removedKeywords
removedAttrs = F15_LogVolData.removedAttrs
def __init__(self, *args, **kwargs):
F15_LogVolData.__init__(self, *args, **kwargs)
self.resize = kwargs.get("resize", False)
def _getArgsAsStr(self):
retval = F15_LogVolData._getArgsAsStr(self)
if self.resize:
retval += " --resize"
return retval
class F18_LogVolData(F17_LogVolData):
removedKeywords = F17_LogVolData.removedKeywords
removedAttrs = F17_LogVolData.removedAttrs
def __init__(self, *args, **kwargs):
F17_LogVolData.__init__(self, *args, **kwargs)
self.hibernation = kwargs.get("hibernation", False)
self.cipher = kwargs.get("cipher", "")
def _getArgsAsStr(self):
retval = F17_LogVolData._getArgsAsStr(self)
if self.hibernation:
retval += " --hibernation"
if self.encrypted and self.cipher:
retval += " --cipher=\"%s\"" % self.cipher
return retval
class F20_LogVolData(F18_LogVolData):
removedKeywords = F18_LogVolData.removedKeywords
removedAttrs = F18_LogVolData.removedAttrs
def __init__(self, *args, **kwargs):
F18_LogVolData.__init__(self, *args, **kwargs)
self.thin_pool = kwargs.get("thin_pool", False)
self.thin_volume = kwargs.get("thin_volume", False)
self.pool_name = kwargs.get("pool_name", "")
# these are only for thin pools
self.chunk_size = kwargs.get("chunk_size", None) # kilobytes
self.metadata_size = kwargs.get("metadata_size", None) # megabytes
def _getArgsAsStr(self):
retval = F18_LogVolData._getArgsAsStr(self)
if self.thin_pool:
retval += " --thinpool"
if self.metadata_size:
retval += " --metadatasize=%d" % self.metadata_size
if self.chunk_size:
retval += " --chunksize=%d" % self.chunk_size
if self.thin_volume:
retval += " --thin --poolname=%s" % self.pool_name
return retval
class F21_LogVolData(F20_LogVolData):
removedKeywords = F20_LogVolData.removedKeywords
removedAttrs = F20_LogVolData.removedAttrs
def __init__(self, *args, **kwargs):
F20_LogVolData.__init__(self, *args, **kwargs)
self.profile = kwargs.get("profile", "")
def _getArgsAsStr(self):
retval = F20_LogVolData._getArgsAsStr(self)
if self.profile:
retval += " --profile=%s" % self.profile
return retval
class RHEL7_LogVolData(F21_LogVolData):
removedKeywords = F21_LogVolData.removedKeywords
removedAttrs = F21_LogVolData.removedAttrs
def __init__(self, *args, **kwargs):
F21_LogVolData.__init__(self, *args, **kwargs)
self.mkfsopts = kwargs.get("mkfsoptions", "") or kwargs.get("mkfsopts", "")
def _getArgsAsStr(self):
retval = F21_LogVolData._getArgsAsStr(self)
if self.mkfsopts:
retval += " --mkfsoptions=\"%s\"" % self.mkfsopts
return retval
class F23_LogVolData(F21_LogVolData):
def __init__(self, *args, **kwargs):
F21_LogVolData.__init__(self, *args, **kwargs)
self.cache_size = kwargs.get("cache_size", 0)
self.cache_mode = kwargs.get("cache_mode", "")
self.cache_pvs = kwargs.get("cache_pvs", [])
self.mkfsopts = kwargs.get("mkfsoptions", "") or kwargs.get("mkfsopts", "")
def _getArgsAsStr(self):
retval = F21_LogVolData._getArgsAsStr(self)
if self.cache_size:
retval += " --cachesize=%d" % self.cache_size
if self.cache_pvs:
retval += " --cachepvs=%s" % ",".join(self.cache_pvs)
if self.cache_mode:
retval += " --cachemode=%s" % self.cache_mode
if self.mkfsopts:
retval += " --mkfsoptions=\"%s\"" % self.mkfsopts
return retval
class F29_LogVolData(F23_LogVolData):
def __init__(self, *args, **kwargs):
F23_LogVolData.__init__(self, *args, **kwargs)
self.luks_version = kwargs.get("luks_version", "")
self.pbkdf = kwargs.get("pbkdf", "")
self.pbkdf_memory = kwargs.get("pbkdf_memory", 0)
self.pbkdf_time = kwargs.get("pbkdf_time", 0)
self.pbkdf_iterations = kwargs.get("pbkdf_iterations", 0)
def _getArgsAsStr(self):
retval = F23_LogVolData._getArgsAsStr(self)
if self.encrypted and self.luks_version:
retval += " --luks-version=%s" % self.luks_version
if self.encrypted and self.pbkdf:
retval += " --pbkdf=%s" % self.pbkdf
if self.encrypted and self.pbkdf_memory:
retval += " --pbkdf-memory=%s" % self.pbkdf_memory
if self.encrypted and self.pbkdf_time:
retval += " --pbkdf-time=%s" % self.pbkdf_time
if self.encrypted and self.pbkdf_iterations:
retval += " --pbkdf-iterations=%s" % self.pbkdf_iterations
return retval
class RHEL8_LogVolData(F29_LogVolData):
pass
class FC3_LogVol(KickstartCommand):
removedKeywords = KickstartCommand.removedKeywords
removedAttrs = KickstartCommand.removedAttrs
def __init__(self, writePriority=133, *args, **kwargs):
KickstartCommand.__init__(self, writePriority, *args, **kwargs)
self.op = self._getParser()
self.lvList = kwargs.get("lvList", [])
def __str__(self):
retval = ""
for part in self.lvList:
retval += part.__str__()
return retval
def _getParser(self):
op = KSOptionParser(prog="logvol", description="""
Create a logical volume for Logical Volume Management
(LVM).""", version=FC3, epilog="""
Create the partition first, create the logical volume
group, and then create the logical volume. For example::
part pv.01 --size 3000
volgroup myvg pv.01
logvol / --vgname=myvg --size=2000 --name=rootvol
""", conflicts=self.conflictingCommands)
op.add_argument("mntpoint", metavar="<mntpoint>", type=mountpoint, nargs=1,
version=FC3, help="""
Mountpoint for this logical volume or 'none'.
""")
op.add_argument("--fstype", version=FC3, help="""
Sets the file system type for the logical volume. Valid
values include ext4, ext3, ext2, btrfs, swap, and vfat.
Other filesystems may be valid depending on command line
arguments passed to Anaconda to enable other filesystems.
""")
op.add_argument("--grow", action="store_true", default=False,
version=FC3, help="""
Tells the logical volume to grow to fill available space
(if any), or up to the maximum size setting. Note that
``--grow`` is not supported for logical volumes containing
a RAID volume on top of them.""")
op.add_argument("--maxsize", dest="maxSizeMB", type=int,
version=FC3, help="""
The maximum size in MiB the logical volume may grow to.
Specify an integer value here, and do not append any
units. This option is only relevant if ``--grow`` is
specified as well.""")
op.add_argument("--name", required=True, version=FC3, help="""
The name of this logical volume.""")
op.add_argument("--noformat", action="store_false", version=FC3,
dest="format", default=True, help="""
Use an existing logical volume and do not format it.
""")
op.add_argument("--percent", dest="percent", type=int,
version=FC3, help="""
Specify the size of the logical volume as a percentage
of available space in the volume group. Without the above
``--grow`` option, this may not work.""")
op.add_argument("--recommended", action="store_true", default=False,
version=FC3, help="""
Determine the size of the logical volume automatically.
""")
op.add_argument("--size", type=int, version=FC3, help="""
Size of this logical volume.""")
op.add_argument("--useexisting", dest="preexist", version=FC3,
action="store_true", default=False,
help="Use an existing logical volume and reformat it.")
op.add_argument("--vgname", required=True, version=FC3, help="""
Name of the Volume Group this logical volume belongs to.
""")
return op
def parse(self, args):
(ns, extra) = self.op.parse_known_args(args=args, lineno=self.lineno)
if extra:
mapping = {"command": "logvol", "options": extra}
raise KickstartParseError(_("Unexpected arguments to %(command)s command: %(options)s") % mapping, lineno=self.lineno)
lvd = self.dataClass() # pylint: disable=not-callable
self.set_to_obj(ns, lvd)
lvd.lineno = self.lineno
lvd.mountpoint = ns.mntpoint[0]
if not lvd.format:
lvd.preexist = True
# Check for duplicates in the data list.
if lvd in self.dataList():
warnings.warn(_("A logical volume with the name %(logical_volume_name)s has already been defined in volume group %(volume_group)s.") % {"logical_volume_name": lvd.name, "volume_group": lvd.vgname}, KickstartParseWarning)
return lvd
def dataList(self):
return self.lvList
@property
def dataClass(self):
return self.handler.LogVolData
class FC4_LogVol(FC3_LogVol):
removedKeywords = FC3_LogVol.removedKeywords
removedAttrs = FC3_LogVol.removedAttrs
def _getParser(self):
op = FC3_LogVol._getParser(self)
op.add_argument("--bytes-per-inode", dest="bytesPerInode", type=int,
version=FC4, help="Specify the bytes/inode ratio.")
op.add_argument("--fsoptions", dest="fsopts", version=FC4, help="""
Specifies a free form string of options to be used when
mounting the filesystem. This string will be copied into
the ``/etc/fstab`` file of the installed system and should
be enclosed in quotes.""")
return op
class RHEL5_LogVol(FC4_LogVol):
removedKeywords = FC4_LogVol.removedKeywords
removedAttrs = FC4_LogVol.removedAttrs
def _getParser(self):
op = FC4_LogVol._getParser(self)
op.add_argument("--encrypted", action="store_true", version=RHEL5,
default=False, help="""
Specify that this logical volume should be encrypted.
""")
op.add_argument("--passphrase", version=RHEL5, help="""
Specify the passphrase to use when encrypting this
logical volume. Without the above ``--encrypted``
option, this option does nothing. If no passphrase is
specified, the default system-wide one is used, or the
installer will stop and prompt if there is no default.
""")
return op
class F9_LogVol(FC4_LogVol):
removedKeywords = FC4_LogVol.removedKeywords
removedAttrs = FC4_LogVol.removedAttrs
def _getParser(self):
op = FC4_LogVol._getParser(self)
op.add_argument("--bytes-per-inode", deprecated=F9)
op.add_argument("--fsprofile", version=F9, help="""
Specifies a usage type to be passed to the program that
makes a filesystem on this partition. A usage type
defines a variety of tuning parameters to be used when
making a filesystem. For this option to work, the
filesystem must support the concept of usage types and
there must be a configuration file that lists valid
types. For ext2/3/4, this configuration file is
``/etc/mke2fs.conf``.""")
op.add_argument("--encrypted", action="store_true", default=False,
version=F9, help="""
Specify that this logical volume should be encrypted.
""")
op.add_argument("--passphrase", version=F9, help="""
Specify the passphrase to use when encrypting this
logical volume. Without the above ``--encrypted``
option, this option does nothing. If no passphrase is
specified, the default system-wide one is used, or the
installer will stop and prompt if there is no default.
""")
return op
class F12_LogVol(F9_LogVol):
removedKeywords = F9_LogVol.removedKeywords
removedAttrs = F9_LogVol.removedAttrs
def _getParser(self):
op = F9_LogVol._getParser(self)
op.add_argument("--escrowcert", metavar="<url>", version=F12, help="""
Load an X.509 certificate from ``<url>``. Store the data
encryption key of this logical volume, encrypted using
the certificate, as a file in ``/root``. Only relevant
if ``--encrypted`` is specified as well.""")
op.add_argument("--backuppassphrase", action="store_true", version=F12,
default=False, help="""
Only relevant if ``--escrowcert`` is specified as well.
In addition to storing the data encryption key, generate
a random passphrase and add it to this logical volume.
Then store the passphrase, encrypted using the certificate
specified by ``--escrowcert``, as a file in ``/root``. If
more than one LUKS volume uses ``--backuppassphrase``,
the same passphrase will be used for all such volumes.
""")
return op
class RHEL6_LogVol(F12_LogVol):
removedKeywords = F12_LogVol.removedKeywords
removedAttrs = F12_LogVol.removedAttrs
conflictingCommands = ["autopart"]
def _getParser(self):
op = F12_LogVol._getParser(self)
op.add_argument("--cipher", version=RHEL6, help="""
Only relevant if ``--encrypted`` is specified. Specifies
which encryption algorithm should be used to encrypt the
filesystem.""")
op.add_argument("--hibernation", action="store_true", default=False,
version=RHEL6, help="""
This option can be used to automatically determine the
size of the swap partition big enough for hibernation.
""")
op.add_argument("--thinpool", action="store_true", version=RHEL6,
dest="thin_pool", default=False, help="""
Create a thin pool logical volume. Use a mountpoint of
'none'""")
op.add_argument("--thin", action="store_true", version=RHEL6,
dest="thin_volume", default=False, help="""
Create a thin logical volume. Requires ``--poolname``.
""")
op.add_argument("--poolname", dest="pool_name", version=RHEL6, help="""
Specify the name of the thin pool in which to create a
thin logical volume. Requires ``--thin``.""")
op.add_argument("--chunksize", type=int, dest="chunk_size",
version=RHEL6, help="""
Specify the chunk size (in KiB) for a new thin pool
device.""")
op.add_argument("--metadatasize", type=int, dest="metadata_size",
version=RHEL6, help="""
Specify the metadata area size (in MiB) for a new thin
pool device.""")
op.add_argument("--profile", version=RHEL6, help="""
Specify an LVM profile for the thin pool (see ``lvm(8)``,
standard profiles are ``default`` and ``thin-performance``
defined in the ``/etc/lvm/profile/`` directory).""")
return op
def parse(self, args):
# call the overriden method
retval = F12_LogVol.parse(self, args)
if retval.thin_volume and retval.thin_pool:
errorMsg = _("--thin and --thinpool cannot both be specified for "
"the same logvol")
raise KickstartParseError(errorMsg, lineno=self.lineno)
if retval.thin_volume and not retval.pool_name:
errorMsg = _("--thin requires --poolname to specify pool name")
raise KickstartParseError(errorMsg, lineno=self.lineno)
if (retval.chunk_size or retval.metadata_size) and \
not retval.thin_pool:
errorMsg = _("--chunksize and --metadatasize are for thin pools only")
raise KickstartParseError(errorMsg, lineno=self.lineno)
return retval
class F14_LogVol(F12_LogVol):
removedKeywords = F12_LogVol.removedKeywords
removedAttrs = F12_LogVol.removedAttrs
def _getParser(self):
op = F12_LogVol._getParser(self)
op.remove_argument("--bytes-per-inode", version=F14)
return op
class F15_LogVol(F14_LogVol):
removedKeywords = F14_LogVol.removedKeywords
removedAttrs = F14_LogVol.removedAttrs
def _getParser(self):
op = F14_LogVol._getParser(self)
op.add_argument("--label", version=F15, help="""
Specify the label to give to the filesystem to be made.
If the given label is already in use by another
filesystem, a new label will be created.""")
return op
class F17_LogVol(F15_LogVol):
removedKeywords = F15_LogVol.removedKeywords
removedAttrs = F15_LogVol.removedAttrs
def _getParser(self):
op = F15_LogVol._getParser(self)
op.add_argument("--resize", action="store_true", default=False,
version=F17, help="""
Attempt to resize this logical volume to the size given
by ``--size=``. This option must be used with
``--useexisting --size=``, or an error will be raised.
""")
return op
def parse(self, args):
retval = F15_LogVol.parse(self, args)
if retval.resize and not retval.preexist:
raise KickstartParseError(_("--resize can only be used in conjunction with --useexisting"), lineno=self.lineno)
if retval.resize and not retval.size:
raise KickstartParseError(_("--resize requires --size to indicate new size"), lineno=self.lineno)
return retval
class F18_LogVol(F17_LogVol):
removedKeywords = F17_LogVol.removedKeywords
removedAttrs = F17_LogVol.removedAttrs
def _getParser(self):
op = F17_LogVol._getParser(self)
op.add_argument("--hibernation", action="store_true", default=False,
version=F18, help="""
This option can be used to automatically determine the
size of the swap partition big enough for hibernation.
""")
op.add_argument("--cipher", version=F18, help="""
Only relevant if ``--encrypted`` is specified. Specifies
which encryption algorithm should be used to encrypt the
filesystem.""")
return op
class F20_LogVol(F18_LogVol):
removedKeywords = F18_LogVol.removedKeywords
removedAttrs = F18_LogVol.removedAttrs
conflictingCommands = ["autopart", "mount"]
def _getParser(self):
op = F18_LogVol._getParser(self)
op.add_argument("--thinpool", action="store_true", version=F20,
dest="thin_pool", default=False, help="""
Create a thin pool logical volume. Use a mountpoint
of 'none'.""")
op.add_argument("--thin", action="store_true", version=F20,
dest="thin_volume", default=False, help="""
Create a thin logical volume. Requires ``--poolname``.
""")
op.add_argument("--poolname", dest="pool_name", version=F20, help="""
Specify the name of the thin pool in which to create a
thin logical volume. Requires ``--thin``.""")
op.add_argument("--chunksize", type=int, dest="chunk_size",
version=F20, help="""
Specify the chunk size (in KiB) for a new thin pool
device.""")
op.add_argument("--metadatasize", type=int, dest="metadata_size",
version=F20, help="""
Specify the metadata area size (in MiB) for a new thin
pool device.""")
return op
def parse(self, args):
retval = F18_LogVol.parse(self, args)
if retval.thin_volume and retval.thin_pool:
err = _("--thin and --thinpool cannot both be specified for the same logvol")
raise KickstartParseError(err, lineno=self.lineno)
if retval.thin_volume and not retval.pool_name:
err = _("--thin requires --poolname to specify pool name")
raise KickstartParseError(err, lineno=self.lineno)
if (retval.chunk_size or retval.metadata_size) and \
not retval.thin_pool:
err = _("--chunksize and --metadatasize are for thin pools only")
raise KickstartParseError(err, lineno=self.lineno)
if not retval.preexist and not retval.percent and not retval.size and not retval.recommended and not retval.hibernation:
errorMsg = _("No size given for logical volume. Use one of --useexisting, --noformat, --size, --percent, or --hibernation.")
raise KickstartParseError(errorMsg, lineno=self.lineno)
if retval.percent is not None and (retval.percent < 0 or retval.percent > 100):
errorMsg = _("Percentage must be between 0 and 100.")
raise KickstartParseError(errorMsg, lineno=self.lineno)
return retval
class F21_LogVol(F20_LogVol):
removedKeywords = F20_LogVol.removedKeywords
removedAttrs = F20_LogVol.removedAttrs
def _getParser(self):
op = F20_LogVol._getParser(self)
op.add_argument("--profile", version=F21, help="""
Specify an LVM profile for the thin pool (see ``lvm(8)``,
standard profiles are ``default`` and ``thin-performance``
defined in the ``/etc/lvm/profile/`` directory).""")
return op
def parse(self, args):
retval = F20_LogVol.parse(self, args)
if retval.size and retval.percent:
err = _("--size and --percent cannot both be specified for the same logvol")
raise KickstartParseError(err, lineno=self.lineno)
return retval
class RHEL7_LogVol(F21_LogVol):
removedKeywords = F21_LogVol.removedKeywords
removedAttrs = F21_LogVol.removedAttrs
def _getParser(self):
op = F21_LogVol._getParser(self)
op.add_argument("--mkfsoptions", dest="mkfsopts", version=RHEL7, help="""
Specifies additional parameters to be passed to the
program that makes a filesystem on this partition. No
processing is done on the list of arguments, so they
must be supplied in a format that can be passed directly
to the mkfs program. This means multiple options should
be comma-separated or surrounded by double quotes,
depending on the filesystem.""")
return op
def parse(self, args):
retval = F21_LogVol.parse(self, args)
if not retval.format and retval.mkfsopts:
raise KickstartParseError(_("--mkfsoptions with --noformat has no effect."), lineno=self.lineno)
if retval.fsprofile and retval.mkfsopts:
raise KickstartParseError(_("--mkfsoptions and --fsprofile cannot be used together."), lineno=self.lineno)
return retval
class F23_LogVol(F21_LogVol):
def _getParser(self):
op = F21_LogVol._getParser(self)
op.add_argument("--cachesize", type=int, dest="cache_size",
version=F23, help="""
Requested size (in MiB) of cache attached to the logical
volume. Requires ``--cachepvs``.""")
op.add_argument("--cachemode", dest="cache_mode", version=F23, help="""
Mode that should be used for the cache. Either
``writeback`` or ``writethrough``.""")
op.add_argument("--cachepvs", dest="cache_pvs", type=commaSplit,
version=F23, help="""
Comma-separated list of (fast) physical volumes that
should be used for the cache.""")
op.add_argument("--mkfsoptions", dest="mkfsopts", version=F23, help="""
Specifies additional parameters to be passed to the
program that makes a filesystem on this partition. No
processing is done on the list of arguments, so they
must be supplied in a format that can be passed directly
to the mkfs program. This means multiple options should
be comma-separated or surrounded by double quotes,
depending on the filesystem.""")
return op
def parse(self, args):
retval = F21_LogVol.parse(self, args)
if retval.cache_size or retval.cache_mode or retval.cache_pvs:
if retval.preexist:
err = _("Adding a cache to an existing logical volume is not supported")
raise KickstartParseError(err, lineno=self.lineno)
if retval.thin_volume:
err = _("Thin volumes cannot be cached")
raise KickstartParseError(err, lineno=self.lineno)
if not retval.cache_pvs:
err = _("Cache needs to have a list of (fast) PVs specified")
raise KickstartParseError(err, lineno=self.lineno)
if not retval.cache_size:
err = _("Cache needs to have size specified")
raise KickstartParseError(err, lineno=self.lineno)
if retval.cache_mode and retval.cache_mode not in ("writeback", "writethrough"):
err = _("Invalid cache mode given: %s") % retval.cache_mode
raise KickstartParseError(err, lineno=self.lineno)
if not retval.format and retval.mkfsopts:
raise KickstartParseError(_("--mkfsoptions with --noformat has no effect."), lineno=self.lineno)
if retval.fsprofile and retval.mkfsopts:
raise KickstartParseError(_("--mkfsoptions and --fsprofile cannot be used together."), lineno=self.lineno)
return retval
class F29_LogVol(F23_LogVol):
removedKeywords = F23_LogVol.removedKeywords
removedAttrs = F23_LogVol.removedAttrs
def _getParser(self):
op = F23_LogVol._getParser(self)
op.add_argument("--luks-version", dest="luks_version", version=F29, default="",
help="""
Only relevant if ``--encrypted`` is specified. Specifies
which version of LUKS format should be used to encrypt
the filesystem.""")
op.add_argument("--pbkdf", version=F29, default="", help="""
Only relevant if ``--encrypted`` is specified. Sets
Password-Based Key Derivation Function (PBKDF) algorithm
for LUKS keyslot. See ``man cryptsetup``.""")
op.add_argument("--pbkdf-memory", dest="pbkdf_memory", type=int, default=0,
version=F29, help="""
Only relevant if ``--encrypted`` is specified. Sets
the memory cost for PBKDF. See ``man cryptsetup``.""")
op.add_argument("--pbkdf-time", dest="pbkdf_time", type=int, default=0,
version=F29, help="""
Only relevant if ``--encrypted`` is specified. Sets
the number of milliseconds to spend with PBKDF passphrase
processing. See ``--iter-time`` in ``man cryptsetup``.
Only one of ``--pbkdf-time`` and ``--pbkdf-iterations``
can be specified.
""")
op.add_argument("--pbkdf-iterations", dest="pbkdf_iterations", type=int, default=0,
version=F29, help="""
Only relevant if ``--encrypted`` is specified. Sets
the number of iterations directly and avoids PBKDF benchmark.
See ``--pbkdf-force-iterations`` in ``man cryptsetup``.
Only one of ``--pbkdf-time`` and ``--pbkdf-iterations``
can be specified.
""")
return op
def parse(self, args):
retval = F23_LogVol.parse(self, args)
if retval.pbkdf_time and retval.pbkdf_iterations:
msg = _("Only one of --pbkdf-time and --pbkdf-iterations can be specified.")
raise KickstartParseError(msg, lineno=self.lineno)
return retval
class RHEL8_LogVol(F29_LogVol):
removedKeywords = F29_LogVol.removedKeywords
removedAttrs = F29_LogVol.removedAttrs
def parse(self, args):
retval = F29_LogVol.parse(self, args)
if retval.fstype == "btrfs":
raise KickstartParseError(_("Btrfs file system is not supported"), lineno=self.lineno)
return retval
def _getParser(self):
"Only necessary for the type change documentation"
op = F29_LogVol._getParser(self)
for action in op._actions:
if "--fstype" in action.option_strings:
action.help += """
.. versionchanged:: %s
Btrfs support was removed.""" % versionToLongString(RHEL8)
return op
class RHEL9_LogVol(RHEL8_LogVol):
pass
class RHEL10_LogVol(RHEL8_LogVol):
pass