Beispiel #1
0
 def as_dict(self):
     """Return the object as a dictionary.
     Note that the password is omitted from the output for
     security reasons.
     """
     dictionary = {
         "id": self.__provider_id,
         "type": get_provider_type(self.__provider_idx),
         "username": self.__username,
         "url": self.__url,
         "tenant": self.__tenant or "",
         "default_image": self.__default_image or "",
         "default_flavor": self.__default_flavor or "",
         "extra": self.__extra or ""
     }
     return dictionary
 def as_dict(self):
     """Return the object as a dictionary.
     Note that the password is omitted from the output for
     security reasons.
     """
     dictionary = {
         "id": self.__provider_id,
         "type": get_provider_type(self.__provider_idx),
         "username": self.__username,
         "url": self.__url,
         "tenant": self.__tenant or "",
         "default_image": self.__default_image or "",
         "default_flavor": self.__default_flavor or "",
         "extra": self.__extra or "",
     }
     return dictionary
Beispiel #3
0
    def construct_from_row(row):
        """Create a Provider object from a row.

        :row param: Record that contains provider's data.
        """
        provider_id, provider_idx, username, password, url, tenant, \
            default_image, default_flavor, extra = row
        if extra:
            extra = [str(opt) for opt in json.loads(extra)]
        provider_type = get_provider_type(provider_idx)

        return Provider(provider_id=provider_id,
                        provider_type=provider_type,
                        username=username,
                        password=password,
                        url=url,
                        tenant=tenant,
                        default_image=default_image,
                        default_flavor=default_flavor,
                        extra=extra)
    def construct_from_row(row):
        """Create a Provider object from a row.

        :row param: Record that contains provider's data.
        """
        provider_id, provider_idx, username, password, url, tenant, default_image, default_flavor, extra = row
        if extra:
            extra = [str(opt) for opt in json.loads(extra)]
        provider_type = get_provider_type(provider_idx)

        return Provider(
            provider_id=provider_id,
            provider_type=provider_type,
            username=username,
            password=password,
            url=url,
            tenant=tenant,
            default_image=default_image,
            default_flavor=default_flavor,
            extra=extra,
        )
Beispiel #5
0
    def __init__(self,
                 provider_id=None,
                 provider_type=None,
                 username=None,
                 password=None,
                 url=None,
                 tenant=None,
                 default_image=None,
                 default_flavor=None,
                 row=None):
        """Constructor for the Provider.
        """
        super(Provider, self).__init__()

        if row is not None:
            assert provider_id is None
            assert provider_type is None
            assert username is None
            assert password is None
            assert url is None
            assert tenant is None
            provider_id, provider_idx, username, password, url, tenant, \
                default_image, default_flavor = row
            provider_type = get_provider_type(provider_idx)

        assert provider_id is not None
        assert provider_type is not None
        assert username is not None
        assert password is not None
        assert url is not None
        assert tenant is not None

        self.__provider_id = provider_id
        self.__provider_idx = get_provider_idx(provider_type)
        self.__username = username
        self.__password = password
        self.__url = url
        self.__tenant = tenant
        self.__default_image = default_image
        self.__default_flavor = default_flavor
Beispiel #6
0
 def provider_type(self):
     """Return the provider's type.
     """
     return get_provider_type(self.__provider_idx)
 def provider_type(self):
     """Return the provider's type.
     """
     return get_provider_type(self.__provider_idx)