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

        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

        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
        self.__extra = extra
Example #2
0
    def __init__(
        self,
        provider_id,
        provider_type,
        username,
        password,
        url,
        tenant=None,
        default_image=None,
        default_flavor=None,
        extra=None,
    ):
        """Constructor for the Provider.
        """
        super(Provider, self).__init__()

        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

        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
        self.__extra = extra
Example #3
0
    def add(provider, persister=None):
        """Write a provider object into the state store.

        :param provider: A reference to a provider.
        :param persister: Object to access the state store.
        """
        persister.exec_stmt(
            _INSERT_PROVIDER, {
                "params":
                (provider.provider_id, get_provider_idx(
                    provider.provider_type), provider.username,
                 provider.password, provider.url, provider.tenant,
                 provider.default_image, provider.default_flavor)
            })
Example #4
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
Example #5
0
    def add(provider, persister=None):
        """Write a provider object into the state store.

        :param provider: A reference to a provider.
        :param persister: Object to access the state store.
        """
        extra = provider.extra
        persister.exec_stmt(
            _INSERT_PROVIDER,
            {
                "params": (
                    provider.provider_id,
                    get_provider_idx(provider.provider_type),
                    provider.username,
                    provider.password,
                    provider.url,
                    provider.tenant,
                    provider.default_image,
                    provider.default_flavor,
                    json.dumps(extra) if extra else extra,
                )
            },
        )