Commit cc208ed0 authored by Guido Trotter's avatar Guido Trotter
Browse files

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): ...@@ -963,9 +963,10 @@ def InstanceReboot(instance, reboot_type):
instance OS, do not recreate the VM instance OS, do not recreate the VM
- L{constants.INSTANCE_REBOOT_HARD}: tear down and - L{constants.INSTANCE_REBOOT_HARD}: tear down and
restart the VM (at the hypervisor level) restart the VM (at the hypervisor level)
- the other reboot type (L{constants.INSTANCE_REBOOT_HARD}) - the other reboot type (L{constants.INSTANCE_REBOOT_FULL}) is
is not accepted here, since that mode is handled not accepted here, since that mode is handled differently, in
differently cmdlib, and translates into full stop and start of the
instance (instead of a call_instance_reboot RPC)
@rtype: None @rtype: None
""" """
......
...@@ -701,6 +701,8 @@ def FormatError(err): ...@@ -701,6 +701,8 @@ def FormatError(err):
" job submissions until old jobs are archived\n") " job submissions until old jobs are archived\n")
elif isinstance(err, errors.TypeEnforcementError): elif isinstance(err, errors.TypeEnforcementError):
obuf.write("Parameter Error: %s" % msg) 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): elif isinstance(err, errors.GenericError):
obuf.write("Unhandled Ganeti error: %s" % msg) obuf.write("Unhandled Ganeti error: %s" % msg)
elif isinstance(err, luxi.NoMasterError): elif isinstance(err, luxi.NoMasterError):
......
...@@ -1606,14 +1606,11 @@ class LUSetClusterParams(LogicalUnit): ...@@ -1606,14 +1606,11 @@ class LUSetClusterParams(LogicalUnit):
if self.op.candidate_pool_size is not None: if self.op.candidate_pool_size is not None:
self.cluster.candidate_pool_size = self.op.candidate_pool_size 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) 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): def _RedistributeAncillaryFiles(lu, additional_nodes=None):
"""Distribute additional files which are part of the cluster configuration. """Distribute additional files which are part of the cluster configuration.
...@@ -1976,6 +1973,7 @@ class LUQueryNodes(NoHooksLU): ...@@ -1976,6 +1973,7 @@ class LUQueryNodes(NoHooksLU):
"master", "master",
"offline", "offline",
"drained", "drained",
"role",
) )
def ExpandNames(self): def ExpandNames(self):
...@@ -2104,6 +2102,17 @@ class LUQueryNodes(NoHooksLU): ...@@ -2104,6 +2102,17 @@ class LUQueryNodes(NoHooksLU):
val = node.drained val = node.drained
elif self._FIELDS_DYNAMIC.Matches(field): elif self._FIELDS_DYNAMIC.Matches(field):
val = live_data[node.name].get(field, None) 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: else:
raise errors.ParameterError(field) raise errors.ParameterError(field)
node_output.append(val) node_output.append(val)
...@@ -3513,6 +3522,8 @@ class LUQueryInstances(NoHooksLU): ...@@ -3513,6 +3522,8 @@ class LUQueryInstances(NoHooksLU):
val = live_data[instance.name].get("memory", "?") val = live_data[instance.name].get("memory", "?")
else: else:
val = "-" val = "-"
elif field == "vcpus":
val = i_be[constants.BE_VCPUS]
elif field == "disk_template": elif field == "disk_template":
val = instance.disk_template val = instance.disk_template
elif field == "ip": elif field == "ip":
...@@ -3624,9 +3635,10 @@ class LUQueryInstances(NoHooksLU): ...@@ -3624,9 +3635,10 @@ class LUQueryInstances(NoHooksLU):
else: else:
assert False, "Unhandled NIC parameter" assert False, "Unhandled NIC parameter"
else: else:
assert False, "Unhandled variable parameter" assert False, ("Declared but unhandled variable parameter '%s'" %
field)
else: else:
raise errors.ParameterError(field) assert False, "Declared but unhandled parameter '%s'" % field
iout.append(val) iout.append(val)
output.append(iout) output.append(iout)
...@@ -5799,6 +5811,7 @@ class LUQueryInstanceData(NoHooksLU): ...@@ -5799,6 +5811,7 @@ class LUQueryInstanceData(NoHooksLU):
"sstatus": dev_sstatus, "sstatus": dev_sstatus,
"children": dev_children, "children": dev_children,
"mode": dev.mode, "mode": dev.mode,
"size": dev.size,
} }
return data return data
......
...@@ -101,10 +101,14 @@ class HttpServerRequestAuthentication(object): ...@@ -101,10 +101,14 @@ class HttpServerRequestAuthentication(object):
""" """
realm = self.GetAuthRealm(req) realm = self.GetAuthRealm(req)
# Authentication required? # Authentication not required, and no credentials given?
if realm is None: if realm is None and http.HTTP_AUTHORIZATION not in req.request_headers:
return return
if realm is None: # in case we don't require auth but someone
# passed the crendentials anyway
realm = "Unspecified"
# Check "Authorization" header # Check "Authorization" header
if self._CheckAuthorization(req): if self._CheckAuthorization(req):
# User successfully authenticated # User successfully authenticated
......
...@@ -423,6 +423,38 @@ ...@@ -423,6 +423,38 @@
<simpara>whether the node is offline or not</simpara> <simpara>whether the node is offline or not</simpara>
</listitem> </listitem>
</varlistentry> </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> </variablelist>
</para> </para>
......
...@@ -220,6 +220,7 @@ def ListInstances(opts, args): ...@@ -220,6 +220,7 @@ def ListInstances(opts, args):
"hvparams": "Hypervisor_parameters", "hvparams": "Hypervisor_parameters",
"be/memory": "Configured_memory", "be/memory": "Configured_memory",
"be/vcpus": "VCPUs", "be/vcpus": "VCPUs",
"vcpus": "VCPUs",
"be/auto_balance": "Auto_balance", "be/auto_balance": "Auto_balance",
"disk.count": "Disks", "disk.sizes": "Disk_sizes", "disk.count": "Disks", "disk.sizes": "Disk_sizes",
"nic.count": "NICs", "nic.ips": "NIC_IPs", "nic.count": "NICs", "nic.ips": "NIC_IPs",
...@@ -1040,7 +1041,11 @@ def _FormatBlockDevInfo(idx, top_level, dev, static): ...@@ -1040,7 +1041,11 @@ def _FormatBlockDevInfo(idx, top_level, dev, static):
txt = "disk %d" % idx txt = "disk %d" % idx
else: else:
txt = "child %d" % idx 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 = [] data = []
if top_level: if top_level:
data.append(("access mode", dev["mode"])) data.append(("access mode", dev["mode"]))
......
...@@ -56,6 +56,7 @@ _LIST_HEADERS = { ...@@ -56,6 +56,7 @@ _LIST_HEADERS = {
"master_candidate": "MasterC", "master_candidate": "MasterC",
"master": "IsMaster", "master": "IsMaster",
"offline": "Offline", "drained": "Drained", "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