Skip to content

Commit e2dff2d

Browse files
authored
Merge pull request #182 from fabric-testbed/hasattr
Hasattr and Slice id
2 parents 487b5c2 + 545a5fa commit e2dff2d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

fabric_cf/actor/core/proxies/kafka/translate.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def translate_slice_to_avro(*, slice_obj: ABCSlice) -> SliceAvro:
104104
avro_slice.config_properties = slice_obj.get_config_properties()
105105
avro_slice.set_lease_end(lease_end=slice_obj.get_lease_end())
106106
avro_slice.set_lease_start(lease_start=slice_obj.get_lease_start())
107-
if hasattr(slice_obj, 'project_id') is not None:
107+
if hasattr(slice_obj, 'project_id'):
108108
avro_slice.set_project_id(project_id=slice_obj.get_project_id())
109109

110110
if slice_obj.get_resource_type() is not None:
@@ -124,7 +124,7 @@ def translate_auth_to_avro(*, auth: AuthToken) -> AuthAvro:
124124
result.guid = str(auth.get_guid())
125125
result.oidc_sub_claim = auth.get_oidc_sub_claim()
126126
result.email = auth.get_email()
127-
if hasattr(auth, 'token') is not None:
127+
if hasattr(auth, 'token'):
128128
result.token = auth.get_token()
129129
return result
130130

@@ -137,7 +137,8 @@ def translate_auth_from_avro(*, auth_avro: AuthAvro) -> AuthToken:
137137
result.guid = auth_avro.guid
138138
result.oidc_sub_claim = auth_avro.oidc_sub_claim
139139
result.email = auth_avro.email
140-
result.token = auth_avro.token
140+
if hasattr(auth_avro, 'token'):
141+
result.token = auth_avro.token
141142
return result
142143

143144
@staticmethod

fabric_cf/orchestrator/swagger_server/response/slices_controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def slices_create_post(body, slice_name, ssh_key, lease_end_time): # noqa: E501
5353
response.value = value
5454
success_counter.labels(POST_METHOD, SLICES_CREATE_PATH).inc()
5555
from fabric_cf.orchestrator.core.response_builder import ResponseBuilder
56-
slice_id = value[0][ResponseBuilder.PROP_SLICE_ID]
56+
slice_id = value[ResponseBuilder.RESPONSE_RESERVATIONS][0][ResponseBuilder.PROP_SLICE_ID]
5757
logger.info(f"Slice {slice_id} created for user: {email}")
5858
return response
5959
except OrchestratorException as e:

0 commit comments

Comments
 (0)