def _CreateInstanceByDiskTemplateRaw(nodes_spec, disk_template, fail=False):
  """Creates an instance with the given disk template on the given nodes(s).
     Note that this function does not check if enough nodes are given for
     the respective disk template.

  @type nodes_spec: string
  @param nodes_spec: string specification of one node (by node name) or several
                     nodes according to the requirements of the disk template
  @type disk_template: string
  @param disk_template: the disk template to be used by the instance
  @return: the created instance

  """
  instance = qa_config.AcquireInstance()
  try:
    cmd = (["gnt-instance", "add",
            "--os-type=%s" % qa_config.get("os"),
            "--disk-template=%s" % disk_template,
            "--node=%s" % nodes_spec] +
           GetGenericAddParameters(instance, disk_template))
    cmd.append(instance.name)

    AssertCommand(cmd, fail=fail)

    if not fail:
      CheckSsconfInstanceList(instance.name)
      instance.SetDiskTemplate(disk_template)

      return instance
  except:
    instance.Release()
    raise

  # Handle the case where creation is expected to fail
  assert fail
  instance.Release()
  return None
dataset/ETHPy150Open ganeti/ganeti/qa/qa_instance_utils.py/_CreateInstanceByDiskTemplateRaw/original