コード例 #1
0
    def ensure_exists(self):
        """Ensures pool exists

        This method is not race safe,
        the pool could've been deleted
        right after it was called.
        """
        req, trans = self.client._request_and_transport()
        # As of now on PUT, zaqar server updates pool if it is already
        # exists else it will create a new one. The zaqar client should
        # maitain symmetry with zaqar server.
        # TBD(mdnadeem): Have to change this code when zaqar server
        # behaviour change for PUT operation.

        data = {
            'uri': self.uri,
            'weight': self.weight,
            'options': self.options
        }

        if self.client.api_version >= 1.1 and self.flavor:
            data['flavor'] = self.flavor

        req, trans = self.client._request_and_transport()
        core.pool_create(trans, req, self.name, data)
コード例 #2
0
    def ensure_exists(self):
        """Ensures pool exists

        This method is not race safe,
        the pool could've been deleted
        right after it was called.
        """
        req, trans = self.client._request_and_transport()

        try:
            pool = core.pool_get(trans, req, self.name)
            self.uri = pool["uri"]
            self.weight = pool["weight"]
            self.group = pool.get("group", None)
            self.options = pool.get("options", {})

        except errors.ResourceNotFound:
            data = {
                'uri': self.uri,
                'weight': self.weight,
                'options': self.options
            }

            if self.client.api_version >= 1.1:
                data['group'] = self.group

            req, trans = self.client._request_and_transport()
            core.pool_create(trans, req, self.name, data)
コード例 #3
0
    def test_pool_create(self):
        with mock.patch.object(self.transport, 'send',
                               autospec=True) as send_method:
            resp = response.Response(None, None)
            send_method.return_value = resp

            req = request.Request()
            core.pool_create(self.transport, req,
                             'test_pool', {'uri': 'sqlite://',
                                           'weight': 0})
コード例 #4
0
ファイル: pool.py プロジェクト: jeffrey4l/python-zaqarclient
    def ensure_exists(self):
        """Ensures pool exists

        This method is not race safe,
        the pool could've been deleted
        right after it was called.
        """
        req, trans = self.client._request_and_transport()

        data = {"uri": self.uri, "weight": self.weight, "options": self.options}

        core.pool_create(trans, req, self.name, data)
コード例 #5
0
ファイル: pool.py プロジェクト: jeffrey4l/python-zaqarclient
    def ensure_exists(self):
        """Ensures pool exists

        This method is not race safe,
        the pool could've been deleted
        right after it was called.
        """
        req, trans = self.client._request_and_transport()

        data = {
            'uri': self.uri,
            'weight': self.weight,
            'options': self.options
        }

        core.pool_create(trans, req, self.name, data)
コード例 #6
0
ファイル: pool.py プロジェクト: openstack/python-zaqarclient
    def ensure_exists(self):
        """Ensures pool exists

        This method is not race safe,
        the pool could've been deleted
        right after it was called.
        """
        req, trans = self.client._request_and_transport()
        # As of now on PUT, zaqar server updates pool if it is already
        # exists else it will create a new one. The zaqar client should
        # maitain symmetry with zaqar server.
        # TBD(mdnadeem): Have to change this code when zaqar server
        # behaviour change for PUT operation.

        data = {'uri': self.uri,
                'weight': self.weight,
                'options': self.options}

        if self.client.api_version >= 1.1 and self.group:
            data['group'] = self.group

        req, trans = self.client._request_and_transport()
        core.pool_create(trans, req, self.name, data)