Skip to content

Commit

Permalink
Merge branch 'develop' into feature/alex_162339_make_CLP_not_searchable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexazarh committed Jul 23, 2017
2 parents e1165ab + 78832ab commit 86fff40
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def refresh_ip(self, cloudshell_session, ec2_session, deployed_instance_id, priv
public_ip_on_aws = deployed_instance.public_ip_address
private_ip_on_aws = deployed_instance.private_ip_address

if public_ip_on_aws != public_ip_on_resource :
if public_ip_on_aws != public_ip_on_resource:
cloudshell_session.SetAttributeValue(resource_fullname, RefreshIpOperation.public_ip,
public_ip_on_aws if public_ip_on_aws is not None else "")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class AWSModelsParser(object):

@staticmethod
def convert_app_resource_to_deployed_app(resource):
json_str = jsonpickle.decode(resource.app_context.deployed_app_json)
Expand Down Expand Up @@ -51,7 +50,7 @@ def convert_to_deployment_resource_model(deployment_request, resource_context_de
deployment_resource_model.root_volume_name = data["Attributes"]['Root Volume Name']
deployment_resource_model.wait_for_ip = AWSModelsParser.convert_to_bool(data["Attributes"]['Wait for IP'])
deployment_resource_model.wait_for_status_check = AWSModelsParser.convert_to_bool(
data["Attributes"]['Wait for Status Check'])
data["Attributes"]['Wait for Status Check'])
deployment_resource_model.autoload = AWSModelsParser.convert_to_bool(data["Attributes"]['Autoload'])
deployment_resource_model.inbound_ports = data["Attributes"]['Inbound Ports']
deployment_resource_model.outbound_ports = data["Attributes"]['Outbound Ports']
Expand All @@ -60,11 +59,28 @@ def convert_to_deployment_resource_model(deployment_request, resource_context_de
deployment_resource_model.add_public_ip = AWSModelsParser.convert_to_bool(data["Attributes"]['Add Public IP'])
deployment_resource_model.allocate_elastic_ip = \
AWSModelsParser.convert_to_bool(data["Attributes"]['Allocate Elastic IP'])
deployment_resource_model.user = data["LogicalResourceRequestAttributes"]["User"]
deployment_resource_model.user = \
AWSModelsParser.get_attribute_value_by_name_ignoring_namespace(data["LogicalResourceRequestAttributes"],
"User")
deployment_resource_model.app_name = data_holder.AppName

return deployment_resource_model

@staticmethod
def get_attribute_value_by_name_ignoring_namespace(attributes, name):
"""
Finds the attribute value by name ignoring attribute namespaces.
:param dict attributes: Attributes key value dict to search on.
:param str name: Attribute name to search for.
:return: Attribute str value. None if not found.
:rtype: str
"""
for key, val in attributes.iteritems():
last_part = key.split(".")[-1] # get last part of namespace.
if name == last_part:
return val
return None

@staticmethod
def convert_to_bool(string):
"""
Expand All @@ -81,9 +97,9 @@ def convert_to_bool(string):
def get_public_ip_from_connected_resource_details(resource_context):
public_ip_on_resource = ""
public_ip = 'Public IP'
if resource_context.remote_endpoints is not None and public_ip in resource_context.remote_endpoints[
0].attributes:
public_ip_on_resource = resource_context.remote_endpoints[0].attributes[public_ip]
if resource_context.remote_endpoints is not None:
public_ip_on_resource = AWSModelsParser.get_attribute_value_by_name_ignoring_namespace(
resource_context.remote_endpoints[0].attributes, public_ip)
return public_ip_on_resource

@staticmethod
Expand All @@ -97,8 +113,8 @@ def get_private_ip_from_connected_resource_details(resource_context):
def try_get_deployed_connected_resource_instance_id(resource_context):
try:
deployed_instance_id = str(
jsonpickle.decode(resource_context.remote_endpoints[0].app_context.deployed_app_json)['vmdetails'][
'uid'])
jsonpickle.decode(resource_context.remote_endpoints[0].app_context.deployed_app_json)['vmdetails'][
'uid'])
except Exception as e:
raise ValueError('Could not find an ID of the AWS Deployed instance' + e.message)
return deployed_instance_id
Expand All @@ -116,4 +132,4 @@ def convert_to_reservation_model(reservation_context):
:param ReservationContextDetails reservation_context:
:rtype: ReservationModel
"""
return ReservationModel(reservation_context)
return ReservationModel(reservation_context)

0 comments on commit 86fff40

Please sign in to comment.