Skip to content

Commit

Permalink
remove is ci flag and print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
alfred2g committed Dec 27, 2023
1 parent 3241807 commit c193269
Showing 1 changed file with 0 additions and 40 deletions.
40 changes: 0 additions & 40 deletions servicetests/tests/FleetProvisioning/fleet_provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def on_publish_register_thing(future):
# type: (Future) -> None
try:
future.result() # raises exception if publish failed
print("Published RegisterThing request..")

except Exception as e:
print("Failed to publish RegisterThing request.")
Expand All @@ -93,7 +92,6 @@ def on_publish_create_keys_and_certificate(future):
# type: (Future) -> None
try:
future.result() # raises exception if publish failed
print("Published CreateKeysAndCertificate request..")

except Exception as e:
print("Failed to publish CreateKeysAndCertificate request.")
Expand All @@ -104,7 +102,6 @@ def on_publish_create_certificate_from_csr(future):
# type: (Future) -> None
try:
future.result() # raises exception if publish failed
print("Published CreateCertificateFromCsr request..")

except Exception as e:
print("Failed to publish CreateCertificateFromCsr request.")
Expand All @@ -116,9 +113,6 @@ def createkeysandcertificate_execution_accepted(response):
try:
global createKeysAndCertificateResponse
createKeysAndCertificateResponse = response
if (cmdData.input_is_ci == False):
print("Received a new message {}".format(createKeysAndCertificateResponse))

return

except Exception as e:
Expand All @@ -136,8 +130,6 @@ def createcertificatefromcsr_execution_accepted(response):
try:
global createCertificateFromCsrResponse
createCertificateFromCsrResponse = response
if (cmdData.input_is_ci == False):
print("Received a new message {}".format(createCertificateFromCsrResponse))
global certificateOwnershipToken
certificateOwnershipToken = response.certificate_ownership_token

Expand All @@ -158,8 +150,6 @@ def registerthing_execution_accepted(response):
try:
global registerThingResponse
registerThingResponse = response
if (cmdData.input_is_ci == False):
print("Received a new message {} ".format(registerThingResponse))
return

except Exception as e:
Expand All @@ -178,7 +168,6 @@ def on_connection_interrupted(connection, error, **kwargs):

# Callback when an interrupted connection is re-established.
def on_connection_resumed(connection, return_code, session_present, **kwargs):
print("Connection resumed. return_code: {} session_present: {}".format(return_code, session_present))

if return_code == mqtt.ConnectReturnCode.ACCEPTED and not session_present:
print("Session did not persist. Resubscribing to existing topics...")
Expand All @@ -191,7 +180,6 @@ def on_connection_resumed(connection, return_code, session_present, **kwargs):

def on_resubscribe_complete(resubscribe_future):
resubscribe_results = resubscribe_future.result()
print("Resubscribe results: {}".format(resubscribe_results))

for topic, qos in resubscribe_results['topics']:
if qos is None:
Expand All @@ -204,10 +192,6 @@ def waitForCreateKeysAndCertificateResponse():
while loopCount < 10 and createKeysAndCertificateResponse is None:
if createKeysAndCertificateResponse is not None:
break
if not cmdData.input_is_ci:
print('Waiting... CreateKeysAndCertificateResponse: ' + json.dumps(createKeysAndCertificateResponse))
else:
print("Waiting... CreateKeysAndCertificateResponse: ...")
loopCount += 1
time.sleep(1)

Expand All @@ -218,10 +202,6 @@ def waitForCreateCertificateFromCsrResponse():
while loopCount < 10 and createCertificateFromCsrResponse is None:
if createCertificateFromCsrResponse is not None:
break
if not cmdData.input_is_ci:
print('Waiting...CreateCertificateFromCsrResponse: ' + json.dumps(createCertificateFromCsrResponse))
else:
print("Waiting... CreateCertificateFromCsrResponse: ...")
loopCount += 1
time.sleep(1)

Expand All @@ -233,10 +213,6 @@ def waitForRegisterThingResponse():
if registerThingResponse is not None:
break
loopCount += 1
if not cmdData.input_is_ci:
print('Waiting... RegisterThingResponse: ' + json.dumps(registerThingResponse))
else:
print('Waiting... RegisterThingResponse: ...')
time.sleep(1)

# MQTT5 specific functions
Expand Down Expand Up @@ -322,13 +298,6 @@ def on_lifecycle_stopped(lifecycle_stopped_data: mqtt5.LifecycleStoppedData):
print("Unsopported MQTT version number\n")
sys.exit(-1)


if not cmdData.input_is_ci:
print(f"Connecting to {cmdData.input_endpoint} with client ID '{cmdData.input_clientId}'...")
else:
print("Connecting to endpoint with client ID")


print("Connected!")

try:
Expand All @@ -340,7 +309,6 @@ def on_lifecycle_stopped(lifecycle_stopped_data: mqtt5.LifecycleStoppedData):
if cmdData.input_csr_path is None:
createkeysandcertificate_subscription_request = iotidentity.CreateKeysAndCertificateSubscriptionRequest()

print("Subscribing to CreateKeysAndCertificate Accepted topic...")
createkeysandcertificate_subscribed_accepted_future, _ = identity_client.subscribe_to_create_keys_and_certificate_accepted(
request=createkeysandcertificate_subscription_request,
qos=mqtt_qos,
Expand All @@ -349,7 +317,6 @@ def on_lifecycle_stopped(lifecycle_stopped_data: mqtt5.LifecycleStoppedData):
# Wait for subscription to succeed
createkeysandcertificate_subscribed_accepted_future.result()

print("Subscribing to CreateKeysAndCertificate Rejected topic...")
createkeysandcertificate_subscribed_rejected_future, _ = identity_client.subscribe_to_create_keys_and_certificate_rejected(
request=createkeysandcertificate_subscription_request,
qos=mqtt_qos,
Expand All @@ -360,7 +327,6 @@ def on_lifecycle_stopped(lifecycle_stopped_data: mqtt5.LifecycleStoppedData):
else:
createcertificatefromcsr_subscription_request = iotidentity.CreateCertificateFromCsrSubscriptionRequest()

print("Subscribing to CreateCertificateFromCsr Accepted topic...")
createcertificatefromcsr_subscribed_accepted_future, _ = identity_client.subscribe_to_create_certificate_from_csr_accepted(
request=createcertificatefromcsr_subscription_request,
qos=mqtt_qos,
Expand All @@ -369,7 +335,6 @@ def on_lifecycle_stopped(lifecycle_stopped_data: mqtt5.LifecycleStoppedData):
# Wait for subscription to succeed
createcertificatefromcsr_subscribed_accepted_future.result()

print("Subscribing to CreateCertificateFromCsr Rejected topic...")
createcertificatefromcsr_subscribed_rejected_future, _ = identity_client.subscribe_to_create_certificate_from_csr_rejected(
request=createcertificatefromcsr_subscription_request,
qos=mqtt_qos,
Expand All @@ -381,7 +346,6 @@ def on_lifecycle_stopped(lifecycle_stopped_data: mqtt5.LifecycleStoppedData):
registerthing_subscription_request = iotidentity.RegisterThingSubscriptionRequest(
template_name=cmdData.input_template_name)

print("Subscribing to RegisterThing Accepted topic...")
registerthing_subscribed_accepted_future, _ = identity_client.subscribe_to_register_thing_accepted(
request=registerthing_subscription_request,
qos=mqtt_qos,
Expand All @@ -390,7 +354,6 @@ def on_lifecycle_stopped(lifecycle_stopped_data: mqtt5.LifecycleStoppedData):
# Wait for subscription to succeed
registerthing_subscribed_accepted_future.result()

print("Subscribing to RegisterThing Rejected topic...")
registerthing_subscribed_rejected_future, _ = identity_client.subscribe_to_register_thing_rejected(
request=registerthing_subscription_request,
qos=mqtt_qos,
Expand All @@ -401,7 +364,6 @@ def on_lifecycle_stopped(lifecycle_stopped_data: mqtt5.LifecycleStoppedData):
fleet_template_name = cmdData.input_template_name
fleet_template_parameters = cmdData.input_template_parameters
if cmdData.input_csr_path is None:
print("Publishing to CreateKeysAndCertificate...")
publish_future = identity_client.publish_create_keys_and_certificate(
request=iotidentity.CreateKeysAndCertificateRequest(), qos=mqtt_qos)
publish_future.add_done_callback(on_publish_create_keys_and_certificate)
Expand All @@ -416,7 +378,6 @@ def on_lifecycle_stopped(lifecycle_stopped_data: mqtt5.LifecycleStoppedData):
certificate_ownership_token=createKeysAndCertificateResponse.certificate_ownership_token,
parameters=json.loads(fleet_template_parameters))
else:
print("Publishing to CreateCertificateFromCsr...")
csrPath = open(cmdData.input_csr_path, 'r').read()
publish_future = identity_client.publish_create_certificate_from_csr(
request=iotidentity.CreateCertificateFromCsrRequest(certificate_signing_request=csrPath),
Expand All @@ -433,7 +394,6 @@ def on_lifecycle_stopped(lifecycle_stopped_data: mqtt5.LifecycleStoppedData):
certificate_ownership_token=createCertificateFromCsrResponse.certificate_ownership_token,
parameters=json.loads(fleet_template_parameters))

print("Publishing to RegisterThing topic...")
registerthing_publish_future = identity_client.publish_register_thing(
registerThingRequest, mqtt_qos)
registerthing_publish_future.add_done_callback(on_publish_register_thing)
Expand Down

0 comments on commit c193269

Please sign in to comment.