Skip to content

Commit

Permalink
implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
erolue committed Aug 21, 2017
1 parent c67e521 commit bdde092
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions OPSI/Backend/HostControl.py
Expand Up @@ -57,7 +57,7 @@


class RpcThread(KillableThread):
def __init__(self, hostControlBackend, hostId, address, username, password, method, params=[]):
def __init__(self, hostControlBackend, hostId, address, username, password, method, params=[], hostPort=0):
KillableThread.__init__(self)
self.hostControlBackend = hostControlBackend
self.hostId = forceHostId(hostId)
Expand All @@ -70,6 +70,10 @@ def __init__(self, hostControlBackend, hostId, address, username, password, meth
self.result = None
self.started = 0
self.ended = 0
if hostPort:
self.hostPort = forceInt(hostPort)
else:
self.hostPort = self.hostControlBackend._opsiclientdPort

def run(self):
self.started = time.time()
Expand All @@ -88,7 +92,7 @@ def run(self):

connection = HTTPSConnection(
host=self.address,
port=self.hostControlBackend._opsiclientdPort,
port=self.hostPort,
timeout=timeout
)
with closingConnection(connection) as connection:
Expand Down Expand Up @@ -223,11 +227,21 @@ def _opsiclientdRpc(self, hostIds, method, params=[], timeout=None):
rpcts = []
for host in self._context.host_getObjects(id=hostIds): # pylint: disable=maybe-no-member
try:
try:
port = None
configState = self._context.configState_getObjects(configId="opsiclientd.control_server.port", objectId=host.id)
if configState:
logger.notice("Custom Port for opsiclientd found %s" % type(int(configState[0].values[0])))
port = int(configState[0].values[0])
except Exception as e:
logger.critical("Exception: %s" % e)
pass
address = self._getHostAddress(host)
rpcts.append(
RpcThread(
hostControlBackend=self,
hostId=host.id,
hostPort=port,
address=address,
username=u'',
password=host.opsiHostKey,
Expand Down

0 comments on commit bdde092

Please sign in to comment.