Revision 973d7867 lib/cmdlib.py

b/lib/cmdlib.py
4101 4101
    self.ip = getattr(self.op, "ip", None)
4102 4102
    self.mac = getattr(self.op, "mac", None)
4103 4103
    self.bridge = getattr(self.op, "bridge", None)
4104
    if [self.mem, self.vcpus, self.ip, self.bridge, self.mac].count(None) == 5:
4104
    self.kernel_path = getattr(self.op, "kernel_path", None)
4105
    self.initrd_path = getattr(self.op, "initrd_path", None)
4106
    all_parms = [self.mem, self.vcpus, self.ip, self.bridge, self.mac,
4107
                 self.kernel_path, self.initrd_path]
4108
    if all_parms.count(None) == len(all_parms):
4105 4109
      raise errors.OpPrereqError("No changes submitted")
4106 4110
    if self.mem is not None:
4107 4111
      try:
......
4130 4134
      if not utils.IsValidMac(self.mac):
4131 4135
        raise errors.OpPrereqError('Invalid MAC address %s' % self.mac)
4132 4136

  
4137
    if self.kernel_path is not None:
4138
      self.do_kernel_path = True
4139
      if self.kernel_path == constants.VALUE_NONE:
4140
        raise errors.OpPrereqError("Can't set instance to no kernel")
4141

  
4142
      if self.kernel_path != constants.VALUE_DEFAULT:
4143
        if not os.path.isabs(self.kernel_path):
4144
          raise errors.OpPrereError("The kernel path must be an absolute"
4145
                                    " filename")
4146

  
4147
    if self.initrd_path is not None:
4148
      self.do_initrd_path = True
4149
      if self.initrd_path not in (constants.VALUE_NONE,
4150
                                  constants.VALUE_DEFAULT):
4151
        if not os.path.isabs(self.kernel_path):
4152
          raise errors.OpPrereError("The initrd path must be an absolute"
4153
                                    " filename")
4154

  
4133 4155
    instance = self.cfg.GetInstanceInfo(
4134 4156
      self.cfg.ExpandInstanceName(self.op.instance_name))
4135 4157
    if instance is None:
......
4161 4183
    if self.mac:
4162 4184
      instance.nics[0].mac = self.mac
4163 4185
      result.append(("mac", self.mac))
4186
    if self.do_kernel_path:
4187
      instance.kernel_path = self.kernel_path
4188
      result.append(("kernel_path", self.kernel_path))
4189
    if self.do_initrd_path:
4190
      instance.initrd_path = self.initrd_path
4191
      result.append(("initrd_path", self.initrd_path))
4164 4192

  
4165 4193
    self.cfg.AddInstance(instance)
4166 4194

  

Also available in: Unified diff