+ 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"]
+
+ def GetNodesPrimaryIps(self):
+ return self._nodes_primary_ips
+
+ def GetMasterCandidatesPrimaryIps(self):
+ return self._mc_primary_ips
+
+ def GetInstancesIps(self, link):
+ """Get list of nic ips connected to a certain link.
+
+ @type link: string
+ @param link: nic link
+ @rtype: list
+ @return: list of ips connected to that link
+
+ """
+ if not link:
+ link = self.GetDefaultNicLink()
+
+ if link in self._inst_ips_by_link:
+ return self._inst_ips_by_link[link]
+ else:
+ return []
+