Esempio n. 1
0
    def clean_devices(self, config_file, region=None, profile_name=None):
        """
        Clean all device related provisioned artifacts from both the local file
        and the AWS Greengrass service.

        :param config_file: config file containing the devices to clean
        :param region: the region in which the devices should be cleaned.
            [default: us-west-2]
        :param profile_name: the name of the `awscli` profile to use.
            [default: None]
        """
        config = GroupConfigFile(config_file=config_file)
        if region is None:
            region = self._region

        devices = config['devices']
        if 'device_thing_name' in devices:
            logging.info('Configured devices already clean')
            return

        policy_name = config['misc']['policy_name']
        for device in devices:
            cert_arn = devices[device]['cert_arn']
            cert_id = devices[device]['cert_id']
            thing_name = device
            logging.info('Deleting device_thing_name:{0}'.format(thing_name))
            GroupCommands._delete_thing(
                cert_arn, cert_id, thing_name, region, policy_name, profile_name
            )
        config.make_devices_fresh()
Esempio n. 2
0
    def clean_devices(self, config_file, region=None):
        """
        Clean all device related provisioned artifacts from both the local file
        and the AWS Greengrass service.

        :param config_file:
        :param region:
        :return:
        """
        config = GroupConfigFile(config_file=config_file)
        if region is None:
            region = self._region

        devices = config['devices']
        policy_name = config['misc']['policy_name']
        for device in devices:
            cert_arn = devices[device]['cert_arn']
            cert_id = devices[device]['cert_id']
            thing_name = device
            logging.info('Deleting device_thing_name:{0}'.format(thing_name))
            GroupCommands._delete_thing(cert_arn, cert_id, thing_name, region,
                                        policy_name)
        config.make_devices_fresh()