示例#1
0
 def done(self, *args, **kwargs):
     newplugin = []
     pjail = self.cleaned_data.get('pjail')
     jail = None
     if not pjail:
         # FIXME: Better base name, using pbi_info
         try:
             jail = new_default_plugin_jail("customplugin")
         except MiddlewareError, e:
             raise e
         except Exception, e:
             raise MiddlewareError(e)
示例#2
0
 def done(self, *args, **kwargs):
     newplugin = []
     pjail = self.cleaned_data.get('pjail')
     jail = None
     if not pjail:
         #FIXME: Better base name, using pbi_info
         jail = new_default_plugin_jail("customplugin")
         pjail = jail.jail_host
     if notifier().install_pbi(pjail, newplugin):
         newplugin = newplugin[0]
         notifier()._restart_plugins(
             newplugin.plugin_jail,
             newplugin.plugin_name,
         )
     elif jail:
         jail.delete()
示例#3
0
 def done(self, *args, **kwargs):
     newplugin = []
     pjail = self.cleaned_data.get('pjail')
     jail = None
     if not pjail:
         #FIXME: Better base name, using pbi_info
         jail = new_default_plugin_jail("customplugin")
         pjail = jail.jail_host
     if notifier().install_pbi(pjail, newplugin):
         newplugin = newplugin[0]
         notifier()._restart_plugins(
             newplugin.plugin_jail,
             newplugin.plugin_name,
         )
     elif jail:
         jail.delete()
示例#4
0
文件: forms.py 项目: binzyw/freenas
    def done(self, *args, **kwargs):
        newplugin = []
        pjail = self.cleaned_data.get('pjail')
        jail = None
        if not pjail:
            # FIXME: Better base name, using pbi_info
            try:
                jail = new_default_plugin_jail("customplugin")
            except MiddlewareError as e:
                raise e
            except Exception as e:
                raise MiddlewareError(str(e))

            pjail = jail.jail_host
        if notifier().install_pbi(pjail, newplugin):
            newplugin = newplugin[0]
            notifier()._restart_plugins(
                jail=newplugin.plugin_jail,
                plugin=newplugin.plugin_name,
            )
        elif jail:
            jail.delete()
示例#5
0
    def done(self, *args, **kwargs):
        newplugin = []
        pjail = self.cleaned_data.get('pjail')
        jail = None
        if not pjail:
            # FIXME: Better base name, using pbi_info
            try:
                jail = new_default_plugin_jail("customplugin")
            except MiddlewareError as e:
                raise e
            except Exception as e:
                raise MiddlewareError(str(e))

            pjail = jail.jail_host
        if notifier().install_pbi(pjail, newplugin):
            newplugin = newplugin[0]
            notifier()._restart_plugins(
                jail=newplugin.plugin_jail,
                plugin=newplugin.plugin_name,
            )
        elif jail:
            jail.delete()
示例#6
0
            plugin = p
            break

    if not plugin:
        raise MiddlewareError(_("Invalid plugin"))

    if request.method == "POST":

        plugin_upload_path = notifier().get_plugin_upload_path()
        notifier().change_upload_location(plugin_upload_path)

        if not plugin.download("/var/tmp/firmware/pbifile.pbi"):
            raise MiddlewareError(_("Failed to download plugin"))

        try:
            jail = new_default_plugin_jail(plugin.unixname)
        except Exception as e:
            raise MiddlewareError(e)

        newplugin = []
        if notifier().install_pbi(jail.jail_host, newplugin):
            newplugin = newplugin[0]
            notifier()._restart_plugins(
                jail=newplugin.plugin_jail,
                plugin=newplugin.plugin_name,
            )
        else:
            jail.delete()

        return JsonResp(
            request,
示例#7
0
文件: views.py 项目: CsMAr51/freenas
        if p.id == int(oid):
            plugin = p
            break

    if not plugin:
        raise MiddlewareError(_("Invalid plugin"))

    if request.method == "POST":

        plugin_upload_path = notifier().get_plugin_upload_path()
        notifier().change_upload_location(plugin_upload_path)

        if not plugin.download("/var/tmp/firmware/pbifile.pbi"):
            raise MiddlewareError(_("Failed to download plugin"))

        jail = new_default_plugin_jail(plugin.unixname)

        newplugin = []
        if notifier().install_pbi(jail.jail_host, newplugin):
            newplugin = newplugin[0]
            notifier()._restart_plugins(
                newplugin.plugin_jail,
                newplugin.plugin_name,
            )
        else:
            jail.delete()

        return JsonResp(
            request,
            message=_("Plugin successfully installed"),
            events=['reloadHttpd()'],
示例#8
0
文件: views.py 项目: binzyw/freenas
def install_available(request, oid):

    try:
        jc = JailsConfiguration.objects.all()[0]
    except IndexError:
        jc = JailsConfiguration.objects.create()

    try:
        if not jail_path_configured():
            jail_auto_configure()

        if not jc.jc_ipv4_dhcp:
            addrs = guess_addresses()
            if not addrs['high_ipv4']:
                raise MiddlewareError(_("No available IP addresses"))

    except MiddlewareError as e:
        return render(request, "plugins/install_error.html", {
            'error': e.value,
        })

    if os.path.exists("/tmp/.plugin_upload_update"):
        os.unlink("/tmp/.plugin_upload_update")
    if os.path.exists(PROGRESS_FILE):
        os.unlink(PROGRESS_FILE)

    plugin = None
    for p in availablePlugins.get_remote(cache=True):
        if p.id == oid:
            plugin = p
            break

    if not plugin:
        raise MiddlewareError(_("Invalid plugin"))

    if request.method == "POST":

        plugin_upload_path = notifier().get_plugin_upload_path()
        notifier().change_upload_location(plugin_upload_path)

        if not plugin.download("/var/tmp/firmware/pbifile.pbi"):
            raise MiddlewareError(_("Failed to download plugin"))

        try:
            jail = new_default_plugin_jail(plugin.unixname)
        except IOError as e:
            raise MiddlewareError(str(e))
        except MiddlewareError as e:
            raise e
        except Exception as e:
            raise MiddlewareError(str(e))

        newplugin = []
        if notifier().install_pbi(jail.jail_host, newplugin):
            newplugin = newplugin[0]
            notifier()._restart_plugins(
                jail=newplugin.plugin_jail,
                plugin=newplugin.plugin_name,
            )
        else:
            jail.delete()

        return JsonResp(
            request,
            message=_("Plugin successfully installed"),
            events=['reloadHttpd()'],
        )

    return render(request, "plugins/available_install.html", {
        'plugin': plugin,
    })
示例#9
0
def install_available(request, oid):

    try:
        jc = JailsConfiguration.objects.all()[0]
    except IndexError:
        jc = JailsConfiguration.objects.create()

    try:
        if not jail_path_configured():
            jail_auto_configure()

        if not jc.jc_ipv4_dhcp:
            addrs = guess_addresses()
            if not addrs['high_ipv4']:
                raise MiddlewareError(_("No available IP addresses"))

    except MiddlewareError as e:
        return render(request, "plugins/install_error.html", {
            'error': e.value,
        })

    if os.path.exists("/tmp/.plugin_upload_update"):
        os.unlink("/tmp/.plugin_upload_update")
    if os.path.exists(PROGRESS_FILE):
        os.unlink(PROGRESS_FILE)

    plugin = None
    for p in availablePlugins.get_remote(cache=True):
        if p.id == oid:
            plugin = p
            break

    if not plugin:
        raise MiddlewareError(_("Invalid plugin"))

    if request.method == "POST":

        plugin_upload_path = notifier().get_plugin_upload_path()
        notifier().change_upload_location(plugin_upload_path)

        if not plugin.download("/var/tmp/firmware/pbifile.pbi"):
            raise MiddlewareError(_("Failed to download plugin"))

        try:
            jail = new_default_plugin_jail(plugin.unixname)
        except IOError as e:
            raise MiddlewareError(str(e))
        except MiddlewareError as e:
            raise e
        except Exception as e:
            raise MiddlewareError(str(e))

        newplugin = []
        if notifier().install_pbi(jail.jail_host, newplugin):
            newplugin = newplugin[0]
            notifier()._restart_plugins(
                jail=newplugin.plugin_jail,
                plugin=newplugin.plugin_name,
            )
        else:
            jail.delete()

        return JsonResp(
            request,
            message=_("Plugin successfully installed"),
            events=['reloadHttpd()'],
        )

    return render(request, "plugins/available_install.html", {
        'plugin': plugin,
    })