Example #1
0
    def on_submit(self, event, params, vars=None):
        if params[0] == 'dlgEdit':
            v = vars.getvalue('value', '')
            if vars.getvalue('action', '') == 'OK':
                e = backend.Entry()
                if vars.getvalue('disk', 'custom') == 'custom':
                    e.src = vars.getvalue('src', 'none')
                else:
                    e.src = vars.getvalue('disk', 'none')
                e.dst = vars.getvalue('mp', 'none')
                e.fs_type = vars.getvalue('fs', 'none')
                e.options = vars.getvalue('opts', '')
                if vars.getvalue('bind', '0') == '1':
                    e.options += ',bind'
                if vars.getvalue('loop', '0') == '1':
                    e.options += ',loop'
                if vars.getvalue('ro', '0') == '1':
                    e.options += ',ro'
                e.options = e.options.strip(',')
                if e.options.startswith('none,'):
                    e.options = e.options[5:]

                e.dump_p = int(vars.getvalue('dump_p', '0'))
                e.fsck_p = int(vars.getvalue('fsck_p', '0'))
                try:
                    self.fstab[self._editing] = e
                except:
                    self.fstab.append(e)
                backend.save(self.fstab)
            self._editing = -1
Example #2
0
File: main.py Project: bneg/genesis
    def on_submit(self, event, params, vars=None):
        if params[0] == 'dlgEdit':
            v = vars.getvalue('value', '')
            if vars.getvalue('action', '') == 'OK':
                e = backend.Entry()
                if vars.getvalue('disk', 'custom') == 'custom':
                    e.src = vars.getvalue('src', 'none')
                else:
                    e.src = vars.getvalue('disk', 'none')
                e.dst = vars.getvalue('mp', 'none')
                e.fs_type = vars.getvalue('fs', 'none')
                e.options = vars.getvalue('opts', '')
                if vars.getvalue('bind', '0') == '1':
                    e.options += ',bind'
                if vars.getvalue('loop', '0') == '1':
                    e.options += ',loop'
                if vars.getvalue('ro', '0') == '1':
                    e.options += ',ro'
                e.options = e.options.strip(',')
                if e.options.startswith('none,'):
                    e.options = e.options[5:]

                e.dump_p = int(vars.getvalue('dump_p', '0'))
                e.fsck_p = int(vars.getvalue('fsck_p', '0'))
                try:
                    self.fstab[self._editing] = e
                except:
                    self.fstab.append(e)
                backend.save(self.fstab)
            self._editing = -1
Example #3
0
 def on_click(self, event, params, vars=None):
     if params[0] == 'add':
         self._editing = len(self.fstab)
     if params[0] == 'edit':
         self._editing = int(params[1])
     if params[0] == 'del':
         self.fstab.pop(int(params[1]))
         backend.save(self.fstab)
Example #4
0
File: main.py Project: bneg/genesis
 def on_click(self, event, params, vars=None):
     if params[0] == 'add':
         self._editing = len(self.fstab)
     if params[0] == 'edit':
         self._editing = int(params[1])
     if params[0] == 'del':
         self.fstab.pop(int(params[1]))
         backend.save(self.fstab)
Example #5
0
 def on_submit(self, event, params, vars = None):
     if params[0] == 'dlgEdit':
         v = vars.getvalue('value', '')
         if vars.getvalue('action', '') == 'OK':
             h = backend.Host()
             h.ip = vars.getvalue('ip', 'none')
             h.name = vars.getvalue('name', 'none')
             h.aliases = vars.getvalue('aliases', '')
             try:
                 self.hosts[self._editing] = h
             except:
                 self.hosts.append(h)
             backend.save(self.hosts)
         self._editing = -1
Example #6
0
 def on_click(self, event, params, vars=None):
     if params[0] == 'adisk':
         self._tab = 0
         self._add = 'reg'
     if params[0] == 'aedisk':
         self._tab = 0
         self._add = 'enc'
     if params[0] == 'add':
         self._editing = len(self.fstab)
     if params[0] == 'edit':
         self._editing = int(params[1])
     if params[0] == 'del':
         self.fstab.pop(int(params[1]))
         backend.save(self.fstab)
     if params[0] == 'ecvd':
         self._enc = self._vdevs[int(params[1])]
     if params[0] == 'md':
         self._tab = 1
         try:
             self._fsc.mount(self._devs[int(params[1])])
             self.put_message('info', 'Disk mounted successfully')
         except Exception, e:
             self.put_message('err', str(e))
Example #7
0
 def on_click(self, event, params, vars=None):
     if params[0] == 'adisk':
         self._tab = 0
         self._add = 'reg'
     if params[0] == 'aedisk':
         self._tab = 0
         self._add = 'enc'
     if params[0] == 'add':
         self._editing = len(self.fstab)
     if params[0] == 'edit':
         self._editing = int(params[1])
     if params[0] == 'del':
         self.fstab.pop(int(params[1]))
         backend.save(self.fstab)
     if params[0] == 'ecvd':
         self._enc = self._vdevs[int(params[1])]
     if params[0] == 'md':
         self._tab = 1
         try:
             self._fsc.mount(self._devs[int(params[1])])
             self.put_message('info', 'Disk mounted successfully')
         except Exception, e:
             self.put_message('err', str(e))
Example #8
0
    def on_submit(self, event, params, vars=None):
        if params[0] == 'dlgAdd':
            if vars.getvalue('action', '') == 'OK':
                name = vars.getvalue('addname', '')
                size = vars.getvalue('addsize', '')
                passwd = vars.getvalue('passwd', '')
                if not name or not size:
                    self.put_message('err', 'Must choose a name and size')
                elif name in [x.name for x in self._vdevs]:
                    self.put_message(
                        'err',
                        'You already have a virtual disk with that name')
                elif re.search('\.|-|`|\\\\|\/|[ ]', name):
                    self.put_message(
                        'err',
                        'Disk name must not contain spaces, dots, dashes or special characters'
                    )
                elif not can_be_int(size):
                    self.put_message('err',
                                     'Size must be a number in megabytes')
                elif self._add == 'enc' and not passwd:
                    self.put_message('err', 'Must choose a password')
                elif self._add == 'enc' and passwd != vars.getvalue(
                        'passwdb', ''):
                    self.put_message('err', 'Passwords must match')
                elif self._add == 'enc':
                    x = self._fsc.add_vdisk(name, size)
                    self._fsc.encrypt_vdisk(x, passwd, mount=True)
                else:
                    self._fsc.add_vdisk(name, size, mount=True)
            self._add = None
        if params[0] == 'dlgEdit':
            v = vars.getvalue('value', '')
            if vars.getvalue('action', '') == 'OK':
                e = backend.Entry()
                if vars.getvalue('disk', 'custom') == 'custom':
                    e.src = vars.getvalue('src', 'none')
                else:
                    e.src = vars.getvalue('disk', 'none')
                e.dst = vars.getvalue('mp', 'none')
                e.fs_type = vars.getvalue('fs', 'none')
                e.options = vars.getvalue('opts', '')
                if vars.getvalue('bind', '0') == '1':
                    e.options += ',bind'
                if vars.getvalue('loop', '0') == '1':
                    e.options += ',loop'
                if vars.getvalue('ro', '0') == '1':
                    e.options += ',ro'
                e.options = e.options.strip(',')
                if e.options.startswith('none,'):
                    e.options = e.options[5:]

                e.dump_p = int(vars.getvalue('dump_p', '0'))
                e.fsck_p = int(vars.getvalue('fsck_p', '0'))
                try:
                    self.fstab[self._editing] = e
                except:
                    self.fstab.append(e)
                backend.save(self.fstab)
            self._editing = -1
        if params[0] == 'dlgAuth':
            if vars.getvalue('action', '') == 'OK':
                try:
                    self._fsc.mount(self._auth,
                                    vars.getvalue('authpasswd', ''))
                    self.put_message(
                        'info',
                        'Virtual disk decrypted and mounted successfully')
                except Exception, e:
                    self.put_message('err', str(e))
                self._auth = None
Example #9
0
    def on_submit(self, event, params, vars=None):
        if params[0] == 'dlgAdd':
            if vars.getvalue('action', '') == 'OK':
                name = vars.getvalue('addname', '')
                size = vars.getvalue('addsize', '')
                passwd = vars.getvalue('passwd', '')
                if not name or not size:
                    self.put_message('err', 'Must choose a name and size')
                elif name in [x.name for x in self._vdevs]:
                    self.put_message('err', 'You already have a virtual disk with that name')
                elif re.search('\.|-|`|\\\\|\/|[ ]', name):
                    self.put_message('err', 'Disk name must not contain spaces, dots, dashes or special characters')
                elif not can_be_int(size):
                    self.put_message('err', 'Size must be a number in megabytes')
                elif self._add == 'enc' and not passwd:
                    self.put_message('err', 'Must choose a password')
                elif self._add == 'enc' and passwd != vars.getvalue('passwdb', ''):
                    self.put_message('err', 'Passwords must match')
                elif self._add == 'enc':
                    x = self._fsc.add_vdisk(name, size)
                    self._fsc.encrypt_vdisk(x, passwd, mount=True)
                else:
                    self._fsc.add_vdisk(name, size, mount=True)
            self._add = None
        if params[0] == 'dlgEdit':
            v = vars.getvalue('value', '')
            if vars.getvalue('action', '') == 'OK':
                e = backend.Entry()
                if vars.getvalue('disk', 'custom') == 'custom':
                    e.src = vars.getvalue('src', 'none')
                else:
                    e.src = vars.getvalue('disk', 'none')
                e.dst = vars.getvalue('mp', 'none')
                e.fs_type = vars.getvalue('fs', 'none')
                e.options = vars.getvalue('opts', '')
                if vars.getvalue('bind', '0') == '1':
                    e.options += ',bind'
                if vars.getvalue('loop', '0') == '1':
                    e.options += ',loop'
                if vars.getvalue('ro', '0') == '1':
                    e.options += ',ro'
                e.options = e.options.strip(',')
                if e.options.startswith('none,'):
                    e.options = e.options[5:]

                e.dump_p = int(vars.getvalue('dump_p', '0'))
                e.fsck_p = int(vars.getvalue('fsck_p', '0'))
                try:
                    self.fstab[self._editing] = e
                except:
                    self.fstab.append(e)
                backend.save(self.fstab)
            self._editing = -1
        if params[0] == 'dlgAuth':
            if vars.getvalue('action', '') == 'OK':
                try:
                    self._fsc.mount(self._auth, vars.getvalue('authpasswd', ''))
                    self.put_message('info', 'Virtual disk decrypted and mounted successfully')
                except Exception, e:
                    self.put_message('err', str(e))
                self._auth = None