387 |
387 |
return utils.PathJoin(self._cfgdir, instance_name)
|
388 |
388 |
|
389 |
389 |
@classmethod
|
390 |
|
def _WriteNICInfoFile(cls, instance_name, idx, nic):
|
|
390 |
def _WriteNICInfoFile(cls, instance, idx, nic):
|
391 |
391 |
"""Write the Xen config file for the instance.
|
392 |
392 |
|
393 |
393 |
This version of the function just writes the config file from static data.
|
394 |
394 |
|
395 |
395 |
"""
|
|
396 |
instance_name = instance.name
|
396 |
397 |
dirs = [(dname, constants.RUN_DIRS_MODE)
|
397 |
398 |
for dname in cls._DIRS + [cls._InstanceNICDir(instance_name)]]
|
398 |
399 |
utils.EnsureDirs(dirs)
|
... | ... | |
400 |
401 |
cfg_file = cls._InstanceNICFile(instance_name, idx)
|
401 |
402 |
data = StringIO()
|
402 |
403 |
|
|
404 |
data.write("TAGS=%s\n" % "\ ".join(instance.GetTags()))
|
403 |
405 |
if nic.netinfo:
|
404 |
406 |
netinfo = objects.Network.FromDict(nic.netinfo)
|
405 |
407 |
data.write("NETWORK_NAME=%s\n" % netinfo.name)
|
... | ... | |
981 |
983 |
if hvp[constants.HV_VIF_SCRIPT]:
|
982 |
984 |
nic_str += ", script=%s" % hvp[constants.HV_VIF_SCRIPT]
|
983 |
985 |
vif_data.append("'%s'" % nic_str)
|
984 |
|
self._WriteNICInfoFile(instance.name, idx, nic)
|
|
986 |
self._WriteNICInfoFile(instance, idx, nic)
|
985 |
987 |
|
986 |
988 |
disk_data = \
|
987 |
989 |
_GetConfigFileDiskData(block_devices, hvp[constants.HV_BLOCKDEV_PREFIX])
|
... | ... | |
1150 |
1152 |
if hvp[constants.HV_VIF_SCRIPT]:
|
1151 |
1153 |
nic_str += ", script=%s" % hvp[constants.HV_VIF_SCRIPT]
|
1152 |
1154 |
vif_data.append("'%s'" % nic_str)
|
1153 |
|
self._WriteNICInfoFile(instance.name, idx, nic)
|
|
1155 |
self._WriteNICInfoFile(instance, idx, nic)
|
1154 |
1156 |
|
1155 |
1157 |
config.write("vif = [%s]\n" % ",".join(vif_data))
|
1156 |
1158 |
|