def _update_config(self): """ Update the deployed default server configuration. """ # Parse and update the configuration cp = CParse() cp.select(self.server_conf) # Update each section for section, pair in self.params.get_config().iteritems(): for key, val in pair.iteritems(): cp.set_key(key, val, s=section) # Format the value output self.feedback.set('[{}] Set key value for "{}->{}"'.format(self.server_conf, section, key)).success() # Apply the configuration changes cp.apply() self.feedback.set('Applied updated server configuration').success()
def _database_seed(self): """ Seed the database with the base information needed to run Lense. """ # Import modules now to get the new configuration from lense.engine.api.app.group.utils import GroupCreate from lense.engine.api.app.user.utils import UserCreate from lense.engine.api.app.group.models import DBGroupDetails from lense.engine.api.app.gateway.models import DBGatewayACLGroupGlobalPermissions, DBGatewayACLKeys, \ DBGatewayACLAccessGlobal, DBGatewayUtilities from lense.engine.api.app.gateway.utils import GatewayUtilitiesCreate, GatewayACLObjectsCreate, \ GatewayACLCreate # Setup Django models django.setup() # Create the administrator group and user group = self._create_group(GroupCreate) user = self._create_user(UserCreate) # Update administrator info in the server configuration cp = CParse() cp.select(self.server_conf) cp.set_key('user', user['data']['username'], s='admin') cp.set_key('group', self.params.user['group'], s='admin') cp.set_key('key', user['data']['api_key'], s='admin') cp.apply() self.feedback.set('[{}] Set API administrator values'.format(self.server_conf)).success() # Create API utilities / ACL objects / ACL keys / access entries self._create_utils(GatewayUtilitiesCreate) self._create_acl_keys(GatewayACLCreate) self._create_utils_access(DBGatewayACLAccessGlobal, DBGatewayACLKeys, DBGatewayUtilities) self._create_acl_objects(GatewayACLObjectsCreate) self._create_acl_access(DBGatewayACLGroupGlobalPermissions, DBGatewayACLKeys, DBGroupDetails)