Skip to content
Snippets Groups Projects
Commit 90b6aa3a authored by Manuel Franceschini's avatar Manuel Franceschini
Browse files

gnt-cluster option to toggle lvm-storage

This patch does two things:
- Add gnt-cluster modify
- Add --no-lvm-storage option to gnt-cluster init

Reviewed-by: iustinp
parent 0cc05d44
No related branches found
No related tags found
No related merge requests found
......@@ -38,10 +38,18 @@ def InitCluster(opts, args):
args - list of arguments, expected to be [clustername]
"""
if not opts.lvm_storage and opts.vg_name:
print ("Options --no-lvm-storage and --vg-name conflict.")
return 1
vg_name = opts.vg_name
if opts.lvm_storage and not opts.vg_name:
vg_name = constants.DEFAULT_VG
op = opcodes.OpInitCluster(cluster_name=args[0],
secondary_ip=opts.secondary_ip,
hypervisor_type=opts.hypervisor_type,
vg_name=opts.vg_name,
vg_name=vg_name,
mac_prefix=opts.mac_prefix,
def_bridge=opts.def_bridge,
master_netdev=opts.master_netdev,
......@@ -272,6 +280,27 @@ def SearchTags(opts, args):
print "%s %s" % (path, tag)
def SetClusterParams(opts, args):
"""Modify the cluster.
Args:
opts - class with options as members
"""
if not (not opts.lvm_storage or opts.vg_name):
print "Please give at least one of the parameters."
return 1
vg_name = opts.vg_name
if not opts.lvm_storage and opts.vg_name:
print ("Options --no-lvm-storage and --vg-name conflict.")
return 1
op = opcodes.OpSetClusterParams(vg_name=opts.vg_name)
SubmitOpCode(op)
return 0
# this is an option common to more than one command, so we declare
# it here and reuse it
node_option = make_option("-n", "--node", action="append", dest="nodes",
......@@ -303,7 +332,7 @@ commands = {
help="Specify the volume group name "
" (cluster-wide) for disk allocation [xenvg]",
metavar="VG",
default="xenvg",),
default=None,),
make_option("-b", "--bridge", dest="def_bridge",
help="Specify the default bridge name (cluster-wide)"
" to connect the instances to [%s]" %
......@@ -322,6 +351,10 @@ commands = {
constants.DEFAULT_FILE_STORAGE_DIR,
metavar="DIR",
default=constants.DEFAULT_FILE_STORAGE_DIR,),
make_option("--no-lvm-storage", dest="lvm_storage",
help="No support for lvm based instances"
" (cluster-wide)",
action="store_false", default=True,),
],
"[opts...] <cluster_name>",
"Initialises a new cluster configuration"),
......@@ -362,6 +395,20 @@ commands = {
'search-tags': (SearchTags, ARGS_ONE,
[DEBUG_OPT], "", "Searches the tags on all objects on"
" the cluster for a given pattern (regex)"),
'modify': (SetClusterParams, ARGS_NONE,
[DEBUG_OPT,
make_option("-g", "--vg-name", dest="vg_name",
help="Specify the volume group name "
" (cluster-wide) for disk allocation "
"and enable lvm based storage",
metavar="VG",),
make_option("--no-lvm-storage", dest="lvm_storage",
help="Disable support for lvm based instances"
" (cluster-wide)",
action="store_false", default=True,),
],
"[opts...]",
"Alters the parameters of the cluster"),
}
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment