• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python notifier.notifier函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中metanasUI.middleware.notifier.notifier函数的典型用法代码示例。如果您正苦于以下问题:Python notifier函数的具体用法?Python notifier怎么用?Python notifier使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了notifier函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:33,代码来源:views.py


示例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)
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:59,代码来源:models.py


示例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()
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:8,代码来源:models.py


示例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")
开发者ID:RoozbehShafiee,项目名称:MetaNAS,代码行数:8,代码来源:models.py


示例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")
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:9,代码来源:forms.py


示例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")
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:10,代码来源:views.py


示例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})
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:12,代码来源:views.py


示例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,
    })
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:14,代码来源:views.py


示例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,
    })
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:14,代码来源:views.py


示例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
    })
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:50,代码来源:views.py


示例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,
    })
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:14,代码来源:views.py


示例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,
        })
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:14,代码来源:views.py


示例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
    })
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:48,代码来源:views.py


示例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})
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:34,代码来源:views.py


示例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,
    })
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:16,代码来源:views.py


示例16: plugin_install

def plugin_install(request):
    if request.method == "POST":
        pj = PluginsJail.objects.order_by("-id")[0]
        notifier().change_upload_location(pj.plugins_path)
        form = forms.PBIUploadForm(request.POST, request.FILES)
        if form.is_valid():
            form.done()
            return JsonResponse(message=_("Plugin successfully installed"), events=["reloadHttpd()"], enclosed=True)
        else:
            resp = render(request, "plugins/plugin_install.html", {"form": form})
            resp.content = "<html><body><textarea>" + resp.content + "</textarea></boby></html>"
            return resp
    else:
        form = forms.PBIUploadForm()

    return render(request, "plugins/plugin_install.html", {"form": form})
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:16,代码来源:views.py


示例17: wizard

def wizard(request):

    if request.method == "POST":

        form = forms.VolumeWizardForm(request.POST)
        if form.is_valid():
            form.done(request)
            return JsonResponse(message=_("Volume successfully added."))
        else:
            if 'volume_disks' in request.POST:
                disks = request.POST.getlist('volume_disks')
            else:
                disks = None
            zpoolfields = re.compile(r'zpool_(.+)')
            zfsextra = [(zpoolfields.search(i).group(1), i, request.POST.get(i)) \
                        for i in request.POST.keys() if zpoolfields.match(i)]

    else:
        form = forms.VolumeWizardForm()
        disks = []
        zfsextra = None
    return render(request, 'storage/wizard.html', {
        'form': form,
        'disks': disks,
        'zfsextra': zfsextra,
        'zfsversion': notifier().zfs_get_version(),
    })
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:27,代码来源:views.py


示例18: done

 def done(self, request, events):
     if self.instance._original_stg_guiprotocol != self.instance.stg_guiprotocol or \
         self.instance._original_stg_guiaddress != self.instance.stg_guiaddress or \
         self.instance._original_stg_guiport != self.instance.stg_guiport:
         if self.instance.stg_guiaddress == "0.0.0.0":
             address = request.META['HTTP_HOST'].split(':')[0]
         else:
             address = self.instance.stg_guiaddress
         newurl = "%s://%s" % (self.instance.stg_guiprotocol,
                                 address
                                 )
         if self.instance.stg_guiport != '':
             newurl += ":" + self.instance.stg_guiport
         if self.instance._original_stg_guiprotocol == 'http':
             notifier().start_ssl("nginx")
         events.append("restartHttpd('%s')" % newurl)
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:16,代码来源:forms.py


示例19: zvol_create

def zvol_create(request, volume_name):
    defaults = {'zvol_compression': 'inherit', }
    if request.method == 'POST':
        zvol_form = forms.ZVol_CreateForm(request.POST, vol_name=volume_name)
        if zvol_form.is_valid():
            props = {}
            cleaned_data = zvol_form.cleaned_data
            zvol_size = cleaned_data.get('zvol_size')
            zvol_name = "%s/%s" % (volume_name, cleaned_data.get('zvol_name'))
            zvol_compression = cleaned_data.get('zvol_compression')
            props['compression'] = str(zvol_compression)
            errno, errmsg = notifier().create_zfs_vol(name=str(zvol_name),
                size=str(zvol_size),
                props=props)
            if errno == 0:
                return JsonResponse(
                    message=_("ZFS Volume successfully added.")
                    )
            else:
                zvol_form.set_error(errmsg)
    else:
        zvol_form = forms.ZVol_CreateForm(initial=defaults,
            vol_name=volume_name)
    return render(request, 'storage/zvols.html', {
        'form': zvol_form,
        'volume_name': volume_name,
    })
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:27,代码来源:views.py


示例20: multipath_status_json

def multipath_status_json(request):

    multipaths = notifier().multipath_all()
    _id = 1
    items = []
    for mp in multipaths:
        children = []
        for cn in mp.consumers:
            items.append({
                'id': str(_id),
                'name': cn.devname,
                'status': cn.status,
                'type': 'consumer',
            })
            children.append({'_reference': str(_id)})
            _id += 1
        data = {
            'id': str(_id),
            'name': mp.devname,
            'status': mp.status,
            'type': 'root',
            'children': children,
        }
        items.append(data)
        _id += 1
    return HttpResponse(simplejson.dumps({
        'identifier': 'id',
        'label': 'name',
        'items': items,
    }, indent=2), content_type='application/json')
开发者ID:BillTheBest,项目名称:MetaNAS,代码行数:30,代码来源:views.py



注:本文中的metanasUI.middleware.notifier.notifier函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api.eval_object函数代码示例发布时间:2022-05-27
下一篇:
Python metallicity.printsafemulti函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap