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

Rename _PreBuildNICHooksList to _NICListToTuple



We're going to use this helper function for more than just hooks, so
we'll give it a more generic name.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 2b1ac224
...@@ -539,10 +539,11 @@ def _BuildInstanceHookEnv(name, primary_node, secondary_nodes, os_type, status, ...@@ -539,10 +539,11 @@ def _BuildInstanceHookEnv(name, primary_node, secondary_nodes, os_type, status,
return env return env
def _PreBuildNICHooksList(lu, nics): def _NICListToTuple(lu, nics):
"""Build a list of nic information tuples. """Build a list of nic information tuples.
This list is suitable to be passed to _BuildInstanceHookEnv. This list is suitable to be passed to _BuildInstanceHookEnv or as a return
value in LUQueryInstanceData.
@type lu: L{LogicalUnit} @type lu: L{LogicalUnit}
@param lu: the logical unit on whose behalf we execute @param lu: the logical unit on whose behalf we execute
...@@ -587,7 +588,7 @@ def _BuildInstanceHookEnvByObject(lu, instance, override=None): ...@@ -587,7 +588,7 @@ def _BuildInstanceHookEnvByObject(lu, instance, override=None):
'status': instance.admin_up, 'status': instance.admin_up,
'memory': bep[constants.BE_MEMORY], 'memory': bep[constants.BE_MEMORY],
'vcpus': bep[constants.BE_VCPUS], 'vcpus': bep[constants.BE_VCPUS],
'nics': _PreBuildNICHooksList(lu, instance.nics), 'nics': _NICListToTuple(lu, instance.nics),
'disk_template': instance.disk_template, 'disk_template': instance.disk_template,
'disks': [(disk.size, disk.mode) for disk in instance.disks], 'disks': [(disk.size, disk.mode) for disk in instance.disks],
'bep': bep, 'bep': bep,
...@@ -4646,7 +4647,7 @@ class LUCreateInstance(LogicalUnit): ...@@ -4646,7 +4647,7 @@ class LUCreateInstance(LogicalUnit):
os_type=self.op.os_type, os_type=self.op.os_type,
memory=self.be_full[constants.BE_MEMORY], memory=self.be_full[constants.BE_MEMORY],
vcpus=self.be_full[constants.BE_VCPUS], vcpus=self.be_full[constants.BE_VCPUS],
nics=_PreBuildNICHooksList(self, self.nics), nics=_NICListToTuple(self, self.nics),
disk_template=self.op.disk_template, disk_template=self.op.disk_template,
disks=[(d["size"], d["mode"]) for d in self.disks], disks=[(d["size"], d["mode"]) for d in self.disks],
bep=self.be_full, bep=self.be_full,
......
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