def __init__(self, *args, **kwargs): self.jail = None if kwargs and 'jail' in kwargs: self.jail = kwargs.pop('jail') super(NullMountPointForm, self).__init__(*args, **kwargs) if kwargs and 'instance' in kwargs: self.instance = kwargs.pop('instance') if not self.jail: self.jail = Jails.objects.filter( jail_host=self.instance.jail )[0] self.jc = JailsConfiguration.objects.order_by("-id")[0] self.fields['jail'] = forms.ChoiceField( label=_("Jail"), choices=(), widget=forms.Select(attrs={'class': 'required'}), ) if self.jail: self.fields['jail'].initial = self.jail.jail_host self.fields['jail'].widget.attrs['readonly'] = True try: clean_path_execbit(self.jc.jc_path) except forms.ValidationError, e: self.errors['__all__'] = self.error_class(e.messages)
def __init__(self, *args, **kwargs): self.jail = None if kwargs and "jail" in kwargs: self.jail = kwargs.pop("jail") super(JailMountPointForm, self).__init__(*args, **kwargs) self._full = None if kwargs and "instance" in kwargs: self.instance = kwargs.pop("instance") if not self.jail and self.instance.id: try: self.jail = Jails.objects.filter(jail_host=self.instance.jail)[0] except: pass self.jc = JailsConfiguration.objects.order_by("-id")[0] self.fields["jail"] = forms.ChoiceField( label=_("Jail"), choices=(), widget=forms.Select(attrs={"class": "required"}) ) if self.jail: self.fields["jail"].initial = self.jail.jail_host self.fields["jail"].widget.attrs["readonly"] = True jail_path = "%s/%s" % (self.jc.jc_path, self.jail.jail_host) self.fields["destination"].widget.attrs["root"] = jail_path try: clean_path_execbit(self.jc.jc_path) except forms.ValidationError, e: self.errors["__all__"] = self.error_class(e.messages)
def __init__(self, *args, **kwargs): self.jail = None if kwargs and 'jail' in kwargs: self.jail = kwargs.pop('jail') super(NullMountPointForm, self).__init__(*args, **kwargs) if kwargs and 'instance' in kwargs: self.instance = kwargs.pop('instance') if not self.jail: self.jail = Jails.objects.filter( jail_host=self.instance.jail)[0] self.jc = JailsConfiguration.objects.order_by("-id")[0] self.fields['jail'] = forms.ChoiceField( label=_("Jail"), choices=(), widget=forms.Select(attrs={'class': 'required'}), ) if self.jail: self.fields['jail'].initial = self.jail.jail_host self.fields['jail'].widget.attrs['readonly'] = True try: clean_path_execbit(self.jc.jc_path) except forms.ValidationError, e: self.errors['__all__'] = self.error_class(e.messages)
def __init__(self, *args, **kwargs): self.jail = None if kwargs and 'jail' in kwargs: self.jail = kwargs.pop('jail') super(JailMountPointForm, self).__init__(*args, **kwargs) self._full = None if kwargs and 'instance' in kwargs: self.instance = kwargs.pop('instance') if not self.jail and self.instance.id: try: self.jail = Jails.objects.filter( jail_host=self.instance.jail )[0] except: pass self.jc = JailsConfiguration.objects.order_by("-id")[0] self.fields['jail'] = forms.ChoiceField( label=_("Jail"), choices=(), widget=forms.Select(attrs={'class': 'required'}), ) if self.jail: self.fields['jail'].initial = self.jail.jail_host self.fields['jail'].widget.attrs['readonly'] = True jail_path = "%s/%s" % (self.jc.jc_path, self.jail.jail_host) self.fields['destination'].widget.attrs['root'] = jail_path try: clean_path_execbit(self.jc.jc_path) except forms.ValidationError as e: self.errors['__all__'] = self.error_class(e.messages) pjlist = [] try: wlist = Warden().cached_list() except: wlist = [] for wj in wlist: pjlist.append(wj[WARDEN_KEY_HOST]) self.fields['jail'].choices = [('', '')] + [(pj, pj) for pj in pjlist] self.fields['jail'].widget.attrs['onChange'] = ( 'addStorageJailChange(this);' ) self.fields['mpjc_path'].widget = forms.widgets.HiddenInput() self.fields['mpjc_path'].initial = self.jc.jc_path if self.instance.id: self.fields['mounted'].initial = self.instance.mounted else: self.fields['mounted'].widget = forms.widgets.HiddenInput()
def __init__(self, *args, **kwargs): self.jail = None if kwargs and 'jail' in kwargs: self.jail = kwargs.pop('jail') super(NullMountPointForm, self).__init__(*args, **kwargs) if kwargs and 'instance' in kwargs: self.instance = kwargs.pop('instance') self.jc = JailsConfiguration.objects.order_by("-id")[0] if self.jail: self.fields['jail'].initial = self.jail.jail_host self.fields['jail'].widget.attrs['readonly'] = True self.fields['jail'].widget.attrs['class'] = ( 'dijitDisabled dijitTextBoxDisabled' 'dijitValidationTextBoxDisabled' ) self.jc = JailsConfiguration.objects.order_by("-id")[0] jail_path = "%s/%s" % (self.jc.jc_path, self.jail.jail_host) self.fields['destination'].widget.attrs['root'] = (jail_path) else: self.fields['jail'] = forms.ChoiceField( label=_("Jail"), choices=(), widget=forms.Select(attrs={'class': 'required'}), ) try: clean_path_execbit(self.jc.jc_path) except forms.ValidationError, e: self.errors['__all__'] = self.error_class(e.messages) pjlist = [] try: wlist = Warden().list() except: wlist = [] for wj in wlist: pjlist.append(wj[WARDEN_KEY_HOST]) self.fields['jail'].choices = [(pj, pj) for pj in pjlist] self.fields['jail'].widget.attrs['onChange'] = ( 'addStorageJailChange(this);' ) if pjlist: jail_path = "%s/%s" % (self.jc.jc_path, pjlist[0]) self.fields['destination'].widget.attrs['root'] = jail_path
def __init__(self, *args, **kwargs): self.jail = None if kwargs and kwargs.has_key('jail'): self.jail = kwargs.pop('jail') super(NullMountPointForm, self).__init__(*args, **kwargs) if kwargs and kwargs.has_key('instance'): self.instance = kwargs.pop('instance') if self.jail: self.fields['jail'].initial = self.jail.jail_host self.fields['jail'].widget.attrs = { 'readonly': True, 'class': ( 'dijitDisabled dijitTextBoxDisabled' 'dijitValidationTextBoxDisabled' ), } self.jc = JailsConfiguration.objects.order_by("-id")[0] jail_path = "%s/%s" % (self.jc.jc_path, self.jail.jail_host) self.fields['destination'].widget.attrs['root'] = (jail_path) else: self.fields['jail'] = forms.ChoiceField( label=_("Jail"), choices=(), widget=forms.Select(attrs={'class': 'required'}), ) jc = JailsConfiguration.objects.order_by("-id")[0] try: clean_path_execbit(jc.jc_path) except forms.ValidationError, e: self.errors['__all__'] = self.error_class(e.messages) pjlist = [] wlist = Warden().list() for wj in wlist: if wj[WARDEN_KEY_STATUS] == WARDEN_STATUS_RUNNING: pjlist.append(wj[WARDEN_KEY_HOST]) self.fields['jail'].choices = [(pj, pj) for pj in pjlist ]
def __init__(self, *args, **kwargs): self.jail = None if kwargs and kwargs.has_key("jail"): self.jail = kwargs.pop("jail") super(PBIUploadForm, self).__init__(*args, **kwargs) if not self.jail: jc = JailsConfiguration.objects.order_by("-id")[0] try: clean_path_execbit(jc.jc_path) except forms.ValidationError, e: self.errors["__all__"] = self.error_class(e.messages) pjlist = [] wlist = Warden().list() for wj in wlist: if wj[WARDEN_KEY_TYPE] == WARDEN_TYPE_PLUGINJAIL and wj[WARDEN_KEY_STATUS] == WARDEN_STATUS_RUNNING: pjlist.append(wj[WARDEN_KEY_HOST]) self.fields["pjail"].choices = [(pj, pj) for pj in pjlist]
def __init__(self, *args, **kwargs): self.jail = None if kwargs and kwargs.has_key('jail'): self.jail = kwargs.pop('jail') super(PBIUploadForm, self).__init__(*args, **kwargs) if not self.jail: jc = JailsConfiguration.objects.order_by("-id")[0] try: clean_path_execbit(jc.jc_path) except forms.ValidationError, e: self.errors['__all__'] = self.error_class(e.messages) pjlist = [] wlist = Warden().list() for wj in wlist: if wj[WARDEN_KEY_TYPE] == WARDEN_TYPE_PLUGINJAIL and \ wj[WARDEN_KEY_STATUS] == WARDEN_STATUS_RUNNING: pjlist.append(wj[WARDEN_KEY_HOST]) self.fields['pjail'].choices = [(pj, pj) for pj in pjlist]