Revision 973d7867 scripts/gnt-instance
b/scripts/gnt-instance | ||
---|---|---|
134 | 134 |
return choice |
135 | 135 |
|
136 | 136 |
|
137 |
def _TransformPath(user_input): |
|
138 |
"""Transform a user path into a canonical value. |
|
139 |
|
|
140 |
This function transforms the a path passed as textual information |
|
141 |
into the constants that the LU code expects. |
|
142 |
|
|
143 |
""" |
|
144 |
if user_input: |
|
145 |
if user_input.lower() == "default": |
|
146 |
result_path = constants.VALUE_DEFAULT |
|
147 |
elif user_input.lower() == "none": |
|
148 |
result_path = constants.VALUE_NONE |
|
149 |
else: |
|
150 |
if not os.path.isabs(user_input): |
|
151 |
raise errors.OpPrereqError("Path '%s' is not an absolute filename" % |
|
152 |
user_input) |
|
153 |
result_path = user_input |
|
154 |
else: |
|
155 |
result_path = constants.VALUE_DEFAULT |
|
156 |
|
|
157 |
return result_path |
|
158 |
|
|
159 |
|
|
137 | 160 |
def ListInstances(opts, args): |
138 | 161 |
"""List instances and their properties. |
139 | 162 |
|
... | ... | |
627 | 650 |
mac - the new MAC address of the instance |
628 | 651 |
|
629 | 652 |
""" |
630 |
if not (opts.mem or opts.vcpus or opts.ip or opts.bridge or opts.mac): |
|
653 |
if not (opts.mem or opts.vcpus or opts.ip or opts.bridge or opts.mac or |
|
654 |
opts.kernel_path or opts.initrd_path): |
|
631 | 655 |
logger.ToStdout("Please give at least one of the parameters.") |
632 | 656 |
return 1 |
633 | 657 |
|
658 |
kernel_path = _TransformPath(opts.kernel_path) |
|
659 |
initrd_path = _TransformPath(opts.initrd_path) |
|
660 |
|
|
634 | 661 |
op = opcodes.OpSetInstanceParms(instance_name=args[0], mem=opts.mem, |
635 | 662 |
vcpus=opts.vcpus, ip=opts.ip, |
636 |
bridge=opts.bridge, mac=opts.mac) |
|
663 |
bridge=opts.bridge, mac=opts.mac, |
|
664 |
kernel_path=opts.kernel_path, |
|
665 |
initrd_path=opts.initrd_path) |
|
637 | 666 |
result = SubmitOpCode(op) |
638 | 667 |
|
639 | 668 |
if result: |
... | ... | |
815 | 844 |
make_option("--mac", dest="mac", |
816 | 845 |
help="MAC address", default=None, |
817 | 846 |
type="string", metavar="<MACADDRESS>"), |
847 |
make_option("--kernel", dest="kernel_path", |
|
848 |
help="Path to the instances' kernel (or" |
|
849 |
" 'default')", default=None, |
|
850 |
type="string", metavar="<FILENAME>"), |
|
851 |
make_option("--initrd", dest="initrd_path", |
|
852 |
help="Path to the instances' initrd (or 'none', or" |
|
853 |
" 'default')", default=None, |
|
854 |
type="string", metavar="<FILENAME>"), |
|
818 | 855 |
], |
819 | 856 |
"<instance>", "Alters the parameters of an instance"), |
820 | 857 |
'shutdown': (ShutdownInstance, ARGS_ANY, |
Also available in: Unified diff