summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cobbler/commands.py64
-rw-r--r--cobbler/modules/cli_distro.py16
-rw-r--r--cobbler/modules/cli_profile.py99
-rw-r--r--cobbler/modules/cli_repo.py77
-rw-r--r--cobbler/modules/cli_system.py99
-rw-r--r--docs/cobbler.pod24
6 files changed, 329 insertions, 50 deletions
diff --git a/cobbler/commands.py b/cobbler/commands.py
index 59c1fb2..3ef223a 100644
--- a/cobbler/commands.py
+++ b/cobbler/commands.py
@@ -15,6 +15,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import optparse
from cexceptions import *
from rhpl.translate import _, N_, textdomain, utf8
+import sys
#=============================================================
@@ -52,10 +53,10 @@ class FunctionLoader:
fn = self.functions[called_name]
# some functions require args, if none given, show subcommands
- if len(args) == 2:
- no_args_rc = fn.no_args_handler()
- if no_args_rc:
- return True
+ #if len(args) == 2:
+ # no_args_rc = fn.no_args_handler()
+ # if no_args_rc:
+ # return True
# finally let the object parse its own args
loaded_ok = fn.parse_args(args)
@@ -71,7 +72,7 @@ class FunctionLoader:
print "usage:"
print "======"
for name in self.functions.keys():
- print " cobbler %s ... | --help" % name
+ print "cobbler %s --help]" % name
#=============================================================
@@ -83,13 +84,6 @@ class CobblerFunction:
"""
self.api = api
- def no_args_handler(self):
- """
- Called when no additional args are given to a command. False implies
- this is ok, returning True indicates an error condition.
- """
- return False
-
def command_name(self):
"""
The name of the command, as to be entered by users.
@@ -127,13 +121,21 @@ class CobblerFunction:
break
p = optparse.OptionParser(usage="cobbler %s [ARGS]" % accum)
self.add_options(p, args)
- if len(args) > 2:
- for x in args[2:]:
- if x.startswith("-"):
- break
- if x not in self.subcommands():
- raise CX(_("Argument (%s) not recognized") % x)
-
+
+ # if using subcommands, ensure one and only one is used
+ subs = self.subcommands()
+ if len(subs) > 0:
+ count = 0
+ for x in subs:
+ if x in args:
+ count = count + 1
+ if count != 1:
+ print "usage:"
+ print "======"
+ for x in subs:
+ print "cobbler %s %s [ARGS|--help]" % (self.command_name(), x)
+ sys.exit(1)
+
(self.options, self.args) = p.parse_args(args)
return True
@@ -177,18 +179,18 @@ class CobblerFunction:
return rc
- def no_args_handler(self):
-
- """
- Used to accept/reject/explain subcommands. Do not override.
- """
-
- subs = self.subcommands()
- if len(subs) == 0:
- return False
- for x in subs:
- print " cobbler %s %s --help" % (self.command_name(), x)
- return True # stop here
+ #def no_args_handler(self):
+ #
+ # """
+ # Used to accept/reject/explain subcommands. Do not override.
+ # """
+ #
+ # subs = self.subcommands()
+ # if len(subs) == 0:
+ # return False
+ # for x in subs:
+ # print " cobbler %s %s [ARGS|--help]" % (self.command_name(), x)
+ # return True # stop here
diff --git a/cobbler/modules/cli_distro.py b/cobbler/modules/cli_distro.py
index dd9ba4e..ff08e8c 100644
--- a/cobbler/modules/cli_distro.py
+++ b/cobbler/modules/cli_distro.py
@@ -33,16 +33,16 @@ class DistroFunction(commands.CobblerFunction):
return [ "add", "edit", "copy", "rename", "delete" ]
def add_options(self, p, args):
- p.add_option("--name", dest="name")
if not "delete" in args:
- p.add_option("--kernel", dest="kernel")
- p.add_option("--initrd", dest="initrd")
- p.add_option("--kopts", dest="kopts")
- p.add_option("--ksmeta", dest="ksmeta")
- p.add_option("--arch", dest="arch")
- p.add_option("--breed", dest="breed")
+ p.add_option("--arch", dest="arch", help="ex: x86, x86_64, ia64")
+ p.add_option("--breed", dest="breed", help="ex: redhat, debian, suse")
+ p.add_option("--initrd", dest="initrd", help="absolute path to initrd.img (REQUIRED)")
+ p.add_option("--kernel", dest="kernel", help="absolute path to vmlinuz (REQUIRED)")
+ p.add_option("--kopts", dest="kopts", help="ex: 'noipv6'")
+ p.add_option("--ksmeta", dest="ksmeta", help="ex: 'blippy=7'")
+ p.add_option("--name", dest="name", help="ex: 'RHEL-5-i386' (REQUIRED)")
if "copy" in args or "rename" in args:
- p.add_option("--newname", dest="newname")
+ p.add_option("--newname", dest="newname", help="for copy/rename commands")
def run(self):
diff --git a/cobbler/modules/cli_profile.py b/cobbler/modules/cli_profile.py
new file mode 100644
index 0000000..8385986
--- /dev/null
+++ b/cobbler/modules/cli_profile.py
@@ -0,0 +1,99 @@
+"""
+Profile CLI module.
+
+Copyright 2007, Red Hat, Inc
+Michael DeHaan <mdehaan@redhat.com>
+
+This software may be freely redistributed under the terms of the GNU
+general public license.
+
+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., 675 Mass Ave, Cambridge, MA 02139, USA.
+"""
+
+import distutils.sysconfig
+import sys
+
+plib = distutils.sysconfig.get_python_lib()
+mod_path="%s/cobbler" % plib
+sys.path.insert(0, mod_path)
+
+from rhpl.translate import _, N_, textdomain, utf8
+import commands
+import cexceptions
+
+
+class ProfileFunction(commands.CobblerFunction):
+
+ def command_name(self):
+ return "profile"
+
+ def subcommands(self):
+ return [ "add", "edit", "copy", "rename", "delete" ]
+
+ def add_options(self, p, args):
+ if not "delete" in args:
+ p.add_option("--distro", dest="distro", help="ex: 'RHEL-5-i386' (REQUIRED)")
+ p.add_option("--dhcp-tag", dest="dhcp_tag", help="for use in advanced DHCP configuration")
+ p.add_option("--inherit", dest="inherit", help="inherit from this profile name, defaults to no")
+ p.add_option("--kickstart", dest="kickstart", help="absolute path to kickstart template (RECOMMENDED)")
+ p.add_option("--ksmeta", dest="ksmeta", help="ex: 'blippy=7'")
+ p.add_option("--kopts", dest="kopts", help="ex: 'noipv6'")
+ p.add_option("--name", dest="name", help="a name for the profile (REQUIRED)")
+ if "copy" in args or "rename" in args:
+ p.add_option("--newname", dest="newname")
+ if not "delete" in args:
+ p.add_option("--repos", dest="repos", help="names of cobbler repos")
+ p.add_option("--server-override", dest="server_override", help="overrides value in settings file")
+ p.add_option("--virt-bridge", dest="virt_bridge", help="ex: 'virbr0'")
+ p.add_option("--virt-cpus", dest="virt_cpus", help="integer (default: 1)")
+ p.add_option("--virt-file-size", dest="virt_file_size", help="size in GB")
+ p.add_option("--virt-path", dest="virt_path", help="path, partition, or volume")
+ p.add_option("--virt-ram", dest="virt_ram", help="size in MB")
+ p.add_option("--virt-type", dest="virt_type", help="ex: 'xenpv', 'qemu'")
+
+ def run(self):
+
+
+ if self.options.inherit:
+ obj = self.object_manipulator_start(self.api.new_profile,self.api.profiles,subobject=True)
+ else:
+ obj = self.object_manipulator_start(self.api.new_profile,self.api.profiles,subobject=False)
+
+ if obj is None:
+ return True
+
+ if self.options.inherit: obj.set_parent(self.options.inherit)
+ if self.options.distro: obj.set_distro(self.options.distro)
+ if self.options.kickstart: obj.set_kickstart(self.options.kickstart)
+ if self.options.kopts: obj.set_kernel_options(self.options.kopts)
+ if self.options.ksmeta: obj.set_ksmeta(self.options.ksmeta)
+ if self.options.virt_file_size: obj.set_virt_file_size(self.options.virt_file_size)
+ if self.options.virt_ram: obj.set_virt_ram(self.options.virt_ram)
+ if self.options.virt_bridge: obj.set_virt_bridge(self.options.virt_bridge)
+ if self.options.virt_cpus: obj.set_virt_cpus(self.options.virt_cpus)
+ if self.options.repos: obj.set_repos(self.options.repos)
+ if self.options.virt_path: obj.set_virt_path(self.options.virt_path)
+ if self.options.dhcp_tag: obj.set_dhcp_tag(self.options.dhcp_tag)
+ if self.options.server_override: obj.set_server(self.options.server)
+
+ return self.object_manipulator_finish(obj, self.api.profiles)
+
+
+
+########################################################
+# MODULE HOOKS
+
+def register():
+ """
+ The mandatory cobbler module registration hook.
+ """
+ return "cli"
+
+def cli_functions(api):
+ return [
+ ProfileFunction(api)
+ ]
+
+
diff --git a/cobbler/modules/cli_repo.py b/cobbler/modules/cli_repo.py
new file mode 100644
index 0000000..09fa234
--- /dev/null
+++ b/cobbler/modules/cli_repo.py
@@ -0,0 +1,77 @@
+"""
+Repo CLI module.
+
+Copyright 2007, Red Hat, Inc
+Michael DeHaan <mdehaan@redhat.com>
+
+This software may be freely redistributed under the terms of the GNU
+general public license.
+
+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., 675 Mass Ave, Cambridge, MA 02139, USA.
+"""
+
+import distutils.sysconfig
+import sys
+
+plib = distutils.sysconfig.get_python_lib()
+mod_path="%s/cobbler" % plib
+sys.path.insert(0, mod_path)
+
+from rhpl.translate import _, N_, textdomain, utf8
+import commands
+import cexceptions
+
+
+class RepoFunction(commands.CobblerFunction):
+
+ def command_name(self):
+ return "repo"
+
+ def subcommands(self):
+ return [ "add", "edit", "copy", "rename", "delete" ]
+
+ def add_options(self, p, args):
+ if not "delete" in args:
+ p.add_option("--arch", dest="arch", help="overrides repo arch if required")
+ p.add_option("--createrepo-flags", dest="createrepo_flags", help="additional flags for createrepo")
+ p.add_option("--rpm-list", dest="rpm_list", help="just mirror these rpms")
+ p.add_option("--keep-updated", dest="keep_updated", help="update on each reposync, yes/no")
+ p.add_option("--mirror", dest="mirror", help="source to mirror (REQUIRED)")
+ p.add_option("--name", dest="name", help="ex: 'Fedora-8-updates-i386' (REQUIRED)")
+ if "copy" in args or "rename" in args:
+ p.add_option("--newname", dest="newname", help="used for copy/edit")
+
+ def run(self):
+
+ obj = self.object_manipulator_start(self.api.new_repo,self.api.repos)
+ if obj is None:
+ return True
+
+ if self.options.arch: obj.set_arch(self.options.arch)
+ if self.options.createrepo_flags: obj.set_createrepo_flags(self.options.createrepo_flags)
+ if self.options.rpm_list: obj.set_rpm_list(self.options.rpm_list)
+ if self.options.keep_updated: obj.set_keep_updated(self.options.keep_updated)
+ if self.options.mirror: obj.set_mirror(self.options.mirror)
+
+ return self.object_manipulator_finish(obj, self.api.repos)
+
+
+
+########################################################
+# MODULE HOOKS
+
+def register():
+ """
+ The mandatory cobbler module registration hook.
+ """
+ return "cli"
+
+def cli_functions(api):
+ return [
+ RepoFunction(api)
+ ]
+ return []
+
+
diff --git a/cobbler/modules/cli_system.py b/cobbler/modules/cli_system.py
new file mode 100644
index 0000000..bfc5c2f
--- /dev/null
+++ b/cobbler/modules/cli_system.py
@@ -0,0 +1,99 @@
+"""
+System CLI module.
+
+Copyright 2007, Red Hat, Inc
+Michael DeHaan <mdehaan@redhat.com>
+
+This software may be freely redistributed under the terms of the GNU
+general public license.
+
+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., 675 Mass Ave, Cambridge, MA 02139, USA.
+"""
+
+import distutils.sysconfig
+import sys
+
+plib = distutils.sysconfig.get_python_lib()
+mod_path="%s/cobbler" % plib
+sys.path.insert(0, mod_path)
+
+from rhpl.translate import _, N_, textdomain, utf8
+import commands
+import cexceptions
+
+
+class SystemFunction(commands.CobblerFunction):
+
+ def command_name(self):
+ return "system"
+
+ def subcommands(self):
+ return [ "add", "edit", "copy", "rename", "delete" ]
+
+
+ def add_options(self, p, args):
+ if not "delete" in args:
+ p.add_option("--dhcp-tag", dest="dhcp_tag", help="for use in advanced DHCP configurations")
+ p.add_option("--gateway", dest="gateway", help="for static IP / templating usage")
+ p.add_option("--hostname", dest="hostname", help="ex: server.example.org")
+ p.add_option("--interface", dest="interface", help="edit this interface # (0-7, default 0)")
+ p.add_option("--ip", dest="ip", help="ex: 192.168.1.55, (RECOMMENDED)")
+ p.add_option("--kopts", dest="kopts", help="ex: 'noipv6'")
+ p.add_option("--ksmeta", dest="ksmeta", help="ex: 'blippy=7'")
+ p.add_option("--mac", dest="mac", help="ex: 'AA:BB:CC:DD:EE:FF', (RECOMMENDED)")
+ p.add_option("--name", dest="name", help="a name for the system (REQUIRED)")
+ if not "delete" in args:
+ p.add_option("--netboot-enabled", dest="netboot_enabled", help="PXE on (1) or off (0)")
+ if "copy" in args or "rename" in args:
+ p.add_option("--newname", dest="newname", help="for use with copy/edit")
+ if not "delete" in args:
+ p.add_option("--profile", dest="profile", help="name of cobbler profile (REQUIRED)")
+ p.add_option("--server-override", dest="server_override", help="overrides server value in settings file")
+ p.add_option("--subnet", dest="subnet", help="for static IP / templating usage")
+ p.add_option("--virt-bridge", dest="virt_bridge", help="ex: virbr0")
+ p.add_option("--virt-type", dest="virt_type", help="ex: xenpv, qemu")
+
+
+ def run(self):
+
+ obj = self.object_manipulator_start(self.api.new_system,self.api.systems)
+ if obj is None:
+ return True
+
+ if self.options.profile: obj.set_profile(self.options.profile)
+ if self.options.kopts: obj.set_kernel_options(self.options.kopts)
+ if self.options.ksmeta: obj.set_ksmeta(self.options.ksmeta)
+ if self.options.netboot_enabled: obj.set_netboot_enabled(self.options.netboot_enabled)
+ if self.options.server_override: obj.set_server(self.options.server_override)
+ if self.options.virt_path: obj.set_virt_path(self.options.virt_path)
+ if self.options.virt_type: obj.set_virt_type(self.options.virt_type)
+
+ my_interface = "intf%s" % self.options.interface
+ if self.options.hostname: obj.set_hostname(self.options.hostname, my_interface)
+ if self.options.mac: obj.set_mac_address(self.options.mac, my_interface)
+ if self.options.ip: obj.set_ip_address(self.options.ip, my_interface)
+ if self.options.subnet: obj.set_subnet(self.options.subnet, my_interface)
+ if self.options.gateway: obj.set_gateway(self.options.gateway, my_interface)
+ if self.options.dhcp_tag: obj.set_dhcp_tag(self.options.dhcp_tag, my_interface)
+
+ return self.object_manipulator_finish(obj, self.api.profiles)
+
+
+
+########################################################
+# MODULE HOOKS
+
+def register():
+ """
+ The mandatory cobbler module registration hook.
+ """
+ return "cli"
+
+def cli_functions(api):
+ return [
+ SystemFunction(api)
+ ]
+
+
diff --git a/docs/cobbler.pod b/docs/cobbler.pod
index d99fdab..787e539 100644
--- a/docs/cobbler.pod
+++ b/docs/cobbler.pod
@@ -209,8 +209,6 @@ Specifying a mac address via --mac allows the system object to boot via PXE. If
MAC addresses have the format AA:BB:CC:DD:EE:FF.
-If you would like to specify additional interfaces, use --mac0=x, --mac1=y and so on. Interfaces 0 through 7 are supported.
-
=item ip
If cobbler is configured to generate a DHCP configuratition (see advanced section), use this
@@ -220,8 +218,6 @@ Example: ---ip=192.168.1.50
Note for Itanium users: this setting is always required for IA64 regardless of whether DHCP management is enabled.
-If you would like to specify additional IPs, use --ip0=x, --ip1=y and so on.
-
If DHCP management is disabled, setting this parameter may still be useful for record keeping, and it is also available in all kickstart templates, so it can be easily used for static IP configuration within kickstarts.
=item hostname
@@ -230,8 +226,6 @@ If using the DHCP configuration feature (see advanced section) with dnsmasq, use
Example: --hostname=mycomputer.example.com
-If you would like to specify additional hostnames, use --hostname0=x, --hostname1=y and so on.
-
=item --gateway and --subnet
If you are using static IP configurations, you may find it useful to store gateway and subnet
@@ -239,9 +233,6 @@ information inside of cobbler. These variables are not used internally by cobbl
made available in cobbler templates, which are described later in this document and on the Wiki.
For DHCP configurations, these parameters should be left blank.
-To describe gateway and subnet information for multiple intefaces, use --gateway0=x, --gateway1=y
-and so on. Subnets work the same way.
-
=item --virt-bridge
(Virt-only) While --virt-bridge is present in the profile object (see above), here it works on an interface by interface basis. For instance it would be possible to have --virt-bridge0=xenbr0 and --virt-bridge1=xenbr1. If not specified in cobbler for each interface, koan will use the value as specified in the profile for each interface, which may not always be what is intended, but will be sufficient in most cases.
@@ -261,10 +252,21 @@ If you are setting up a PXE environment with multiple subnets/gateways, and are
By default, the dhcp tag for all systems is "default" and means that in the DHCP template files the systems will expand out where $insert_cobbler_systems_definitions is found in the DHCP template. However, you may want certain systems to expand out in other places in the file. Setting --dhcp-tag=subnet2 for instance, will cause that system to expand out where $insert_cobbler_system_definitions_subnet2 is found, allowing you to insert directives to specify different subnets (or other parameters) before the DHCP configuration entries for those particular systems.
-If your system has multiple network interfaces, use --dhcp-tag0=x, --dhcp-tag1=y and so on.
-
This is described further on the Cobbler Wiki.
+=item --interface
+
+By default flags like --ip, --mac, --dhcp-tag, --gateway, --subnet, and --virt-bridge operation on the first network
+interface defined for a system. Additional interfaces can be specified (0 through 7) for use with the edit command.
+
+Example:
+
+cobbler system edit --name=foo --ip=192.168.1.50 --mac=AA:BB:CC:DD:EE:A0
+cobbler system edit --name=foo --interface=2 --ip=192.168.1.51 --mac=AA:BB:CC:DD:EE:A1
+cobbler system report foo
+
+NOTE: Additional interfaces can presently only be deleted via the web interface.
+
=end
=head2 ADDING A REPOSITORY TO MIRROR