def delete_snapshot(self, snapshot):
     self.authenticate_user()
     obj = Snapshot(self.configuration.vipr_hostname, self.configuration.vipr_port)
     snapshotname = snapshot['name']
     try:
         vol = snapshot['volume']
         volumename = self._get_volume_name(vol)
         projectname = self.configuration.vipr_project
         tenantname = self.configuration.vipr_tenant
         storageresType = 'block'
         storageresTypename = 'volumes'
         resourceUri = obj.storageResource_query(storageresType, fileshareName=None, volumeName=volumename, cgName=None, project=projectname, tenant=tenantname)
         if resourceUri is None:
             LOG.info("Snapshot " + snapshotname + " is not found; snapshot deletion is considered successful.")
         else:
             obj.snapshot_delete(storageresType, storageresTypename, resourceUri, snapshotname, sync=True)
         return
     except SOSError as e:
         if (e.err_code == SOSError.SOS_FAILURE_ERR):
             raise SOSError(SOSError.SOS_FAILURE_ERR, "Snapshot " + snapshotname + ": Delete Failed\n")
         else:
             raise e
    def create_snapshot(self, snapshot):
        self.authenticate_user()
        obj = Snapshot(self.configuration.vipr_hostname, self.configuration.vipr_port)
        try:    
            snapshotname = snapshot['name']
            vol = snapshot['volume']
            volumename = self._get_volume_name(vol)
            projectname = self.configuration.vipr_project
            tenantname = self.configuration.vipr_tenant
            storageresType = 'block'
            storageresTypename = 'volumes'
            resourceUri = obj.storageResource_query(storageresType, fileshareName=None, volumeName=volumename, cgName=None, project=projectname, tenant=tenantname)
            inactive = False
            rptype = None
            sync = True
            obj.snapshot_create(storageresType, storageresTypename, resourceUri, snapshotname, inactive, rptype, sync)
            return

        except SOSError as e:
            if (e.err_code == SOSError.SOS_FAILURE_ERR):
                raise SOSError(SOSError.SOS_FAILURE_ERR, "Snapshot: " + snapshotname + ", Create Failed\n" + e.err_text)
            else:
                raise e