Esempio n. 1
0
def get_openssl_version():
    """
    Run the "openssl version" command and grab the output
    to use as the version string to use to select proper
    command string.
    """
    cmd = Command('openssl version')
    if cmd.status == 0:
        return cmd.stdout
    else:
        raise RuntimeError('Unable to determine OpenSSL version')
Esempio n. 2
0
 def check_vmware(self):
     if self.service == 'vmware':
         s = os.path.join(self.config['EUCALYPTUS'],
                          'usr/share/eucalyptus/euca_vmware')
         s += ' --config '
         s += os.path.join(self.config['EUCALYPTUS'],
                           'etc/eucalyptus/vmware_conf.xml')
         cmd = Command(s)
         if cmd.status != 0:
             self.messages.append(cmd.stderr)
             self.status = cmd.status
Esempio n. 3
0
def gen_manpages():
    if not os.path.isdir('man'):
        os.mkdir('man')
    # first remove any existing man pages
    for file in os.listdir('man'):
        os.unlink(os.path.join('man', file))
    for file in os.listdir('bin'):
        cmd_string = """help2man -n "Eucalyptus Admin tool: %s" -o man/%s.1 bin/%s""" % (file, file, file)
        cmd = Command(cmd_string)
        if cmd.status != 0:
            print 'error encountered'
            print cmd.stderr
Esempio n. 4
0
 def sync_rsync(self):
     if not self.use_rsync:
         return
     print
     print 'Trying rsync to sync keys with %s' % self.remote_host
     cmd = 'rsync -az '
     cmd += ' '.join(self.files)
     cmd += ' %s@%s:%s' % (self.remote_user, self.remote_host, self.dst_dir)
     cmd = Command(cmd)
     if cmd.status == 0:
         print 'done'
         return True
     else:
         print 'failed.'
         return False
Esempio n. 5
0
 def sync_scp(self):
     euca_user = self.get_euca_user()
     print
     print 'Trying scp to sync keys with %s (user %s)' % (self.remote_host,
                                                          euca_user)
     # TODO: handle sudo password prompt
     cmd = 'sudo -u %s scp ' % euca_user
     cmd += ' '.join(self.files)
     cmd += ' %s@%s:%s' % (euca_user, self.remote_host, self.dst_dir)
     cmd = Command(cmd)
     if cmd.status == 0:
         print 'done'
         return True
     else:
         print 'failed.'
         return False
Esempio n. 6
0
    def main(self):
        self.euca_user_name = self.config['EUCA_USER']
        if self.euca_user_name == 'root':
            root_data = pwd.getpwnam('root')
            self.euca_user_id = root_data.pw_uid
        else:
            try:
                user_data = pwd.getpwnam(self.euca_user_name)
            except KeyError:
                raise ValueError('Is EUCA_USER defined?')
            self.euca_user_id = user_data.pw_uid
            self.euca_user_group_id = user_data.pw_gid

        db_dir = os.path.join(self.config['EUCALYPTUS'], 'var', 'lib',
                              'eucalyptus', 'db')
        if os.path.exists(os.path.join(db_dir, 'data/ibdata1')):
            sys.exit('error: database in %s already exists' % db_dir)
        if self.debug:
            cmd_string = DebugInitCommand % (self.config['EUCALYPTUS'],
                                             self.config['EUCA_USER'],
                                             self.config['EUCALYPTUS'])
        else:
            cmd_string = InitCommand % (self.config['EUCALYPTUS'],
                                        self.config['EUCA_USER'],
                                        self.config['EUCALYPTUS'])
        self.init_scripts()
        if 'CLOUD_OPTS' in self.config:
            cmd_string += ' %s' % self.config['CLOUD_OPTS']
        print 'Initializing a new cloud.  This may take a few minutes.'
        cmd = Command(cmd_string)
        if self.debug:
            print '\tStatus=%d' % cmd.status
            print '\tOutput:'
            print cmd.stdout
            print cmd.stderr
        if cmd.status:
            print 'Initialize command failed'
        else:
            print 'Initialize command succeeded'
        return cmd.status
Esempio n. 7
0
 def init_scripts(self):
     path_string = VarRunPath % self.config['EUCALYPTUS']
     if not os.path.isdir(path_string):
         if self.debug:
             print 'Creating %s' % path_string
         os.mkdir(path_string)
         os.chown(path_string, self.euca_user_id, self.euca_user_group_id)
     initd_dir = os.path.join(self.config['EUCALYPTUS'], 'etc',
                              'eucalyptus', 'cloud.d', 'init.d')
     init_files = sorted(os.listdir(initd_dir))
     for init_file_name in init_files:
         init_file_path = os.path.join(initd_dir, init_file_name)
         if self.debug:
             print 'Evaluating init script %s' % init_file_path
         cmd = Command('bash %s init' % init_file_path)
         if self.debug:
             print '\tStatus=%d' % cmd.status
             print '\tOutput:'
             print cmd.stdout
             print cmd.stderr
         if cmd.status:
             print 'Init script failed %s' % init_file_path
Esempio n. 8
0
 def gen_cloudpk_file(self):
     cmd_string = get_cmdstring('openssl')
     cmd = Command(cmd_string % (self.eucap12_file, self.cloudpk_file))