Ejemplo n.º 1
0
 def create_snapshot(self):
     ''' create ONTAP snapshot for a volume '''
     args = self.args
     self.check_args(["snapshot_name"])
     api_credentials = {
         'api_server': args.api,
         'username': args.apiuser,
         'password': args.apipass
     }
     ontap = OntapService(api_credentials, args.svm_name, args.aggr_name)
     status = ontap.create_snapshot(args.vol_name, args.snapshot_name)
     print("Create snapshot", status)
Ejemplo n.º 2
0
 def create_clone(self):
     ''' API service call to clone a snapshot, or use an existing clone '''
     args = self.args
     self.check_args(["clone_name", "snapshot_name"])
     api_credentials = {
         'api_server': args.api,
         'username': args.apiuser,
         'password': args.apipass
     }
     ontap = OntapService(api_credentials, args.svm_name, args.aggr_name)
     status, vol_size = ontap.create_clone(args.vol_name, args.uid,
                                           args.gid, args.clone_name,
                                           args.snapshot_name)
     print("Create clone", status, vol_size)
Ejemplo n.º 3
0
 def create_volume(self):
     ''' API service call to create a new volume, or use an existing volume '''
     args = self.args
     self.check_args(["vol_size"])
     api_credentials = {
         'api_server': args.api,
         'username': args.apiuser,
         'password': args.apipass
     }
     ontap = OntapService(api_credentials, args.svm_name, args.aggr_name)
     status, vol_size = ontap.create_volume(args.vol_name, args.vol_size,
                                            args.uid, args.gid,
                                            args.export_policy)
     print("Create volume", status, vol_size)
Ejemplo n.º 4
0
 def delete_volume(self):
     ''' unmount, offline, and delete volume '''
     args = self.args
     api_credentials = {
         'api_server': args.api,
         'username': args.apiuser,
         'password': args.apipass
     }
     ontap = OntapService(api_credentials, args.svm_name, args.aggr_name)
     status = ontap.delete_volume(args.vol_name)
     print(status)
     if status[0]['status'] != "COMPLETED":
         print("Error failed to delete %s" % args.vol_name,
               status[0]['error_message'])
     else:
         print("Deleted %s" % args.vol_name)
Ejemplo n.º 5
0
 def delete_snapshot(self):
     ''' delete snapshot for a volume '''
     self.check_args(["snapshot_name"])
     args = self.args
     api_credentials = {
         'api_server': args.api,
         'username': args.apiuser,
         'password': args.apipass
     }
     ontap = OntapService(api_credentials, args.svm_name, args.aggr_name)
     status = ontap.delete_snapshot(args.vol_name, args.snapshot_name)
     if status[0]['status'] != "COMPLETED":
         print("Error failed to delete %s" % args.snapshot_name,
               status[0]['error_message'])
     else:
         print("Deleted %s" % args.snapshot_name)
Ejemplo n.º 6
0
 def list_volumes(self):
     ''' list all volumes for an aggregate '''
     args = self.args
     api_credentials = {
         'api_server': args.api,
         'username': args.apiuser,
         'password': args.apipass
     }
     ontap = OntapService(api_credentials, args.svm_name, args.aggr_name)
     try:
         volumes = ontap.get_volume_list()
     except IOError as exc:
         print("Error:", exc.errno, exc.strerror, exc.filename)
         return
     if volumes:
         for volume in volumes:
             if not volume['clone_parent_key']:
                 print(volume['name'])
     else:
         print("%s does not have any volume" % args.aggr_name)
Ejemplo n.º 7
0
 def list_snapshots(self):
     ''' list all snapshots for a volume '''
     self.check_args(["vol_name"])
     args = self.args
     api_credentials = {
         'api_server': args.api,
         'username': args.apiuser,
         'password': args.apipass
     }
     ontap = OntapService(api_credentials, args.svm_name, args.aggr_name)
     try:
         snapshots, error_message = ontap.get_snapshot_list(args.vol_name)
     except IOError as exc:
         if "Reason: Volume not online." in exc.filename:
             print("Error: %s is not online" % args.vol_name)
         else:
             print("Error:", exc.errno, exc.strerror, exc.filename)
         return
     if snapshots:
         print(snapshots)
     if not snapshots:
         print("%s does not have any snapshot" % args.vol_name)
     if error_message:
         print("ERROR:", error_message)