Could somebody explain to me how this code in tempest/test.py can possibly work:

    @classmethod
    def setup_credentials(cls):
        """Allocate credentials and the client managers from them.
        A test class that requires network resources must override
        setup_credentials and defined the required resources before super
        is invoked.
        """
        for credentials_type in cls.credentials:
# This may raise an exception in case credentials are not available
            # In that case we want to let the exception through and the test
            # fail accordingly
            if isinstance(credentials_type, six.string_types):
                manager = cls.get_client_manager(
                    credential_type=credentials_type)
                setattr(cls, 'os_%s' % credentials_type, manager)
                # Setup some common aliases
                # TODO(andreaf) The aliases below are a temporary hack
                # to avoid changing too much code in one patch. They should
                # be removed eventually
                if credentials_type == 'primary':
                    cls.os = cls.manager = cls.os_primary
                if credentials_type == 'admin':
                    cls.os_adm = cls.admin_manager = cls.os_admin
                if credentials_type == 'alt':
                    cls.alt_manager = cls.os_alt
            elif isinstance(credentials_type, list):
                manager = cls.get_client_manager(roles=credentials_type[1:],
                                                 force_new=True)
                setattr(cls, 'os_roles_%s' % credentials_type[0], manager)

I'm wondering about the following line:

cls.os_adm = cls.admin_manager = cls.os_admin

From inside the root directory I do a grep search:

$ grep -Hr os_admin tempest
Binary file tempest/test.pyc matches
tempest/test.py: cls.os_adm = cls.admin_manager = cls.os_admin tempest/api/baremetal/admin/base.py: cls.client = cls.os_admin.baremetal_client
Binary file tempest/api/baremetal/admin/base.pyc matches

This indicates to me that "os_admin" isn't being assigned a value anywhere. Therefore, I would expect an AttributeError (class BaseTestCase has no attribute 'os_admin'), yet this class method seems to work. What am I missing?

Thanks,

John


_______________________________________________
OpenStack-Infra mailing list
OpenStack-Infra@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-infra

Reply via email to