예제 #1
0
 def setUp(self):
     self.mysweetconfig = os.path.join(DIRECTORY, 'sweetenv.yaml')
     if os.path.exists(self.mysweetconfig):
         os.unlink(self.mysweetconfig)
     hostname = romeo.MYHOSTNAME
     environment = MY_SWEET_ENVIRONMENT
     data = MY_SWEET_ROMEO_CONFIG % locals()
     f = open(self.mysweetconfig, 'wb')
     f.write(data)
     f.close()
     #prime romeo data
     romeo.reload(datadir=DIRECTORY)
예제 #2
0
 def setUp(self):
     self.mysweetconfig = os.path.join(DIRECTORY, "sweetenv.yaml")
     if os.path.exists(self.mysweetconfig):
         os.unlink(self.mysweetconfig)
     hostname = romeo.MYHOSTNAME
     environment = MY_SWEET_ENVIRONMENT
     data = MY_SWEET_ROMEO_CONFIG % locals()
     f = open(self.mysweetconfig, "wb")
     f.write(data)
     f.close()
     # prime romeo data
     romeo.reload(datadir=DIRECTORY)
예제 #3
0
    def configure(self):
        """load configuration for the rest of us."""
#FIXME, we need to fix romeo to load configuration for a directy specified at startup
#and allow SIGHUP to reload configuration
        try:
            drone.log('Processing ROMEO Configuration')
            romeo.reload(datadir=drone.HOSTDB)
            me = romeo.whoami()
        except romeo.IdentityCrisis:
            drone.log('ROMEO Configuration is missing SERVER entry for %s' % \
                    (romeo.MYHOSTNAME,))
            drone.log('DroneD is Exiting')
            exit(1) #Config FAIL!!!!

        ENV_NAME = [ i for i in romeo.listEnvironments() \
                if i.isChild(me) ][0].get('NAME').VALUE

        ENV_OBJECT = romeo.getEnvironment(ENV_NAME)

        #figure out if we are supposed to run new services
        SERVICES = {}
        for service in me.VALUE.get('SERVICES', []):
            if 'SERVICENAME' not in service: continue
            SERVICES[service['SERVICENAME']] = copy.deepcopy(service)

        #figure out if we are supposed to manage application artifacts
        APPLICATIONS = {}
        for i in romeo.grammars.search('my SHORTNAME'):
            search = str('select ARTIFACT')
            for x in romeo.grammars.search(search):
                if x.get('SHORTNAME') != i: continue
                if not ENV_OBJECT.isChild(x):
                    continue #right artifact/wrong env check
                APPLICATIONS[i.VALUE] = copy.deepcopy(x.VALUE)

        #journal and drone are builtins and should always run
        AUTOSTART_SERVICES = ('journal','drone')
        for service_object in SERVICES.values():
            if 'AUTOSTART' in service_object and service_object['AUTOSTART']:
                if service_object['SERVICENAME'] in AUTOSTART_SERVICES: continue
                AUTOSTART_SERVICES += (service_object['SERVICENAME'],)

        #make sure the application service is available
        if APPLICATIONS and 'application' not in AUTOSTART_SERVICES:
            AUTOSTART_SERVICES += ('application',)
        #primary data storage
        self.data = {
            'AUTOSTART_SERVICES': AUTOSTART_SERVICES,
            'EXCESSIVE_LOGGING': drone.DEBUG,
            'ROMEO_API': romeo,
            'ROMEO_HOST_OBJECT': me,
            'ROMEO_ENV_NAME': ENV_NAME,
            'ROMEO_ENV_OBJECT': ENV_OBJECT,
            'HOSTNAME': me.get('HOSTNAME').VALUE,
            'SERVICES': SERVICES,
            'APPLICATIONS': APPLICATIONS,
            'DRONED_PORT': drone.PORT,
            'DRONED_USER': drone.UID,
            'DRONED_GROUP': drone.GID,
            'DRONED_HOMEDIR': drone.DRONED_HOMEDIR,
#FIXME move webroot to drone service
            'DRONED_WEBROOT': drone.DRONED_WEBROOT,
#FIXME move journaldir to journal service
            'JOURNAL_DIR': drone.JOURNAL_DIR,
            'LOG_DIR': drone.LOG_DIR,
            'DEBUG_EVENTS': drone.DEBUG,
#FIXME cli, config file override these ... some of it needs to go into services
            'DRONED_PRIMES': '/usr/share/droned/primes',
            'DRONED_KEY_DIR': '/etc/pki/droned',
            'DRONED_MASTER_KEY_FILE': '/etc/pki/droned/local.private',
            'DRONED_MASTER_KEY': rsa.PrivateKey('/etc/pki/droned/local.private'),
            'DRONED_POLL_INTERVAL': 30,
            'SERVER_POLL_OFFSET': 0.333,
            'INSTANCE_POLL_INTERVAL': 1.0,
            'ACTION_EXPIRATION_TIME': 600,
            'DO_NOTHING_MODE': False,
            'MAX_CONCURRENT_COMMANDS': 5,
            'SERVER_MANAGEMENT_INTERVAL': 10,
        }
예제 #4
0
    def configure(self):
        """load configuration for the rest of us."""
        #FIXME, we need to fix romeo to load configuration for a directy specified at startup
        #and allow SIGHUP to reload configuration
        try:
            drone.log('Processing ROMEO Configuration')
            romeo.reload(datadir=drone.HOSTDB)
            me = romeo.whoami()
        except romeo.IdentityCrisis:
            drone.log('ROMEO Configuration is missing SERVER entry for %s' % \
                    (romeo.MYHOSTNAME,))
            drone.log('DroneD is Exiting')
            exit(1)  #Config FAIL!!!!

        ENV_NAME = [ i for i in romeo.listEnvironments() \
                if i.isChild(me) ][0].get('NAME').VALUE

        ENV_OBJECT = romeo.getEnvironment(ENV_NAME)

        #figure out if we are supposed to run new services
        SERVICES = {}
        for service in me.VALUE.get('SERVICES', []):
            if 'SERVICENAME' not in service: continue
            SERVICES[service['SERVICENAME']] = copy.deepcopy(service)

        #figure out if we are supposed to manage application artifacts
        APPLICATIONS = {}
        for i in romeo.grammars.search('my SHORTNAME'):
            search = str('select ARTIFACT')
            for x in romeo.grammars.search(search):
                if x.get('SHORTNAME') != i: continue
                if isinstance(x.VALUE.get('CLASS', False), type(None)):
                    continue
                if not ENV_OBJECT.isChild(x):
                    continue  #right artifact/wrong env check
                APPLICATIONS[i.VALUE] = copy.deepcopy(x.VALUE)

        #journal and drone are builtins and should always run
        AUTOSTART_SERVICES = ('journal', 'drone')
        for service_object in SERVICES.values():
            if 'AUTOSTART' in service_object and service_object['AUTOSTART']:
                if service_object['SERVICENAME'] in AUTOSTART_SERVICES:
                    continue
                AUTOSTART_SERVICES += (service_object['SERVICENAME'], )

        #make sure the application service is available
        if APPLICATIONS and 'application' not in AUTOSTART_SERVICES:
            AUTOSTART_SERVICES += ('application', )
        #primary data storage
        self.data = {
            'reactor': drone.reactor,
            'AUTOSTART_SERVICES': AUTOSTART_SERVICES,
            'EXCESSIVE_LOGGING': drone.DEBUG,
            'RETAINED_LOGS': drone.RETAINED_LOG_COUNT,
            'ROMEO_API': romeo,
            'ROMEO_HOST_OBJECT': me,
            'ROMEO_ENV_NAME': ENV_NAME,
            'ROMEO_ENV_OBJECT': ENV_OBJECT,
            'HOSTNAME': me.get('HOSTNAME').VALUE,
            'SERVICES': SERVICES,
            'APPLICATIONS': APPLICATIONS,
            'DRONED_PORT': drone.PORT,
            'DRONED_USER': drone.UID,
            'DRONED_GROUP': drone.GID,
            'DRONED_HOMEDIR': drone.DRONED_HOMEDIR,
            #FIXME move webroot to drone service
            'DRONED_WEBROOT': drone.DRONED_WEBROOT,
            #FIXME move journaldir to journal service
            'JOURNAL_DIR': drone.JOURNAL_DIR,
            'LOG_DIR': drone.LOG_DIR,
            'DEBUG_EVENTS': drone.DEBUG,
            #FIXME cli, config file override these ... some of it needs to go into services
            'DRONED_PRIMES': drone.PRIMES_FILE,
            'DRONED_KEY_DIR': drone.RSA_DIR,
            'DRONED_MASTER_KEY_FILE': drone.RSA_MASTER_KEY_FILE,
            'DRONED_MASTER_KEY': rsa.PrivateKey(drone.RSA_MASTER_KEY_FILE),
            'DRONED_POLL_INTERVAL': 30,
            'SERVER_POLL_OFFSET': 0.333,
            'INSTANCE_POLL_INTERVAL': 1.0,
            'ACTION_EXPIRATION_TIME': 600,
            'DO_NOTHING_MODE': False,
            'MAX_CONCURRENT_COMMANDS': drone.MAX_CONCURRENCY,
            'SERVER_MANAGEMENT_INTERVAL': 10,
        }