- def GetSharedFileStorageDir(self):
- return self._config_data["cluster"]["shared_file_storage_dir"]
-
- def GetNodeList(self):
- return self._config_data["nodes"].keys()
-
- def GetConfigSerialNo(self):
- return self._config_data["serial_no"]
-
- def GetClusterSerialNo(self):
- return self._config_data["cluster"]["serial_no"]
-
- def GetDefaultNicParams(self):
- return self._config_data["cluster"]["nicparams"][constants.PP_DEFAULT]
-
- def GetDefaultNicLink(self):
- return self.GetDefaultNicParams()[constants.NIC_LINK]
-
- def GetNodeStatusFlags(self, node):
- """Get a node's status flags
-
- @type node: string
- @param node: node name
- @rtype: (bool, bool, bool)
- @return: (master_candidate, drained, offline) (or None if no such node)
-
- """
- if node not in self._config_data["nodes"]:
- return None
-
- master_candidate = self._config_data["nodes"][node]["master_candidate"]
- drained = self._config_data["nodes"][node]["drained"]
- offline = self._config_data["nodes"][node]["offline"]
- return master_candidate, drained, offline
-
- def GetInstanceByLinkIp(self, ip, link):
- """Get instance name from its link and ip address.
-
- @type ip: string
- @param ip: ip address
- @type link: string
- @param link: nic link
- @rtype: string
- @return: instance name
-
- """
- if not link:
- link = self.GetDefaultNicLink()
- if not link in self._ip_to_inst_by_link:
- return None
- if not ip in self._ip_to_inst_by_link[link]:
- return None
- return self._ip_to_inst_by_link[link][ip]
-
- def GetNodePrimaryIp(self, node):
- """Get a node's primary ip
-
- @type node: string
- @param node: node name
- @rtype: string, or None
- @return: node's primary ip, or None if no such node
-
- """
- if node not in self._config_data["nodes"]:
- return None
- return self._config_data["nodes"][node]["primary_ip"]
-
- def GetInstancePrimaryNode(self, instance):
- """Get an instance's primary node
-
- @type instance: string
- @param instance: instance name
- @rtype: string, or None
- @return: primary node, or None if no such instance
-
- """
- if instance not in self._config_data["instances"]:
- return None
- return self._config_data["instances"][instance]["primary_node"]