Skip to content

Commit

Permalink
RD-6586 Use rest_port from ctx (#1237)
Browse files Browse the repository at this point in the history
So far we've been always only using rest port from the envvars, but
let's make it more similar to rest_host.
  • Loading branch information
tehasdf authored Jan 24, 2023
1 parent 2b77f19 commit c058f39
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
5 changes: 5 additions & 0 deletions cloudify/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,11 @@ def rest_host(self):
"""REST host"""
return self._rest_host

@property
def rest_port(self):
"""REST port"""
return self._context.get('rest_port')

@property
def rest_token(self):
"""REST service token"""
Expand Down
19 changes: 12 additions & 7 deletions cloudify/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,18 @@ def get_manager_rest_service_host():
return host_ip or os.environ[constants.REST_HOST_KEY].split(',')


def get_manager_rest_service_port():
"""
Returns the port the manager REST service is running on.
"""
rest_port = None
try:
rest_port = _get_current_context().rest_port
except RuntimeError:
pass
return rest_port or int(os.environ[constants.REST_PORT_KEY])


def get_broker_ssl_cert_path():
"""
Returns location of the broker certificate on the agent
Expand All @@ -277,13 +289,6 @@ def get_broker_ssl_cert_path():
get_manager_ip = get_manager_rest_service_host


def get_manager_rest_service_port():
"""
Returns the port the manager REST service is running on.
"""
return int(os.environ[constants.REST_PORT_KEY])


def get_local_rest_certificate():
"""
Returns the path to the local copy of the server's public certificate
Expand Down
22 changes: 15 additions & 7 deletions cloudify/workflows/workflow_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,10 @@ def rest_token(self):
def rest_host(self):
return self._context.get('rest_host')

@property
def rest_port(self):
return self._context.get('rest_port')

@property
def execution_token(self):
"""The token of the current execution"""
Expand Down Expand Up @@ -1554,13 +1558,17 @@ def wait_for_result(self, *args, **kwargs):

@property
def operation_cloudify_context(self):
return {'local': False,
'bypass_maintenance': utils.get_is_bypass_maintenance(),
'rest_token': utils.get_rest_token(),
'workflow_parameters': utils.get_workflow_parameters(),
'execution_token': utils.get_execution_token(),
'execution_creator_username':
utils.get_execution_creator_username()}
return {
'local': False,
'rest_token': self.workflow_ctx.rest_token,
'rest_host': self.workflow_ctx.rest_host,
'rest_port': self.workflow_ctx.rest_port,
'bypass_maintenance': utils.get_is_bypass_maintenance(),
'workflow_parameters': utils.get_workflow_parameters(),
'execution_token': utils.get_execution_token(),
'execution_creator_username':
utils.get_execution_creator_username()
}

def download_deployment_resource(self,
blueprint_id,
Expand Down

0 comments on commit c058f39

Please sign in to comment.