2 # Chris Lumens <clumens@redhat.com>
4 # Copyright 2013 Red Hat, Inc.
6 # This copyrighted material is made available to anyone wishing to use, modify,
7 # copy, or redistribute it subject to the terms and conditions of the GNU
8 # General Public License v.2. This program is distributed in the hope that it
9 # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10 # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 # See the GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License along with
14 # this program; if not, write to the Free Software Foundation, Inc., 51
15 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16 # trademarks that are incorporated in the source code or documentation are not
17 # subject to the GNU General Public License and may only be used or replicated
18 # with the express permission of Red Hat, Inc.
20 from pykickstart
.base
import KickstartCommand
22 class FC3_Method(KickstartCommand
):
23 removedKeywords
= KickstartCommand
.removedKeywords
24 removedAttrs
= KickstartCommand
.removedAttrs
26 # These are all set up as part of the base KickstartCommand. We want to
27 # make sure looking them up gets redirected to the right place.
28 internals
= ["method",
29 "writePriority", "currentCmd", "currentLine", "handler", "lineno", "seen"]
31 _methods
= ["cdrom", "harddrive", "nfs", "url"]
33 def _clear_seen(self
):
34 """ Reset all the method's seen attrs to False"""
35 for method
in self
._methods
:
36 setattr(getattr(self
.handler
, method
), "seen", False)
38 def __getattr__(self
, name
):
39 if name
in self
.internals
:
41 for method
in self
._methods
:
42 if getattr(self
.handler
, method
).seen
:
46 return object.__getattribute
__(self
, name
)
48 # Return name from first seen handler, or url
49 for method
in self
._methods
:
50 if getattr(self
.handler
, method
).seen
:
51 return getattr(getattr(self
.handler
, method
), name
)
53 return getattr(self
.handler
.url
, name
)
55 def __setattr__(self
, name
, value
):
56 if name
in self
.internals
:
59 if name
== "method" and value
== "cdrom":
60 setattr(self
.handler
.cdrom
, "seen", True)
61 elif name
== "method" and value
== "harddrive":
62 setattr(self
.handler
.harddrive
, "seen", True)
63 elif name
== "method" and value
== "nfs":
64 setattr(self
.handler
.nfs
, "seen", True)
65 elif name
== "method" and value
== "url":
66 setattr(self
.handler
.url
, "seen", True)
67 KickstartCommand
.__setattr
__(self
, name
, value
)
68 elif self
.handler
.cdrom
.seen
:
69 setattr(self
.handler
.cdrom
, name
, value
)
70 elif self
.handler
.harddrive
.seen
:
71 setattr(self
.handler
.harddrive
, name
, value
)
72 elif self
.handler
.nfs
.seen
:
73 setattr(self
.handler
.nfs
, name
, value
)
75 setattr(self
.handler
.url
, name
, value
)
77 # These are all just for compat. Calling into the appropriate version-specific
78 # method command will deal with making sure the right options are used.
79 FC6_Method
= FC3_Method
81 F13_Method
= FC6_Method
83 F14_Method
= F13_Method
85 RHEL6_Method
= F14_Method
87 F18_Method
= F14_Method
89 class F19_Method(FC3_Method
):
90 removedKeywords
= FC3_Method
.removedKeywords
91 removedAttrs
= FC3_Method
.removedAttrs
93 _methods
= FC3_Method
._methods
+ ["liveimg"]
95 def __getattr__(self
, name
):
96 if self
.handler
.liveimg
.seen
:
100 return getattr(self
.handler
.liveimg
, name
)
102 return FC3_Method
.__getattr
__(self
, name
)
104 def __setattr__(self
, name
, value
):
105 if name
in self
.internals
:
108 if name
== "method" and value
== "liveimg":
109 setattr(self
.handler
.liveimg
, "seen", True)
111 FC3_Method
.__setattr
__(self
, name
, value
)
112 elif self
.handler
.liveimg
.seen
:
113 setattr(self
.handler
.liveimg
, name
, value
)
115 FC3_Method
.__setattr
__(self
, name
, value
)