Add new RHEL7 logvol objects to master
[pykickstart.git] / pykickstart / commands / vnc.py
blob42b4642a0861b0549afcb204c516e3aaab060f93
2 # Chris Lumens <clumens@redhat.com>
4 # Copyright 2005, 2006, 2007 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
21 from pykickstart.options import KSOptionParser
23 class FC3_Vnc(KickstartCommand):
24 removedKeywords = KickstartCommand.removedKeywords
25 removedAttrs = KickstartCommand.removedAttrs
27 def __init__(self, writePriority=0, *args, **kwargs):
28 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
29 self.op = self._getParser()
31 self.enabled = kwargs.get("enabled", False)
32 self.password = kwargs.get("password", "")
33 self.connect = kwargs.get("connect", "")
35 def __str__(self):
36 retval = KickstartCommand.__str__(self)
38 if not self.enabled:
39 return retval
41 retval += "vnc"
43 if self.connect != "":
44 retval += " --connect=%s" % self.connect
45 if self.password != "":
46 retval += " --password=%s" % self.password
48 return retval + "\n"
50 def _getParser(self):
51 op = KSOptionParser()
52 op.add_option("--connect")
53 op.add_option("--password", dest="password")
54 return op
56 def parse(self, args):
57 self.enabled = True
58 (opts, _extra) = self.op.parse_args(args=args, lineno=self.lineno)
59 self._setToSelf(self.op, opts)
60 return self
62 class FC6_Vnc(FC3_Vnc):
63 removedKeywords = FC3_Vnc.removedKeywords + ["connect"]
64 removedAttrs = FC3_Vnc.removedAttrs + ["connect"]
66 def __init__(self, writePriority=0, *args, **kwargs):
67 FC3_Vnc.__init__(self, writePriority, *args, **kwargs)
68 self.deleteRemovedAttrs()
70 self.host = kwargs.get("host", "")
71 self.port = kwargs.get("port", "")
73 def __str__(self):
74 retval = KickstartCommand.__str__(self)
76 if not self.enabled:
77 return retval
79 retval += "vnc"
81 if self.host != "":
82 retval += " --host=%s" % self.host
84 if self.port != "":
85 retval += " --port=%s" % self.port
86 if self.password != "":
87 retval += " --password=%s" % self.password
89 return retval + "\n"
91 def _getParser(self):
92 def connect_cb (option, opt_str, value, parser):
93 cargs = value.split(":")
94 parser.values.ensure_value("host", cargs[0])
96 if len(cargs) > 1:
97 parser.values.ensure_value("port", cargs[1])
99 op = FC3_Vnc._getParser(self)
100 op.add_option("--connect", action="callback", callback=connect_cb,
101 nargs=1, type="string")
102 op.add_option("--host", dest="host")
103 op.add_option("--port", dest="port")
104 return op
106 class F9_Vnc(FC6_Vnc):
107 removedKeywords = FC6_Vnc.removedKeywords
108 removedAttrs = FC6_Vnc.removedAttrs
110 def _getParser(self):
111 op = FC6_Vnc._getParser(self)
112 op.remove_option("--connect")
113 return op