コード例 #1
0
 def cancel(self, replica, execution, force=False):
     return self.client.post(
         '/replicas/%(replica_id)s/executions/%(execution_id)s/actions' % {
             "replica_id": base.getid(replica),
             "execution_id": base.getid(execution)
         },
         json={'cancel': {
             'force': force
         }})
コード例 #2
0
    def update(self, replica_id, schedule_id, updated_values):
        expiration_date = updated_values.get("expiration_date")
        if expiration_date:
            updated_values = updated_values.copy()
            updated_values["expiration_date"] = self._format_rfc3339_datetime(
                expiration_date)

        return self._put(
            '/replicas/%(replica_id)s/schedules/%(schedule_id)s' % {
                "replica_id": base.getid(replica_id),
                "schedule_id": base.getid(schedule_id)
            }, updated_values, 'schedule')
コード例 #3
0
    def update(self, replica_id, schedule_id, updated_values):
        expiration_date = updated_values.get("expiration_date")
        if expiration_date:
            updated_values = updated_values.copy()
            updated_values["expiration_date"] = self._format_rfc3339_datetime(
                expiration_date)

        return self._put(
            '/replicas/%(replica_id)s/schedules/%(schedule_id)s' % {
                "replica_id": base.getid(replica_id),
                "schedule_id": base.getid(schedule_id)},
            updated_values, 'schedule')
コード例 #4
0
    def delete_disks(self, replica):
        response = self.client.post(
            '/replicas/%s/actions' % base.getid(replica),
            json={'delete-disks': None})

        return replica_executions.ReplicaExecution(
            self, response.json().get("execution"), loaded=True)
コード例 #5
0
    def delete_disks(self, replica):
        response = self.client.post(
            '/replicas/%s/actions' % base.getid(replica),
            json={'delete-disks': None})

        return replica_executions.ReplicaExecution(
            self, response.json().get("execution"), loaded=True)
コード例 #6
0
 def validate_connection(self, endpoint):
     data = self.client.post('/endpoints/%s/actions' % base.getid(endpoint),
                             json={
                                 'validate-connection': None
                             }).json()
     validate_data = data["validate-connection"]
     return validate_data.get("valid"), validate_data.get("message")
コード例 #7
0
 def list(self, replica, hide_expired=False):
     query = {}
     if hide_expired:
         query["show_expired"] = hide_expired is False
     url = '/replicas/%s/schedules' % base.getid(replica)
     if query:
         url += "?" + urlparse.urlencode(query)
     return self._list(url, 'schedules')
コード例 #8
0
 def list(self, replica, hide_expired=False):
     query = {}
     if hide_expired:
         query["show_expired"] = hide_expired is False
     url = '/replicas/%s/schedules' % base.getid(replica)
     if query:
         url += "?" + urlparse.urlencode(query)
     return self._list(
         url, 'schedules')
コード例 #9
0
    def list(self, endpoint, environment=None):
        url = '/endpoints/%s/storage' % base.getid(endpoint)

        if environment:
            encoded_env = base64.b64encode(
                json.dumps(environment).encode()).decode()
            url = '%s?env=%s' % (url, encoded_env)

        return self._list(url, 'storage', values_key='storage_backends')
コード例 #10
0
    def update(self, replica, updated_values):
        data = {
            "replica": updated_values
        }
        response = self.client.put(
            '/replicas/%s' % base.getid(replica), json=data)

        return replica_executions.ReplicaExecution(
            self, response.json().get("execution"), loaded=True)
コード例 #11
0
    def get_default(self, endpoint, environment=None):
        url = '/endpoints/%s/storage' % base.getid(endpoint)

        if environment:
            encoded_env = base64.b64encode(
                json.dumps(environment).encode()).decode()
            url = '%s?env=%s' % (url, encoded_env)

        return self._get(url, 'storage').get('config_default')
コード例 #12
0
    def list(self, endpoint, environment=None):
        url = '/endpoints/%s/networks' % base.getid(endpoint)

        if environment:
            encoded_env = base64.b64encode(
                json.dumps(environment).encode()).decode()
            url = '%s?env=%s' % (url, encoded_env)

        return self._list(url, 'networks')
コード例 #13
0
 def create(self, replica, schedule, enabled, expiration_date,
            shutdown_instance):
     data = {
         "schedule": schedule,
         "enabled": enabled,
         "shutdown_instance": shutdown_instance,
     }
     if expiration_date:
         data["expiration_date"] = self._format_rfc3339_datetime(
             expiration_date)
     return self._post('/replicas/%s/schedules' % base.getid(replica), data,
                       'schedule')
コード例 #14
0
 def create(self, replica, schedule, enabled, expiration_date,
            shutdown_instance):
     data = {
         "schedule": schedule,
         "enabled": enabled,
         "shutdown_instance": shutdown_instance,
     }
     if expiration_date:
         data["expiration_date"] = self._format_rfc3339_datetime(
             expiration_date)
     return self._post(
         '/replicas/%s/schedules' % base.getid(replica), data, 'schedule')
コード例 #15
0
    def get(self, endpoint, instance_id, env=None):
        encoded_instance = base64.b64encode(instance_id.encode()).decode()
        url = '/endpoints/%s/instances/%s' % (base.getid(endpoint),
                                              encoded_instance)

        if env is not None:
            if not isinstance(env, dict):
                raise ValueError("'env' param must be a dict")

            encoded_env = base64.b64encode(json.dumps(env).encode()).decode()
            url = "%s?env=%s" % (url, encoded_env)

        return self._get(url, 'instance')
コード例 #16
0
    def list(self, endpoint, marker=None, limit=None, name=None):

        query = {}
        if marker is not None:
            query['marker'] = marker
        if limit is not None:
            query['limit'] = limit
        if name is not None:
            query["name"] = name

        url = '/endpoints/%s/instances' % base.getid(endpoint)
        if query:
            url += "?" + urlparse.urlencode(query)

        return self._list(url, 'instances')
コード例 #17
0
    def list(self, endpoint, marker=None, limit=None, name=None):

        query = {}
        if marker is not None:
            query['marker'] = marker
        if limit is not None:
            query['limit'] = limit
        if name is not None:
            query["name"] = name

        url = '/endpoints/%s/instances' % base.getid(endpoint)
        if query:
            url += "?" + urlparse.urlencode(query)

        return self._list(url, 'instances')
コード例 #18
0
    def list(self, endpoint, environment=None, option_names=None):
        url = '/endpoints/%s/source-options' % base.getid(endpoint)

        if environment:
            encoded_env = base64.b64encode(
                json.dumps(environment).encode()).decode()
            url = '%s?env=%s' % (url, encoded_env)

        if option_names:
            sep = "?"
            if environment:
                sep = "&"
            encoded_option_names = base64.b64encode(
                json.dumps(option_names).encode()).decode()
            url = '%s%soptions=%s' % (url, sep, encoded_option_names)

        return self._list(url, 'source_options')
コード例 #19
0
    def list(self, endpoint, environment=None, option_names=None):
        url = '/endpoints/%s/destination-options' % base.getid(endpoint)

        if environment:
            encoded_env = base64.b64encode(
                json.dumps(environment).encode()).decode()
            url = '%s?env=%s' % (url, encoded_env)

        if option_names:
            sep = "?"
            if environment:
                sep = "&"
            encoded_option_names = base64.b64encode(
                json.dumps(option_names).encode()).decode()
            url = '%s%soptions=%s' % (url, sep, encoded_option_names)

        return self._list(url, 'destination_options')
コード例 #20
0
    def list(self, endpoint, env=None, marker=None, limit=None, name=None):

        query = {}
        if marker is not None:
            query['marker'] = marker
        if limit is not None:
            query['limit'] = limit
        if name is not None:
            query["name"] = name
        if env is not None:
            if not isinstance(env, dict):
                raise ValueError("'env' param must be a dict")
            query['env'] = base64.b64encode(json.dumps(env).encode()).decode()

        url = '/endpoints/%s/instances' % base.getid(endpoint)
        if query:
            url += "?" + urlparse.urlencode(query)

        return self._list(url, 'instances')
コード例 #21
0
 def delete(self, replica):
     return self._delete('/replicas/%s' % base.getid(replica))
コード例 #22
0
 def cancel(self, migration, force=False):
     return self.client.post(
         '/migrations/%s/actions' % base.getid(migration),
         json={'cancel': {'force': force}})
コード例 #23
0
 def get(self, migration):
     return self._get('/migrations/%s' % base.getid(migration), 'migration')
コード例 #24
0
 def delete(self, replica, execution):
     return self._delete(
         '/replicas/%(replica_id)s/executions/%(execution_id)s' % {
             "replica_id": base.getid(replica),
             "execution_id": base.getid(execution)
         })
コード例 #25
0
 def get(self, replica, execution):
     return self._get(
         '/replicas/%(replica_id)s/executions/%(execution_id)s' % {
             "replica_id": base.getid(replica),
             "execution_id": base.getid(execution)
         }, 'execution')
コード例 #26
0
 def cancel(self, migration, force=False):
     return self.client.post('/migrations/%s/actions' %
                             base.getid(migration),
                             json={'cancel': {
                                 'force': force
                             }})
コード例 #27
0
 def delete(self, replica, execution):
     return self._delete(
         '/replicas/%(replica_id)s/executions/%(execution_id)s' %
         {"replica_id": base.getid(replica),
          "execution_id": base.getid(execution)})
コード例 #28
0
 def delete(self, endpoint):
     return self._delete('/endpoints/%s' % base.getid(endpoint))
コード例 #29
0
 def update(self, endpoint, updated_values):
     data = {"endpoint": updated_values}
     return self._put('/endpoints/%s' % base.getid(endpoint), data,
                      'endpoint')
コード例 #30
0
 def list(self, replica):
     return self._list(
         '/replicas/%s/executions' % base.getid(replica), 'executions')
コード例 #31
0
 def get(self, replica, execution):
     return self._get(
         '/replicas/%(replica_id)s/executions/%(execution_id)s' %
         {"replica_id": base.getid(replica),
          "execution_id": base.getid(execution)},
         'execution')
コード例 #32
0
 def create(self, replica, shutdown_instances=False):
     data = {"execution": {"shutdown_instances": shutdown_instances}}
     return self._post(
         '/replicas/%s/executions' % base.getid(replica), data, 'execution')
コード例 #33
0
 def get(self, service):
     return self._get('/services/%s' % base.getid(service), 'service')
コード例 #34
0
 def delete(self, service):
     return self._delete('/services/%s' % base.getid(service))
コード例 #35
0
 def delete(self, replica):
     return self._delete('/replicas/%s' % base.getid(replica))
コード例 #36
0
 def delete(self, migration):
     return self._delete('/migrations/%s' % base.getid(migration))
コード例 #37
0
 def delete(self, replica, schedule):
     return self._delete(
         '/replicas/%(replica_id)s/schedules/%(schedule_id)s' %
         {"replica_id": base.getid(replica),
          "schedule_id": base.getid(schedule)})
コード例 #38
0
 def list(self, replica):
     return self._list('/replicas/%s/executions' % base.getid(replica),
                       'executions')
コード例 #39
0
 def get(self, replica, schedule):
     return self._get(
         '/replicas/%(replica_id)s/schedules/%(schedule_id)s' % {
             "replica_id": base.getid(replica),
             "schedule_id": base.getid(schedule)
         }, 'schedule')
コード例 #40
0
 def create(self, replica, shutdown_instances=False):
     data = {"execution": {"shutdown_instances": shutdown_instances}}
     return self._post('/replicas/%s/executions' % base.getid(replica),
                       data, 'execution')
コード例 #41
0
 def get(self, replica, schedule):
     return self._get(
         '/replicas/%(replica_id)s/schedules/%(schedule_id)s' %
         {"replica_id": base.getid(replica),
          "schedule_id": base.getid(schedule)},
         'schedule')
コード例 #42
0
 def update(self, endpoint, updated_values):
     data = {
         "endpoint": updated_values
     }
     return self._put(
         '/endpoints/%s' % base.getid(endpoint), data, 'endpoint')
コード例 #43
0
 def validate_connection(self, endpoint):
     data = self.client.post(
         '/endpoints/%s/actions' % base.getid(endpoint),
         json={'validate-connection': None}).json()
     validate_data = data["validate-connection"]
     return validate_data.get("valid"), validate_data.get("message")
コード例 #44
0
 def delete(self, migration):
     return self._delete('/migrations/%s' % base.getid(migration))
コード例 #45
0
 def delete(self, replica, schedule):
     return self._delete(
         '/replicas/%(replica_id)s/schedules/%(schedule_id)s' % {
             "replica_id": base.getid(replica),
             "schedule_id": base.getid(schedule)
         })
コード例 #46
0
 def get(self, replica):
     return self._get('/replicas/%s' % base.getid(replica), 'replica')
コード例 #47
0
 def delete(self, endpoint):
     return self._delete('/endpoints/%s' % base.getid(endpoint))
コード例 #48
0
 def get(self, endpoint):
     return self._get('/endpoints/%s' % base.getid(endpoint), 'endpoint')
コード例 #49
0
 def get(self, endpoint, instance_id):
     url = '/endpoints/%s/instances/%s' % (
         base.getid(endpoint), instance_id)
     return self._get(url, 'instance')
コード例 #50
0
 def update(self, service, updated_values):
     data = {
         "service": updated_values
     }
     return self._put(
         '/services/%s' % base.getid(service), data, 'service')
コード例 #51
0
 def get(self, migration):
     return self._get('/migrations/%s' % base.getid(migration), 'migration')
コード例 #52
0
 def get(self, replica):
     return self._get('/replicas/%s' % base.getid(replica), 'replica')
コード例 #53
0
 def cancel(self, replica, execution, force=False):
     return self.client.post(
         '/replicas/%(replica_id)s/executions/%(execution_id)s/actions' %
         {"replica_id": base.getid(replica),
          "execution_id": base.getid(execution)},
         json={'cancel': {'force': force}})