本文整理汇总了Python中metanasUI.middleware.notifier.notifier函数的典型用法代码示例。如果您正苦于以下问题:Python notifier函数的具体用法?Python notifier怎么用?Python notifier使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了notifier函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: terminal
def terminal(request):
sid = int(request.GET.get("s", 0))
k = request.GET.get("k")
w = int(request.GET.get("w", 80))
h = int(request.GET.get("h", 24))
multiplex = MyServer("/var/run/webshell.sock")
alive = False
for i in range(3):
try:
alive = multiplex.proc_keepalive(sid, w, h)
break
except:
notifier().restart("webshell")
time.sleep(0.5)
try:
if alive:
if k:
multiplex.proc_write(sid, xmlrpclib.Binary(bytearray(str(k))))
time.sleep(0.002)
content_data = '<?xml version="1.0" encoding="UTF-8"?>' + multiplex.proc_dump(sid)
response = HttpResponse(content_data, content_type="text/xml")
return response
else:
response = HttpResponse("Disconnected")
response.status_code = 400
return response
except (KeyError, ValueError, IndexError):
response = HttpResponse("Invalid parameters")
response.status_code = 400
return response
示例2: _delete
def _delete(self, destroy=True, cascade=True):
"""
Some places reference a path which will not cascade delete
We need to manually find all paths within this volume mount point
"""
from metanasUI.services.models import iSCSITargetExtent
# TODO: This is ugly.
svcs = ('cifs', 'afp', 'nfs', 'iscsitarget')
reloads = (False, False, False, False)
n = notifier()
if cascade:
for mp in self.mountpoint_set.all():
reloads = map(sum, zip(reloads, mp.delete_attachments()))
zvols = n.list_zfs_vols(self.vol_name)
for zvol in zvols:
qs = iSCSITargetExtent.objects.filter(
iscsi_target_extent_path='zvol/' + zvol,
iscsi_target_extent_type='ZVOL')
if qs.exists():
if destroy:
retval = notifier().destroy_zfs_vol(zvol)
qs.delete()
reloads = map(sum, zip(reloads, (False, False, False, True)))
else:
for mp in self.mountpoint_set.all():
attachments = mp.has_attachments()
reloads = map(sum,
zip(reloads,
[len(attachments[svc]) for svc in svcs])
)
for (svc, dirty) in zip(svcs, reloads):
if dirty:
n.stop(svc)
n.detach_volume_swaps(self)
# Ghosts volumes, does not exists anymore but is in database
ghost = False
try:
status = n.get_volume_status(self.vol_name, self.vol_fstype)
ghost = status == 'UNKNOWN'
except:
ghost = True
if ghost:
pass
elif destroy:
n.destroy("volume", self)
else:
n.volume_detach(self.vol_name, self.vol_fstype)
return (svcs, reloads)
示例3: delete
def delete(self):
try:
if self.repl_lastsnapshot != "":
zfsname = self.repl_lastsnapshot.split('@')[0]
notifier().zfs_inherit_option(zfsname, 'metanas:state', True)
except:
pass
super(Replication, self).delete()
示例4: delete
def delete(self, using=None, reload=True):
if self.bsdgrp_builtin == True:
raise ValueError(_("Group %s is built-in and can not be "
"deleted!") % (self.bsdgrp_group))
notifier().user_deletegroup(self.bsdgrp_group.__str__())
super(bsdGroups, self).delete(using)
if reload:
notifier().reload("user")
示例5: save
def save(self):
user = models.bsdUsers.objects.get(id=self.userid)
models.bsdGroupMembership.objects.filter(bsdgrpmember_user=user).delete()
groupid_list = self.cleaned_data["bsduser_to_group"]
for groupid in groupid_list:
group = models.bsdGroups.objects.get(id=groupid)
m = models.bsdGroupMembership(bsdgrpmember_group=group, bsdgrpmember_user=user)
m.save()
notifier().reload("user")
示例6: config_restore
def config_restore(request):
if request.method == "POST":
request.session["allow_reboot"] = True
notifier().config_restore()
user = User.objects.all()[0]
backend = get_backends()[0]
user.backend = "%s.%s" % (backend.__module__, backend.__class__.__name__)
login(request, user)
return render(request, "system/config_ok2.html")
return render(request, "system/config_restore.html")
示例7: plugin_delete
def plugin_delete(request, plugin_id):
plugin_id = int(plugin_id)
plugin = models.Plugins.objects.get(id=plugin_id)
if request.method == "POST":
notifier()._stop_plugins(plugin.plugin_name)
if notifier().delete_pbi(plugin):
return JsonResp(request, message=_("Plugin successfully removed."), events=["reloadHttpd()"])
else:
return JsonResp(request, error=True, message=_("Unable to remove plugin."))
else:
return render(request, "plugins/plugin_confirm_delete.html", {"plugin": plugin})
示例8: zpool_scrub
def zpool_scrub(request, vid):
volume = models.Volume.objects.get(pk=vid)
pool = notifier().zpool_parse(volume.vol_name)
if request.method == "POST":
if request.POST.get("scrub") == 'IN_PROGRESS':
notifier().zfs_scrub(str(volume.vol_name), stop=True)
else:
notifier().zfs_scrub(str(volume.vol_name))
return JsonResponse(message=_("The scrub process has begun"))
return render(request, 'storage/scrub_confirm.html', {
'volume': volume,
'scrub': pool.scrub,
})
示例9: zpool_disk_remove
def zpool_disk_remove(request, vname, label):
volume = models.Volume.objects.get(vol_name=vname)
disk = notifier().label_to_disk(label)
if request.method == "POST":
notifier().zfs_remove_disk(volume, label)
return JsonResponse(message=_("Disk has been removed."))
return render(request, 'storage/disk_remove.html', {
'vname': vname,
'label': label,
'disk': disk,
})
示例10: zfsvolume_edit
def zfsvolume_edit(request, object_id):
mp = models.MountPoint.objects.get(pk=object_id)
volume_form = forms.ZFSVolume_EditForm(mp=mp)
if request.method == 'POST':
volume_form = forms.ZFSVolume_EditForm(request.POST, mp=mp)
if volume_form.is_valid():
volume = mp.mp_volume
volume_name = volume.vol_name
volume_name = mp.mp_path.replace("/mnt/", "")
if volume_form.cleaned_data["volume_refquota"] == "0":
volume_form.cleaned_data["volume_refquota"] = "none"
error, errors = False, {}
for attr in ('compression',
'atime',
'refquota',
'refreservation',
):
formfield = 'volume_%s' % attr
if volume_form.cleaned_data[formfield] == "inherit":
success, err = notifier().zfs_inherit_option(
volume_name,
attr,
)
else:
success, err = notifier().zfs_set_option(
volume_name,
attr,
volume_form.cleaned_data[formfield],
)
if not success:
error = True
errors[formfield] = err
if not error:
return JsonResponse(
message=_("Native dataset successfully edited.")
)
else:
for field, err in errors.items():
volume_form._errors[field] = volume_form.error_class([
err,
])
return render(request, 'storage/volume_edit.html', {
'mp': mp,
'form': volume_form
})
示例11: disk_detach
def disk_detach(request, vname, label):
volume = models.Volume.objects.get(vol_name=vname)
if request.method == "POST":
notifier().zfs_detach_disk(volume, label)
return JsonResponse(
message=_("Disk detach has been successfully done.")
)
return render(request, 'storage/disk_detach.html', {
'vname': vname,
'label': label,
})
示例12: snapshot_delete
def snapshot_delete(request, dataset, snapname):
snapshot = '%[email protected]%s' % (dataset, snapname)
if request.method == 'POST':
retval = notifier().destroy_zfs_dataset(path=str(snapshot))
if retval == '':
notifier().restart("collectd")
return JsonResponse(message=_("Snapshot successfully deleted."))
else:
return JsonResponse(error=True, message=retval)
else:
return render(request, 'storage/snapshot_confirm_delete.html', {
'snapname': snapname,
'dataset': dataset,
})
示例13: dataset_edit
def dataset_edit(request, dataset_name):
if request.method == 'POST':
dataset_form = forms.ZFSDataset_EditForm(request.POST, fs=dataset_name)
if dataset_form.is_valid():
if dataset_form.cleaned_data["dataset_quota"] == "0":
dataset_form.cleaned_data["dataset_quota"] = "none"
if dataset_form.cleaned_data["dataset_refquota"] == "0":
dataset_form.cleaned_data["dataset_refquota"] = "none"
error = False
errors = {}
for attr in ('compression',
'atime',
'reservation',
'refreservation',
'quota',
'refquota',
):
formfield = 'dataset_%s' % attr
if dataset_form.cleaned_data[formfield] == "inherit":
success, err = notifier().zfs_inherit_option(
dataset_name,
attr,
)
else:
success, err = notifier().zfs_set_option(
dataset_name,
attr,
dataset_form.cleaned_data[formfield],
)
error |= not success
if not success:
errors[formfield] = err
if not error:
return JsonResponse(message=_("Dataset successfully edited."))
else:
for field, err in errors.items():
dataset_form._errors[field] = dataset_form.error_class([
err,
])
else:
dataset_form = forms.ZFSDataset_EditForm(fs=dataset_name)
return render(request, 'storage/dataset_edit.html', {
'dataset_name': dataset_name,
'form': dataset_form
})
示例14: config_upload
def config_upload(request):
if request.method == "POST":
form = forms.ConfigUploadForm(request.POST, request.FILES)
variables = {"form": form}
if form.is_valid():
if not notifier().config_upload(request.FILES["config"]):
form._errors["__all__"] = form.error_class([_("The uploaded file is not valid.")])
else:
request.session["allow_reboot"] = True
return render(request, "system/config_ok.html", variables)
if request.GET.has_key("iframe"):
return HttpResponse(
"<html><body><textarea>"
+ render_to_string("system/config_upload.html", variables)
+ "</textarea></boby></html>"
)
else:
return render(request, "system/config_upload.html", variables)
else:
FIRMWARE_DIR = "/var/tmp/firmware"
if os.path.exists(FIRMWARE_DIR):
if os.path.islink(FIRMWARE_DIR):
os.unlink(FIRMWARE_DIR)
if os.path.isdir(FIRMWARE_DIR):
shutil.rmtree(FIRMWARE_DIR + "/")
os.mkdir(FIRMWARE_DIR)
os.chmod(FIRMWARE_DIR, 01777)
form = forms.ConfigUploadForm()
return render(request, "system/config_upload.html", {"form": form})
示例15: snapshot_delete_bulk
def snapshot_delete_bulk(request):
snaps = request.POST.get("snaps", None)
delete = request.POST.get("delete", None)
if snaps and delete == "true":
snap_list = snaps.split('|')
for snapshot in snap_list:
retval = notifier().destroy_zfs_dataset(path=str(snapshot))
if retval != '':
return JsonResponse(error=True, message=retval)
notifier().restart("collectd")
return JsonResponse(message=_("Snapshots successfully deleted."))
return render(request, 'storage/snapshot_confirm_delete_bulk.html', {
'snaps': snaps,
})