sregistry/main/swift/__init__.py
def _update_secrets(self):
        '''update secrets will look for a user and token in the environment
           If we find the values, cache and continue. Otherwise, exit with error
        '''

        # Get the swift authentication type first.  That will determine what we
        # will need to collect for proper authentication
        self.config['SREGISTRY_SWIFT_AUTHTYPE'] = self._required_get_and_update(
                                                     'SREGISTRY_SWIFT_AUTHTYPE')

        # Check what auth version is requested and setup the connection
        if self.config['SREGISTRY_SWIFT_AUTHTYPE'] == 'preauth':

            # Pre-Authenticated Token/URL - Use OS_AUTH_TOKEN/OS_STORAGE_URL
            # Retrieve the user token, user, and base. Exit if not found 
            for envar in ['SREGISTRY_SWIFT_OS_AUTH_TOKEN',
                          'SREGISTRY_SWIFT_OS_STORAGE_URL' ]:
                self.config[envar] = self._required_get_and_update(envar)

            self.conn = swiftclient.Connection(
                preauthurl=self.config['SREGISTRY_SWIFT_OS_STORAGE_URL'],
                preauthtoken=self.config['SREGISTRY_SWIFT_OS_AUTH_TOKEN']
            )
        elif self.config['SREGISTRY_SWIFT_AUTHTYPE'] == 'keystonev3':

            # Keystone v3 Authentication
            # Retrieve the user token, user, and base. Exit if not found 
            for envar in ['SREGISTRY_SWIFT_USER',
                          'SREGISTRY_SWIFT_TOKEN',
                          'SREGISTRY_SWIFT_URL']:
                self.config[envar] = self._required_get_and_update(envar)

            auth_url = '%s/v3' % self.config['SREGISTRY_SWIFT_URL']
            # Setting to default as a safety.  No v3 environment to test
            # May require ENV vars for real use. - M. Moore
            _os_options = {
                'user_domain_name': 'Default',
                'project_domain_name': 'Default',
                'project_name': 'Default'
            }

            # Save the connection to use for some command
            self.conn = swiftclient.Connection(
                user=self.config['SREGISTRY_SWIFT_USER'],
                key=self.config['SREGISTRY_SWIFT_TOKEN'],
                os_options=_os_options,
                authurl=auth_url,
                auth_version='3'
            )

        elif self.config['SREGISTRY_SWIFT_AUTHTYPE'] == 'keystonev2':

            # Keystone v2 Authentication
            # Retrieve the user token, user, and base. Exit if not found 
            for envar in ['SREGISTRY_SWIFT_USER',
                          'SREGISTRY_SWIFT_TOKEN',
                          'SREGISTRY_SWIFT_TENANT',
                          'SREGISTRY_SWIFT_REGION',
                          'SREGISTRY_SWIFT_URL']:
                self.config[envar] = self._required_get_and_update(envar)

            # More human friendly to interact with
            auth_url = '%s/v2.0/' % self.config['SREGISTRY_SWIFT_URL']
            # Set required OpenStack options for tenant/region
            _os_options = {
                'tenant_name': self.config['SREGISTRY_SWIFT_TENANT'],
                'region_name': self.config['SREGISTRY_SWIFT_REGION']
            }

            # Save the connection to use for some command
            self.conn = swiftclient.Connection(
                user=self.config['SREGISTRY_SWIFT_USER'],
                key=self.config['SREGISTRY_SWIFT_TOKEN'],
                os_options=_os_options,
                authurl=auth_url,
                auth_version='2'
            )
        else:

            # Legacy Authentication
            # Retrieve the user token, user, and base. Exit if not found 
            for envar in ['SREGISTRY_SWIFT_USER',
                          'SREGISTRY_SWIFT_TOKEN',
                          'SREGISTRY_SWIFT_URL']:
                self.config[envar] = self._required_get_and_update(envar)

            # More human friendly to interact with
            auth_url = '%s/auth/' % self.config['SREGISTRY_SWIFT_URL']

            # Save the connection to use for some command
            self.conn = swiftclient.Connection(
                user=self.config['SREGISTRY_SWIFT_USER'],
                key=self.config['SREGISTRY_SWIFT_TOKEN'],
                authurl=auth_url,
            )
def _update_secrets(self):
        '''update secrets will look for a user and token in the environment
           If we find the values, cache and continue. Otherwise, exit with error
        '''

        # Get the swift authentication type first.  That will determine what we
        # will need to collect for proper authentication
        self.config['SREGISTRY_SWIFT_AUTHTYPE'] = self._required_get_and_update(
                                                     'SREGISTRY_SWIFT_AUTHTYPE')

        # Check what auth version is requested and setup the connection
        if self.config['SREGISTRY_SWIFT_AUTHTYPE'] == 'preauth':

            # Pre-Authenticated Token/URL - Use OS_AUTH_TOKEN/OS_STORAGE_URL
            # Retrieve the user token, user, and base. Exit if not found 
            for envar in ['SREGISTRY_SWIFT_OS_AUTH_TOKEN',
                          'SREGISTRY_SWIFT_OS_STORAGE_URL' ]:
                self.config[envar] = self._required_get_and_update(envar)

            self.conn = swiftclient.Connection(
                preauthurl=self.config['SREGISTRY_SWIFT_OS_STORAGE_URL'],
                preauthtoken=self.config['SREGISTRY_SWIFT_OS_AUTH_TOKEN']
            )
        elif self.config['SREGISTRY_SWIFT_AUTHTYPE'] == 'keystonev3':

            # Keystone v3 Authentication
            # Retrieve the user token, user, and base. Exit if not found 
            for envar in ['SREGISTRY_SWIFT_USER',
                          'SREGISTRY_SWIFT_TOKEN',
                          'SREGISTRY_SWIFT_URL']:
                self.config[envar] = self._required_get_and_update(envar)

            auth_url = '%s/v3' % self.config['SREGISTRY_SWIFT_URL']
            # Setting to default as a safety.  No v3 environment to test
            # May require ENV vars for real use. - M. Moore
            _os_options = {
                'user_domain_name': 'Default',
                'project_domain_name': 'Default',
                'project_name': 'Default'
            }

            # Save the connection to use for some command
            self.conn = swiftclient.Connection(
                user=self.config['SREGISTRY_SWIFT_USER'],
                key=self.config['SREGISTRY_SWIFT_TOKEN'],
                os_options=_os_options,
                authurl=auth_url,
                auth_version='3'
            )

        elif self.config['SREGISTRY_SWIFT_AUTHTYPE'] == 'keystonev2':

            # Keystone v2 Authentication
            # Retrieve the user token, user, and base. Exit if not found 
            for envar in ['SREGISTRY_SWIFT_USER',
                          'SREGISTRY_SWIFT_TOKEN',
                          'SREGISTRY_SWIFT_TENANT',
                          'SREGISTRY_SWIFT_REGION',
                          'SREGISTRY_SWIFT_URL']:
                self.config[envar] = self._required_get_and_update(envar)

            # More human friendly to interact with
            auth_url = '%s/v2.0/' % self.config['SREGISTRY_SWIFT_URL']
            # Set required OpenStack options for tenant/region
            _os_options = {
                'tenant_name': self.config['SREGISTRY_SWIFT_TENANT'],
                'region_name': self.config['SREGISTRY_SWIFT_REGION']
            }

            # Save the connection to use for some command
            self.conn = swiftclient.Connection(
                user=self.config['SREGISTRY_SWIFT_USER'],
                key=self.config['SREGISTRY_SWIFT_TOKEN'],
                os_options=_os_options,
                authurl=auth_url,
                auth_version='2'
            )
        else:

            # Legacy Authentication
            # Retrieve the user token, user, and base. Exit if not found 
            for envar in ['SREGISTRY_SWIFT_USER',
                          'SREGISTRY_SWIFT_TOKEN',
                          'SREGISTRY_SWIFT_URL']:
                self.config[envar] = self._required_get_and_update(envar)

            # More human friendly to interact with
            auth_url = '%s/auth/' % self.config['SREGISTRY_SWIFT_URL']

            # Save the connection to use for some command
            self.conn = swiftclient.Connection(
                user=self.config['SREGISTRY_SWIFT_USER'],
                key=self.config['SREGISTRY_SWIFT_TOKEN'],
                authurl=auth_url,
            )
def _update_secrets ( self ) : # Get the swift authentication type first.  That will determine what we # will need to collect for proper authentication self . config [ 'SREGISTRY_SWIFT_AUTHTYPE' ] = self . _required_get_and_update ( 'SREGISTRY_SWIFT_AUTHTYPE' ) # Check what auth version is requested and setup the connection if self . config [ 'SREGISTRY_SWIFT_AUTHTYPE' ] == 'preauth' : # Pre-Authenticated Token/URL - Use OS_AUTH_TOKEN/OS_STORAGE_URL # Retrieve the user token, user, and base. Exit if not found  for envar in [ 'SREGISTRY_SWIFT_OS_AUTH_TOKEN' , 'SREGISTRY_SWIFT_OS_STORAGE_URL' ] : self . config [ envar ] = self . _required_get_and_update ( envar ) self . conn = swiftclient . Connection ( preauthurl = self . config [ 'SREGISTRY_SWIFT_OS_STORAGE_URL' ] , preauthtoken = self . config [ 'SREGISTRY_SWIFT_OS_AUTH_TOKEN' ] ) elif self . config [ 'SREGISTRY_SWIFT_AUTHTYPE' ] == 'keystonev3' : # Keystone v3 Authentication # Retrieve the user token, user, and base. Exit if not found  for envar in [ 'SREGISTRY_SWIFT_USER' , 'SREGISTRY_SWIFT_TOKEN' , 'SREGISTRY_SWIFT_URL' ] : self . config [ envar ] = self . _required_get_and_update ( envar ) auth_url = '%s/v3' % self . config [ 'SREGISTRY_SWIFT_URL' ] # Setting to default as a safety.  No v3 environment to test # May require ENV vars for real use. - M. Moore _os_options = { 'user_domain_name' : 'Default' , 'project_domain_name' : 'Default' , 'project_name' : 'Default' } # Save the connection to use for some command self . conn = swiftclient . Connection ( user = self . config [ 'SREGISTRY_SWIFT_USER' ] , key = self . config [ 'SREGISTRY_SWIFT_TOKEN' ] , os_options = _os_options , authurl = auth_url , auth_version = '3' ) elif self . config [ 'SREGISTRY_SWIFT_AUTHTYPE' ] == 'keystonev2' : # Keystone v2 Authentication # Retrieve the user token, user, and base. Exit if not found  for envar in [ 'SREGISTRY_SWIFT_USER' , 'SREGISTRY_SWIFT_TOKEN' , 'SREGISTRY_SWIFT_TENANT' , 'SREGISTRY_SWIFT_REGION' , 'SREGISTRY_SWIFT_URL' ] : self . config [ envar ] = self . _required_get_and_update ( envar ) # More human friendly to interact with auth_url = '%s/v2.0/' % self . config [ 'SREGISTRY_SWIFT_URL' ] # Set required OpenStack options for tenant/region _os_options = { 'tenant_name' : self . config [ 'SREGISTRY_SWIFT_TENANT' ] , 'region_name' : self . config [ 'SREGISTRY_SWIFT_REGION' ] } # Save the connection to use for some command self . conn = swiftclient . Connection ( user = self . config [ 'SREGISTRY_SWIFT_USER' ] , key = self . config [ 'SREGISTRY_SWIFT_TOKEN' ] , os_options = _os_options , authurl = auth_url , auth_version = '2' ) else : # Legacy Authentication # Retrieve the user token, user, and base. Exit if not found  for envar in [ 'SREGISTRY_SWIFT_USER' , 'SREGISTRY_SWIFT_TOKEN' , 'SREGISTRY_SWIFT_URL' ] : self . config [ envar ] = self . _required_get_and_update ( envar ) # More human friendly to interact with auth_url = '%s/auth/' % self . config [ 'SREGISTRY_SWIFT_URL' ] # Save the connection to use for some command self . conn = swiftclient . Connection ( user = self . config [ 'SREGISTRY_SWIFT_USER' ] , key = self . config [ 'SREGISTRY_SWIFT_TOKEN' ] , authurl = auth_url , )
update secrets will look for a user and token in the environment
           If we find the values, cache and continue. Otherwise, exit with error
update secrets will look for a user and token in the environment If we find the values cache and continue . Otherwise exit with error