Revision b2fddf63 lib/config.py
b/lib/config.py | ||
---|---|---|
169 | 169 |
disk.physical_id = disk.logical_id |
170 | 170 |
return |
171 | 171 |
|
172 |
def AddTcpIpPort(self, port): |
|
172 |
def AddTcpUdpPort(self, port): |
|
173 |
"""Adds a new port to the available port pool. |
|
174 |
|
|
175 |
""" |
|
173 | 176 |
if not isinstance(port, int): |
174 |
raise errors.ProgrammerError("Invalid type passed for port") |
|
177 |
raise errors.ProgrammerError, ("Invalid type passed for port")
|
|
175 | 178 |
|
176 | 179 |
self._OpenConfig() |
177 |
self._config_data.tcpudp_port_pool.add(port) |
|
180 |
self._config_data.cluster.tcpudp_port_pool.add(port)
|
|
178 | 181 |
self._WriteConfig() |
179 | 182 |
|
180 |
def GetPortList(): |
|
183 |
def GetPortList(self):
|
|
181 | 184 |
"""Returns a copy of the current port list. |
182 | 185 |
|
183 | 186 |
""" |
184 | 187 |
self._OpenConfig() |
185 | 188 |
self._ReleaseLock() |
186 |
return self._config_data.tcpudp_port_pool.copy() |
|
189 |
return self._config_data.cluster.tcpudp_port_pool.copy()
|
|
187 | 190 |
|
188 | 191 |
def AllocatePort(self): |
189 | 192 |
"""Allocate a port. |
190 | 193 |
|
191 |
The port will be recorded in the cluster config. |
|
194 |
The port will be taken from the available port pool or from the |
|
195 |
default port range (and in this case we increase |
|
196 |
highest_used_port). |
|
192 | 197 |
|
193 | 198 |
""" |
194 | 199 |
self._OpenConfig() |
195 | 200 |
|
196 | 201 |
# If there are TCP/IP ports configured, we use them first. |
197 |
if self._config_data.tcpudp_port_pool: |
|
198 |
port = self._config_data.tcpudp_port_pool.pop() |
|
202 |
if self._config_data.cluster.tcpudp_port_pool:
|
|
203 |
port = self._config_data.cluster.tcpudp_port_pool.pop()
|
|
199 | 204 |
else: |
200 | 205 |
port = self._config_data.cluster.highest_used_port + 1 |
201 | 206 |
if port >= constants.LAST_DRBD_PORT: |
... | ... | |
500 | 505 |
highest_used_port=hu_port, |
501 | 506 |
mac_prefix=mac_prefix, |
502 | 507 |
volume_group_name=vg_name, |
503 |
default_bridge=def_bridge) |
|
508 |
default_bridge=def_bridge, |
|
509 |
tcpudp_port_pool=set()) |
|
504 | 510 |
if secondary_ip is None: |
505 | 511 |
secondary_ip = primary_ip |
506 | 512 |
nodeconfig = objects.Node(name=node, primary_ip=primary_ip, |
... | ... | |
508 | 514 |
|
509 | 515 |
self._config_data = objects.ConfigData(nodes={node: nodeconfig}, |
510 | 516 |
instances={}, |
511 |
cluster=globalconfig, |
|
512 |
tcpudp_port_pool=set()) |
|
517 |
cluster=globalconfig) |
|
513 | 518 |
self._WriteConfig() |
514 | 519 |
|
515 | 520 |
def GetClusterName(self): |
Also available in: Unified diff