Commit d7135309 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis Committed by Jose A. Lopes

Add disks entry to config.data

Add disks entry to config.data.
Signed-off-by: default avatarIlias Tsitsimpis <iliastsi@grnet.gr>
Reviewed-by: default avatarJose A. Lopes <jabolopes@google.com>
parent 50a88ae3
......@@ -868,6 +868,7 @@ def InitConfig(version, cluster_config, master_node_config,
nodes=nodes,
instances={},
networks={},
disks={},
serial_no=1,
ctime=now, mtime=now)
utils.WriteFile(cfg_file,
......
......@@ -405,19 +405,20 @@ class ConfigData(ConfigObject):
"nodegroups",
"instances",
"networks",
"disks",
"serial_no",
] + _TIMESTAMPS
def ToDict(self, _with_private=False):
"""Custom function for top-level config data.
This just replaces the list of instances, nodes and the cluster
with standard python types.
This just replaces the list of nodes, instances, nodegroups,
networks, disks and the cluster with standard python types.
"""
mydict = super(ConfigData, self).ToDict(_with_private=_with_private)
mydict["cluster"] = mydict["cluster"].ToDict()
for key in "nodes", "instances", "nodegroups", "networks":
for key in "nodes", "instances", "nodegroups", "networks", "disks":
mydict[key] = outils.ContainerToDicts(mydict[key])
return mydict
......@@ -435,6 +436,7 @@ class ConfigData(ConfigObject):
obj.nodegroups = \
outils.ContainerFromDicts(obj.nodegroups, dict, NodeGroup)
obj.networks = outils.ContainerFromDicts(obj.networks, dict, Network)
obj.disks = outils.ContainerFromDicts(obj.disks, dict, Disk)
return obj
def HasAnyDiskOfType(self, dev_type):
......@@ -475,6 +477,8 @@ class ConfigData(ConfigObject):
self.networks = {}
for network in self.networks.values():
network.UpgradeConfig()
for disk in self.disks.values():
disk.UpgradeConfig()
def _UpgradeEnabledDiskTemplates(self):
"""Upgrade the cluster's enabled disk templates by inspecting the currently
......
......@@ -758,6 +758,7 @@ $(buildObject "ConfigData" "config" $
, simpleField "nodegroups" [t| Container NodeGroup |]
, simpleField "instances" [t| Container Instance |]
, simpleField "networks" [t| Container Network |]
, simpleField "disks" [t| Container Disk |]
]
++ timeStampFields
++ serialFields)
......
......@@ -296,6 +296,7 @@ genEmptyCluster ncount = do
else GenericContainer nodemap
continsts = GenericContainer Map.empty
networks = GenericContainer Map.empty
disks = GenericContainer Map.empty
let contgroups = GenericContainer $ Map.singleton guuid grp
serial <- arbitrary
-- timestamp fields
......@@ -303,7 +304,7 @@ genEmptyCluster ncount = do
mtime <- arbitrary
cluster <- resize 8 arbitrary
let c = ConfigData version cluster contnodes contgroups continsts networks
ctime mtime serial
disks ctime mtime serial
return c
-- | FIXME: make an even simpler base version of creating a cluster.
......
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