HTYPE = constants.HTYPE_INSTANCE
_OP_REQP = ["instance_name", "mem_size", "disk_size", "pnode",
"disk_template", "swap_size", "mode", "start", "vcpus",
- "wait_for_sync"]
+ "wait_for_sync", "ip_check"]
def BuildHooksEnv(self):
"""Build hooks env.
inst_ip = ip
self.inst_ip = inst_ip
- command = ["fping", "-q", hostname1.ip]
- result = utils.RunCmd(command)
- if not result.failed:
- raise errors.OpPrereqError("IP %s of instance %s already in use" %
- (hostname1.ip, instance_name))
+ if self.op.start and not self.op.ip_check:
+ raise errors.OpPrereqError("Cannot ignore IP address conflicts when"
+ " adding an instance in start mode")
+
+ if self.op.ip_check:
+ command = ["fping", "-q", hostname1.ip]
+ result = utils.RunCmd(command)
+ if not result.failed:
+ raise errors.OpPrereqError("IP address %s of instance %s already"
+ " in use" % (hostname1.ip, instance_name))
# bridge verification
bridge = getattr(self.op, "bridge", None)
__slots__ = ["instance_name", "mem_size", "disk_size", "os_type", "pnode",
"disk_template", "snode", "swap_size", "mode",
"vcpus", "ip", "bridge", "src_node", "src_path", "start",
- "wait_for_sync"]
+ "wait_for_sync", "ip_check"]
class OpReinstallInstance(OpCode):
metavar="<node>"),
make_option("--src-dir", dest="src_dir", help="Source directory",
metavar="<dir>"),
+ make_option("--no-ip-check", dest="ip_check", default=True,
+ action="store_false", help="Don't check that the instance's IP"
+ " is alive"),
]
commands = {
mode=constants.INSTANCE_CREATE,
os_type=opts.os, pnode=opts.node,
snode=opts.snode, vcpus=opts.vcpus,
- ip=opts.ip, bridge=opts.bridge, start=True,
+ ip=opts.ip, bridge=opts.bridge,
+ start=opts.start, ip_check=opts.ip_check,
wait_for_sync=opts.wait_for_sync)
SubmitOpCode(op)
return 0
metavar="<node>"),
make_option("-b", "--bridge", dest="bridge",
help="Bridge to connect this instance to",
- default=None, metavar="<bridge>")
+ default=None, metavar="<bridge>"),
+ make_option("--no-start", dest="start", default=True,
+ action="store_false", help="Don't start the instance after"
+ " creation"),
+ make_option("--no-ip-check", dest="ip_check", default=True,
+ action="store_false", help="Don't check that the instance's IP"
+ " is alive (only valid with --no-start)"),
]
commands = {