Example #1
0
 def test_sanitize_registry(self):
     """ Test a valid invocation of API sanitize_registry_data """
     result = EdgeUtils.sanitize_registry_data('test_address',
                                               'test_username',
                                               'test_password')
     pattern = re.compile(
         r'^Address: test_address, Username: test_username, Password:[\*]+$'
     )
     self.assertTrue(pattern.match(result))
Example #2
0
 def __str__(self):
     result = 'Deployment Type:\t' + self.deployment_type + '\n'
     result += 'Docker Engine URI:\t' + self.uri + '\n'
     result += 'Edge Agent Image:\t' + self.edge_image + '\n'
     result += 'Registries:' + '\n'
     for registry in self.registries:
         result += '\t\t\t'
         reg_str = EdgeUtils.sanitize_registry_data(registry[EC.REGISTRY_ADDRESS_KEY],
                                                    registry[EC.REGISTRY_USERNAME_KEY],
                                                    registry[EC.REGISTRY_PASSWORD_KEY])
         result += reg_str + '\n'
     result += 'Logging Driver:\t\t' + self.logging_driver + '\n'
     options = self.logging_options
     for key in options:
         result += '\t\t\t' + str(key) + ': ' + options[key] + '\n'
     return result
Example #3
0
    def _parse_login_options(self, args):
        is_valid = self._parse_command_options_common(args)
        if is_valid:
            try:
                self.edge_config.deployment_config.add_registry(
                    args.address, args.username, args.password)
            except ValueError as ex:
                log.error('%s', str(ex))
                msg = EdgeUtils.sanitize_registry_data(args.address,
                                                       args.username,
                                                       args.password)
                log.error('Error setting login data: [%s].', msg)
                raise edgectl.errors.EdgeError('Error setting login data', ex)

            EdgeHostPlatform.install_edge_by_json_data(self.edge_config, False)
            config_file = EdgeHostPlatform.get_host_config_file_path()
            log.info('The runtime configuration file %s was updated with' \
                     ' the credentials for registry: %s', config_file, args.address)
        return is_valid