Commit cc208ed0 authored by Guido Trotter's avatar Guido Trotter

Merge branch 'master' into branch-2.1

* master:
  Fix adjustement of candidates in cluster modify
  Add a new node list field
  Fix HTTP server library handling of credentials
  Fix a typo in backend.InstanceReboot docstring
  Fix handling of 'vcpus' in instance list
  Fix checking for valid OS in instance create
  Show disk size in instance info

Conflicts:
  lib/backend.py
    docstring update, mixed version kept
  lib/cmdlib.py
    OS validity checking, branch-2.1 version kept, since the new rpc
    included all the error checking
parents b2a6ccd4 75e914fb
......@@ -963,9 +963,10 @@ def InstanceReboot(instance, reboot_type):
instance OS, do not recreate the VM
- L{constants.INSTANCE_REBOOT_HARD}: tear down and
restart the VM (at the hypervisor level)
- the other reboot type (L{constants.INSTANCE_REBOOT_HARD})
is not accepted here, since that mode is handled
differently
- the other reboot type (L{constants.INSTANCE_REBOOT_FULL}) is
not accepted here, since that mode is handled differently, in
cmdlib, and translates into full stop and start of the
instance (instead of a call_instance_reboot RPC)
@rtype: None
"""
......
......@@ -701,6 +701,8 @@ def FormatError(err):
" job submissions until old jobs are archived\n")
elif isinstance(err, errors.TypeEnforcementError):
obuf.write("Parameter Error: %s" % msg)
elif isinstance(err, errors.ParameterError):
obuf.write("Failure: unknown/wrong parameter name '%s'" % msg)
elif isinstance(err, errors.GenericError):
obuf.write("Unhandled Ganeti error: %s" % msg)
elif isinstance(err, luxi.NoMasterError):
......
......@@ -1606,14 +1606,11 @@ class LUSetClusterParams(LogicalUnit):
if self.op.candidate_pool_size is not None:
self.cluster.candidate_pool_size = self.op.candidate_pool_size
# we need to update the pool size here, otherwise the save will fail
_AdjustCandidatePool(self)
self.cfg.Update(self.cluster)
# we want to update nodes after the cluster so that if any errors
# happen, we have recorded and saved the cluster info
if self.op.candidate_pool_size is not None:
_AdjustCandidatePool(self)
def _RedistributeAncillaryFiles(lu, additional_nodes=None):
"""Distribute additional files which are part of the cluster configuration.
......@@ -1976,6 +1973,7 @@ class LUQueryNodes(NoHooksLU):
"master",
"offline",
"drained",
"role",
)
def ExpandNames(self):
......@@ -2104,6 +2102,17 @@ class LUQueryNodes(NoHooksLU):
val = node.drained
elif self._FIELDS_DYNAMIC.Matches(field):
val = live_data[node.name].get(field, None)
elif field == "role":
if node.name == master_node:
val = "M"
elif node.master_candidate:
val = "C"
elif node.drained:
val = "D"
elif node.offline:
val = "O"
else:
val = "R"
else:
raise errors.ParameterError(field)
node_output.append(val)
......@@ -3513,6 +3522,8 @@ class LUQueryInstances(NoHooksLU):
val = live_data[instance.name].get("memory", "?")
else:
val = "-"
elif field == "vcpus":
val = i_be[constants.BE_VCPUS]
elif field == "disk_template":
val = instance.disk_template
elif field == "ip":
......@@ -3624,9 +3635,10 @@ class LUQueryInstances(NoHooksLU):
else:
assert False, "Unhandled NIC parameter"
else:
assert False, "Unhandled variable parameter"
assert False, ("Declared but unhandled variable parameter '%s'" %
field)
else:
raise errors.ParameterError(field)
assert False, "Declared but unhandled parameter '%s'" % field
iout.append(val)
output.append(iout)
......@@ -5799,6 +5811,7 @@ class LUQueryInstanceData(NoHooksLU):
"sstatus": dev_sstatus,
"children": dev_children,
"mode": dev.mode,
"size": dev.size,
}
return data
......
......@@ -101,10 +101,14 @@ class HttpServerRequestAuthentication(object):
"""
realm = self.GetAuthRealm(req)
# Authentication required?
if realm is None:
# Authentication not required, and no credentials given?
if realm is None and http.HTTP_AUTHORIZATION not in req.request_headers:
return
if realm is None: # in case we don't require auth but someone
# passed the crendentials anyway
realm = "Unspecified"
# Check "Authorization" header
if self._CheckAuthorization(req):
# User successfully authenticated
......
......@@ -423,6 +423,38 @@
<simpara>whether the node is offline or not</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>role</term>
<listitem>
<para>
A condensed version of the node flags; this field will
output a one-character field, with the following
possible values:
<itemizedlist>
<listitem>
<simpara><emphasis>M</emphasis> for the master
node</simpara>
</listitem>
<listitem>
<simpara><emphasis>C</emphasis> for a master
candidate</simpara>
</listitem>
<listitem>
<simpara><emphasis>R</emphasis> for a regular
node</simpara>
</listitem>
<listitem>
<simpara><emphasis>D</emphasis> for a drained
node</simpara>
</listitem>
<listitem>
<simpara><emphasis>O</emphasis> for an offline
node</simpara>
</listitem>
</itemizedlist>
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
......
......@@ -220,6 +220,7 @@ def ListInstances(opts, args):
"hvparams": "Hypervisor_parameters",
"be/memory": "Configured_memory",
"be/vcpus": "VCPUs",
"vcpus": "VCPUs",
"be/auto_balance": "Auto_balance",
"disk.count": "Disks", "disk.sizes": "Disk_sizes",
"nic.count": "NICs", "nic.ips": "NIC_IPs",
......@@ -1040,7 +1041,11 @@ def _FormatBlockDevInfo(idx, top_level, dev, static):
txt = "disk %d" % idx
else:
txt = "child %d" % idx
d1 = ["- %s: %s" % (txt, dev["dev_type"])]
if isinstance(dev["size"], int):
nice_size = utils.FormatUnit(dev["size"], "h")
else:
nice_size = dev["size"]
d1 = ["- %s: %s, size %s" % (txt, dev["dev_type"], nice_size)]
data = []
if top_level:
data.append(("access mode", dev["mode"]))
......
......@@ -56,6 +56,7 @@ _LIST_HEADERS = {
"master_candidate": "MasterC",
"master": "IsMaster",
"offline": "Offline", "drained": "Drained",
"role": "Role",
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment