Ejemplo n.º 1
0
 def create_application(self, body):
     """Use REST application/applications san template to create one or more LUNs"""
     self.fail_if_uuid()
     api = '/application/applications'
     query = {'return_timeout': 30, 'return_records': 'true'}
     response, error = self.rest_api.post(api, body, params=query)
     return rrh.check_for_error_and_job_results(api, response, error,
                                                self.rest_api)
Ejemplo n.º 2
0
 def delete_application(self):
     """Use REST application/applications to delete app"""
     self.fail_if_no_uuid()
     api = '/application/applications/%s' % self.app_uuid
     query = {'return_timeout': 30}
     response, error = self.rest_api.delete(api, params=query)
     response, error = rrh.check_for_error_and_job_results(
         api, response, error, self.rest_api)
     self.app_uuid = None
     return response, error
Ejemplo n.º 3
0
 def patch_application(self, body):
     """Use REST application/applications san template to add one or more LUNs"""
     dummy, error = self.fail_if_no_uuid()
     if error is not None:
         return dummy, error
     uuid, error = self.get_application_uuid()
     if error is not None:
         return dummy, error
     api = '/application/applications/%s' % uuid
     query = {'return_timeout': 30, 'return_records': 'true'}
     response, error = self.rest_api.patch(api, body, params=query)
     return rrh.check_for_error_and_job_results(api, response, error, self.rest_api)
Ejemplo n.º 4
0
def patch_volume(rest_api, uuid, body, query=None):
    api = 'storage/volumes/%s' % uuid
    # see delete_volume for async and sync operations and status codes
    params = dict(return_timeout=30)
    if query is not None:
        params.update(query)
    response, error = rest_api.patch(api, body=body, params=params)
    response, error = rrh.check_for_error_and_job_results(api,
                                                          response,
                                                          error,
                                                          rest_api,
                                                          increment=20)
    return response, error
Ejemplo n.º 5
0
def post_flexcache(rest_api, body, query=None, timeout=180):
    api = 'storage/flexcache/flexcaches'
    # see delete_flexcache for async and sync operations and status codes
    params = None
    if timeout > 0:
        params = dict(return_timeout=min(30, timeout))
    if query is not None:
        params.update(query)
    response, error = rest_api.post(api, body=body, params=params)
    response, error = rrh.check_for_error_and_job_results(api,
                                                          response,
                                                          error,
                                                          rest_api,
                                                          increment=20,
                                                          timeout=timeout)
    return response, error
Ejemplo n.º 6
0
def delete_volume(rest_api, uuid):
    api = 'storage/volumes/%s' % uuid
    # without return_timeout, REST returns immediately with a 202 and a job link
    #   but the job status is 'running'
    # with return_timeout, REST returns quickly with a 200 and a job link
    #   and the job status is 'success'
    # I guess that if the operation was taking more than 30 seconds, we'd get a 202 with 'running'.
    # I tried with a value of 1 second, I got a 202, but the job showed as complete (success) :)
    query = dict(return_timeout=30)
    response, error = rest_api.delete(api, params=query)
    response, error = rrh.check_for_error_and_job_results(api,
                                                          response,
                                                          error,
                                                          rest_api,
                                                          increment=20)
    return response, error
Ejemplo n.º 7
0
def delete_flexcache(rest_api, uuid, timeout=180, return_timeout=5):
    api = 'storage/flexcache/flexcaches/%s' % uuid
    # without return_timeout, REST returns immediately with a 202 and a job link
    #   but the job status is 'running'
    # with return_timeout, REST returns quickly with a 200 and a job link
    #   and the job status is 'success'
    # I guess that if the operation was taking more than 30 seconds, we'd get a 202 with 'running'.
    # I tried with a value of 1 second, I got a 202, but the job showed as complete (success) :)

    # There may be a bug in ONTAP.  If return_timeout is >= 15, the call fails with uuid not found!
    # With 5, a job is queued, and completes with success.  With a big enough value, no job is
    # queued, and the API returns in around 15 seconds with a not found error.
    query = dict(return_timeout=return_timeout)
    response, error = rest_api.delete(api, params=query)
    response, error = rrh.check_for_error_and_job_results(api,
                                                          response,
                                                          error,
                                                          rest_api,
                                                          increment=10,
                                                          timeout=timeout)
    return response, error