def add_introducer(introducer): """Add an introducer to the storage node's list of introducers. Param introducer must be a tuple of (pet_name, furl) """ actions.run_as_user( 'tahoe-lafs', ['add-introducer', "--introducer", ",".join(introducer)], become_user='******')
def remove_introducer(pet_name): """Rename the introducer entry in the introducers.yaml file specified by the param pet_name. """ actions.run_as_user('tahoe-lafs', ['remove-introducer', '--pet-name', pet_name], become_user='******')
def add_introducer(introducer): """Add an introducer to the storage node's list of introducers. Param introducer must be a tuple of (pet_name, furl) """ actions.run_as_user('tahoe-lafs', ['add-introducer', "--introducer", ",".join(introducer)], become_user='******')
def post_setup(configured_domain_name): """Actions to be performed after installing tahoe-lafs package.""" actions.superuser_run('tahoe-lafs', ['setup', '--domain-name', configured_domain_name]) actions.run_as_user('tahoe-lafs', ['create-introducer'], become_user='******') actions.run_as_user('tahoe-lafs', ['create-storage-node'], become_user='******') actions.superuser_run('tahoe-lafs', ['autostart']) app.enable()
def __call__(self, value): """Validate a directory.""" if not value.startswith('/'): raise ValidationError(_('Invalid directory name.'), 'invalid') command = ['validate-directory', '--path', value] if self.check_creatable: command.append('--check-creatable') elif self.check_writable: command.append('--check-writable') if self.username: output = actions.run_as_user('storage', command, become_user=self.username) else: output = actions.run('storage', command) if 'ValidationError' in output: error_nr = int(output.strip().split()[1]) if error_nr == 1: raise ValidationError(_('Directory does not exist.'), 'invalid') elif error_nr == 2: raise ValidationError(_('Path is not a directory.'), 'invalid') elif error_nr == 3: raise ValidationError( _('Directory is not readable by the user.'), 'invalid') elif error_nr == 4: raise ValidationError( _('Directory is not writable by the user.'), 'invalid')
def get_local_introducer(): """Return the name and furl of the introducer created on this FreedomBox. """ introducer = actions.run_as_user('tahoe-lafs', ['get-local-introducer'], become_user='******') return json.loads(introducer)
def form_valid(self, form): """Apply new superuser password if it exists""" new_config = form.cleaned_data password = new_config.get('super_user_password') if password: actions.run_as_user( 'mumble', ['create-password'], input=password.encode(), become_user="******", ) messages.success(self.request, _('SuperUser password successfully updated.')) return super().form_valid(form)
def get_introducers(): """Return a dictionary of all introducers and their furls added to the storage node running on this FreedomBox. """ introducers = actions.run_as_user('tahoe-lafs', ['get-introducers'], become_user='******') return json.loads(introducers)
def form_valid(self, form): """Apply new superuser password if it exists""" new_config = form.cleaned_data if mumble.get_domain() != new_config['domain']: mumble.set_domain(new_config['domain']) mumble.app.get_component('letsencrypt-mumble').setup_certificates() messages.success(self.request, _('Configuration updated')) password = new_config.get('super_user_password') if password: actions.run_as_user( 'mumble', ['create-password'], input=password.encode(), become_user="******", ) messages.success(self.request, _('SuperUser password successfully updated.')) return super().form_valid(form)
def post_setup(configured_domain_name): """Actions to be performed after installing tahoe-lafs package.""" actions.superuser_run('tahoe-lafs', ['setup', '--domain-name', configured_domain_name]) actions.superuser_run('tahoe-lafs', ['enable']) actions.run_as_user('tahoe-lafs', ['create-introducer'], become_user='******') actions.run_as_user('tahoe-lafs', ['create-storage-node'], become_user='******') actions.superuser_run('tahoe-lafs', ['autostart']) global service if service is None: service = service_module.Service(managed_services[0], name, ports=['tahoe-plinth'], is_external=True, is_enabled=is_enabled, enable=enable, disable=disable, is_running=is_running) service.notify_enabled(None, True) add_shortcut()
def post_setup(configured_domain_name): """Actions to be performed after installing tahoe-lafs package.""" actions.superuser_run('tahoe-lafs', ['setup', '--domain-name', configured_domain_name]) actions.superuser_run('tahoe-lafs', ['enable']) actions.run_as_user('tahoe-lafs', ['create-introducer'], become_user='******') actions.run_as_user('tahoe-lafs', ['create-storage-node'], become_user='******') actions.superuser_run('tahoe-lafs', ['autostart']) global service if service is None: service = service_module.Service( managed_services[0], name, ports=['tahoe-plinth'], is_external=True, is_enabled=is_enabled, enable=enable, disable=disable, is_running=is_running) service.notify_enabled(None, True) add_shortcut()