Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Enroll a single device #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

a-martynovich
Copy link

@a-martynovich a-martynovich commented Jun 28, 2019

WoTTsecurity/api#278
Note: the --device argument is optional because if it's not specified this utility should list all devices and enroll all of them. To do this it needs an API key (WoTTsecurity/api#278), so it's not yet implemented.

@vpetersson vpetersson requested a review from rptrchv June 28, 2019 17:55


WOTT_ENDPOINT = os.getenv('WOTT_ENDPOINT', 'https://api.wott.io')
PROJECT = 'wott-244904'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used


WOTT_ENDPOINT = os.getenv('WOTT_ENDPOINT', 'https://api.wott.io')
PROJECT = 'wott-244904'
LOCATION = 'europe-west1'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used

def create_client():
# iot.DeviceManagerClient doesn't do this himself, unlike other Google libs.
if 'GOOGLE_APPLICATION_CREDENTIALS' in os.environ:
with open(os.environ['GOOGLE_APPLICATION_CREDENTIALS']) as key:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a file, not a key

return client


def create_registry(client, project_name, location, registry_name, pubsub_topic, ca_cert):
Copy link

@rptrchv rptrchv Jul 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls fix PEP8 compliance of this function code

device = client.create_device(registry_path, device)
else:
print(f'Updating device {device_name}')
device = types.Device(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use the device instance received in the try clause?




if __name__ == '__main__':
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls carefully check all arguments' required and default values. Many of them look wrong

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants