Commit d676dbea authored by Sebastian Gebhard's avatar Sebastian Gebhard Committed by Klaus Aehlig

Extend gnt-instance show to show vlan parameter

Extensions for "gnt-instance show" to output the vlan parameter which
was introduced by my recent patch series.
This is done by extending the nic object that is used to output the
info. Every other occurrence of this object is adopted as well.

This should fix the errors during make commit-check and lint errors
Signed-off-by: default avatarSebastian Gebhard <sege@fs.ei.tum.de>
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 1cc324f0
......@@ -1065,7 +1065,7 @@ def _FormatBlockDevInfo(idx, top_level, dev, roman):
def _FormatInstanceNicInfo(idx, nic):
"""Helper function for L{_FormatInstanceInfo()}"""
(name, uuid, ip, mac, mode, link, _, netinfo) = nic
(name, uuid, ip, mac, mode, link, vlan, _, netinfo) = nic
network_name = None
if netinfo:
network_name = netinfo["name"]
......@@ -1075,6 +1075,7 @@ def _FormatInstanceNicInfo(idx, nic):
("IP", str(ip)),
("mode", str(mode)),
("link", str(link)),
("vlan", str(vlan)),
("network", str(network_name)),
("UUID", str(uuid)),
("name", str(name)),
......
......@@ -59,8 +59,8 @@ def BuildInstanceHookEnv(name, primary_node_name, secondary_node_names, os_type,
@type vcpus: string
@param vcpus: the count of VCPUs the instance has
@type nics: list
@param nics: list of tuples (name, uuid, ip, mac, mode, link, net, netinfo)
representing the NICs the instance has
@param nics: list of tuples (name, uuid, ip, mac, mode, link, vlan, net,
netinfo) representing the NICs the instance has
@type disk_template: string
@param disk_template: the disk template of the instance
@type disks: list
......@@ -94,7 +94,8 @@ def BuildInstanceHookEnv(name, primary_node_name, secondary_node_names, os_type,
}
if nics:
nic_count = len(nics)
for idx, (name, uuid, ip, mac, mode, link, net, netinfo) in enumerate(nics):
for idx, (name, uuid, ip, mac, mode, link, vlan, net, netinfo) \
in enumerate(nics):
if ip is None:
ip = ""
if name:
......@@ -104,6 +105,7 @@ def BuildInstanceHookEnv(name, primary_node_name, secondary_node_names, os_type,
env["INSTANCE_NIC%d_MAC" % idx] = mac
env["INSTANCE_NIC%d_MODE" % idx] = mode
env["INSTANCE_NIC%d_LINK" % idx] = link
env["INSTANCE_NIC%d_VLAN" % idx] = vlan
if netinfo:
nobj = objects.Network.FromDict(netinfo)
env.update(nobj.HooksDict("INSTANCE_NIC%d_" % idx))
......@@ -112,7 +114,8 @@ def BuildInstanceHookEnv(name, primary_node_name, secondary_node_names, os_type,
# network, but the relevant network entry was not in the config. This
# should be made impossible.
env["INSTANCE_NIC%d_NETWORK_NAME" % idx] = net
if mode == constants.NIC_MODE_BRIDGED:
if mode == constants.NIC_MODE_BRIDGED or \
mode == constants.NIC_MODE_OVS:
env["INSTANCE_NIC%d_BRIDGE" % idx] = link
else:
nic_count = 0
......@@ -317,11 +320,13 @@ def NICToTuple(lu, nic):
filled_params = cluster.SimpleFillNIC(nic.nicparams)
mode = filled_params[constants.NIC_MODE]
link = filled_params[constants.NIC_LINK]
vlan = filled_params[constants.NIC_VLAN]
netinfo = None
if nic.network:
nobj = lu.cfg.GetNetwork(nic.network)
netinfo = objects.Network.ToDict(nobj)
return (nic.name, nic.uuid, nic.ip, nic.mac, mode, link, nic.network, netinfo)
return (nic.name, nic.uuid, nic.ip, nic.mac, mode, link, vlan,
nic.network, netinfo)
def NICListToTuple(lu, nics):
......
......@@ -417,6 +417,7 @@ $(buildObject "INicParams" "inic"
, optionalField $ simpleField C.inicMode [t| NonEmptyString |]
, optionalField $ simpleField C.inicLink [t| NonEmptyString |]
, optionalField $ simpleField C.inicName [t| NonEmptyString |]
, optionalField $ simpleField C.inicVlan [t| NonEmptyString |]
])
-- | Disk modification definition. FIXME: disksize should be VTYPE_UNIT.
......
......@@ -75,6 +75,7 @@ instance Arbitrary OpCodes.DiskIndex where
instance Arbitrary INicParams where
arbitrary = INicParams <$> genMaybe genNameNE <*> genMaybe genName <*>
genMaybe genNameNE <*> genMaybe genNameNE <*> genMaybe genNameNE
<*> genMaybe genNameNE
instance Arbitrary IDiskParams where
arbitrary = IDiskParams <$> arbitrary <*> arbitrary <*>
......
......@@ -503,9 +503,11 @@ class MoveDestExecutor(object):
constants.INIC_MAC: mac,
constants.INIC_MODE: mode,
constants.INIC_LINK: link,
constants.INIC_NAME: vlan,
constants.INIC_NETWORK: network,
constants.INIC_NAME: nic_name
} for nic_name, _, ip, mac, mode, link, network, _ in instance["nics"]]
} for nic_name, _, ip, mac, mode, link, vlan, network, _
in instance["nics"]]
if len(override_nics) > len(nics):
raise Error("Can not create new NICs")
......
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