Skip to content

Commit c058f39

Browse files
authored
RD-6586 Use rest_port from ctx (#1237)
So far we've been always only using rest port from the envvars, but let's make it more similar to rest_host.
1 parent 2b77f19 commit c058f39

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

cloudify/context.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,11 @@ def rest_host(self):
863863
"""REST host"""
864864
return self._rest_host
865865

866+
@property
867+
def rest_port(self):
868+
"""REST port"""
869+
return self._context.get('rest_port')
870+
866871
@property
867872
def rest_token(self):
868873
"""REST service token"""

cloudify/utils.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,18 @@ def get_manager_rest_service_host():
266266
return host_ip or os.environ[constants.REST_HOST_KEY].split(',')
267267

268268

269+
def get_manager_rest_service_port():
270+
"""
271+
Returns the port the manager REST service is running on.
272+
"""
273+
rest_port = None
274+
try:
275+
rest_port = _get_current_context().rest_port
276+
except RuntimeError:
277+
pass
278+
return rest_port or int(os.environ[constants.REST_PORT_KEY])
279+
280+
269281
def get_broker_ssl_cert_path():
270282
"""
271283
Returns location of the broker certificate on the agent
@@ -277,13 +289,6 @@ def get_broker_ssl_cert_path():
277289
get_manager_ip = get_manager_rest_service_host
278290

279291

280-
def get_manager_rest_service_port():
281-
"""
282-
Returns the port the manager REST service is running on.
283-
"""
284-
return int(os.environ[constants.REST_PORT_KEY])
285-
286-
287292
def get_local_rest_certificate():
288293
"""
289294
Returns the path to the local copy of the server's public certificate

cloudify/workflows/workflow_context.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,10 @@ def rest_token(self):
594594
def rest_host(self):
595595
return self._context.get('rest_host')
596596

597+
@property
598+
def rest_port(self):
599+
return self._context.get('rest_port')
600+
597601
@property
598602
def execution_token(self):
599603
"""The token of the current execution"""
@@ -1554,13 +1558,17 @@ def wait_for_result(self, *args, **kwargs):
15541558

15551559
@property
15561560
def operation_cloudify_context(self):
1557-
return {'local': False,
1558-
'bypass_maintenance': utils.get_is_bypass_maintenance(),
1559-
'rest_token': utils.get_rest_token(),
1560-
'workflow_parameters': utils.get_workflow_parameters(),
1561-
'execution_token': utils.get_execution_token(),
1562-
'execution_creator_username':
1563-
utils.get_execution_creator_username()}
1561+
return {
1562+
'local': False,
1563+
'rest_token': self.workflow_ctx.rest_token,
1564+
'rest_host': self.workflow_ctx.rest_host,
1565+
'rest_port': self.workflow_ctx.rest_port,
1566+
'bypass_maintenance': utils.get_is_bypass_maintenance(),
1567+
'workflow_parameters': utils.get_workflow_parameters(),
1568+
'execution_token': utils.get_execution_token(),
1569+
'execution_creator_username':
1570+
utils.get_execution_creator_username()
1571+
}
15641572

15651573
def download_deployment_resource(self,
15661574
blueprint_id,

0 commit comments

Comments
 (0)