示例#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
         }})
    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')
    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')
    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)
    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)
 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")
 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')
 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')
    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')
 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')
 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')
    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')
    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')
    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')
    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')
    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')
    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))
 def cancel(self, migration, force=False):
     return self.client.post(
         '/migrations/%s/actions' % base.getid(migration),
         json={'cancel': {'force': force}})
 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
                             }})
 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')
 def list(self, replica):
     return self._list(
         '/replicas/%s/executions' % base.getid(replica), 'executions')
 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')
 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))
 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')
 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')
 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')
 def update(self, endpoint, updated_values):
     data = {
         "endpoint": updated_values
     }
     return self._put(
         '/endpoints/%s' % base.getid(endpoint), data, 'endpoint')
 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")
 def delete(self, migration):
     return self._delete('/migrations/%s' % base.getid(migration))
 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')
 def delete(self, endpoint):
     return self._delete('/endpoints/%s' % base.getid(endpoint))
 def get(self, endpoint):
     return self._get('/endpoints/%s' % base.getid(endpoint), 'endpoint')
 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')
 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}})