Revision 23824641
b/lib/confd/querylib.py | ||
---|---|---|
212 | 212 |
class InstancesIpsQuery(ConfdQuery): |
213 | 213 |
"""A query for instances IPs. |
214 | 214 |
|
215 |
It returns the list of instances IPs. |
|
215 |
It returns the list of IPs of NICs connected to the requested link or all the |
|
216 |
instances IPs if no link is submitted. |
|
216 | 217 |
|
217 | 218 |
""" |
218 | 219 |
def Exec(self, query): |
219 | 220 |
"""InstancesIpsQuery main execution. |
220 | 221 |
|
221 | 222 |
""" |
222 |
if query is None: |
|
223 |
status = constants.CONFD_REPL_STATUS_OK |
|
224 |
answer = self.reader.GetInstancesIps() |
|
225 |
else: |
|
226 |
status = constants.CONFD_REPL_STATUS_ERROR |
|
227 |
answer = "non-empty instances IPs query" |
|
223 |
link = query |
|
224 |
status = constants.CONFD_REPL_STATUS_OK |
|
225 |
answer = self.reader.GetInstancesIps(link) |
|
228 | 226 |
|
229 | 227 |
return status, answer |
230 | 228 |
|
b/lib/ssconf.py | ||
---|---|---|
34 | 34 |
from ganeti import constants |
35 | 35 |
from ganeti import utils |
36 | 36 |
from ganeti import serializer |
37 |
from ganeti import objects |
|
37 | 38 |
|
38 | 39 |
|
39 | 40 |
SSCONF_LOCK_TIMEOUT = 10 |
... | ... | |
101 | 102 |
|
102 | 103 |
self._ip_to_instance = {} |
103 | 104 |
self._instances_ips = [] |
105 |
self._inst_ips_by_link = {} |
|
106 |
c_nparams = self._config_data['cluster']['nicparams'][constants.PP_DEFAULT] |
|
104 | 107 |
for iname in self._config_data['instances']: |
105 | 108 |
instance = self._config_data['instances'][iname] |
106 | 109 |
for nic in instance['nics']: |
107 | 110 |
if 'ip' in nic and nic['ip']: |
108 | 111 |
self._instances_ips.append(nic['ip']) |
109 | 112 |
self._ip_to_instance[nic['ip']] = iname |
113 |
params = objects.FillDict(c_nparams, nic['nicparams']) |
|
114 |
if not params['link'] in self._inst_ips_by_link: |
|
115 |
self._inst_ips_by_link[params['link']] = [] |
|
116 |
self._inst_ips_by_link[params['link']].append(nic['ip']) |
|
110 | 117 |
|
111 | 118 |
self._nodes_primary_ips = [] |
112 | 119 |
self._mc_primary_ips = [] |
... | ... | |
203 | 210 |
def GetMasterCandidatesPrimaryIps(self): |
204 | 211 |
return self._mc_primary_ips |
205 | 212 |
|
206 |
def GetInstancesIps(self): |
|
207 |
return self._instances_ips |
|
213 |
def GetInstancesIps(self, link): |
|
214 |
if link is None: |
|
215 |
return self._instances_ips |
|
216 |
if link in self._inst_ips_by_link: |
|
217 |
return self._inst_ips_by_link[link] |
|
218 |
else: |
|
219 |
return [] |
|
208 | 220 |
|
209 | 221 |
|
210 | 222 |
class SimpleStore(object): |
Also available in: Unified diff