Пример #1
0
    def _write_multi(self, wf):
        '''Writes input for multi-node configurations.'''        
        wf.write('2\n')   # 2 = multi
        
        # EC2 prompt is version 3.0 and later
        if not self._using22:
            wf.write('n\n')   # not EC2
            
        combined = 2
        if self._cluster.config()['rolespec'].has_key('um'):
            combined = 1
        wf.write('%d\n' % combined) # 2 = combined, 1 = separate
#        if combined == 1 and ConfigSpec._version_greaterthan(self._cluster.config()['idbversion'],'4.5.0-0'):
#            if self._cluster.config()['pm_query']:
#                wf.write('y\n')
#            else:
#                wf.write('n\n')  # pm with user = n; applies to version 4.5 and up

        wf.write('%s\n' % self._cluster.config()['name'])
        wf.write('pm1\n') # local module name always pm1 by convention
        if self._cluster.config()['datdup'] and ConfigSpec._version_greaterthan('4.0.0-0',self._cluster.config()['idbversion']):
            wf.write('y\n')   # y = use datdup
        else:
            self._write_storage_type(wf)
                    
        if self._using22:
            # this is 2.2 - there is a # dbroots prompt here we need to sum up across all nodes
            dbrootcnt = 0
            for m in self._cluster.machines():
                dbrootcnt += len(self._cluster.machines()[m]['dbroots'])
            wf.write('%d\n' % dbrootcnt)            
                        
        if combined == 1:
            self._write_nodes(wf, 'um')
        self._write_nodes(wf, 'pm', nodbroot=self._using22)
        if not self._nonroot:        
            wf.write('y\n')   # y = disable SNMP trap
        else:
            wf.write('n\n')   # n = keep SNMP trap disabled (non-root always defaults off)
        wf.write('n\n')   # n = no external devices
        # note that as it stands right now we cannot run the install in this method 
        # because postConfigure does a getpass() which does not read from STDIN
        # if we want to do this, postConfigure needs an enhancement to bypass that option
        wf.write('y\n')   # perform system install
        wf.write('%s\n' % self._ptype)    # package type
        if self._cluster.config()['datdup']:
            self._write_datdup(wf)
        wf.write('y\n')   # startup system
Пример #2
0
 def _write_storage_type(self, wf):
     if not self._using22:
         # versions 3.0 or later 1 = internal, 2 = external
         # starting at version 4.0 or later, 3 = glusterfs, 4 = hdfs
         if self._cluster.config()['hadoop']:
             wf.write('4\n')   # 4 = hdfs storage
             # TODO - may have to support plugin configuration - not sure if we can
             # trust postConfigure to present the right one as default.  Regardless,
             # not relevant until we add alternate hadoop version support              
             wf.write('\n')   # accept default plugin                  
         elif self._cluster.config()['datdup'] and ConfigSpec._version_greaterthan(self._cluster.config()['idbversion'],'4.0.0-0'):                
             wf.write('3\n')   # 3 = glusterfs storage
         elif self._cluster.config()['storage'] == 'external':
             wf.write('2\n')   # 2 = external storage
         else:
             wf.write('1\n')   # 1 = internal storage
     else:
         # versions earlier than 3.0, 1 = external, 2 = internal
         if self._cluster.config()['storage'] == 'external':
             wf.write('1\n')   # 1 = external storage
         else:
             wf.write('2\n')   # 2 = internal storage
Пример #3
0
    def write_input(self, fname, cluster, ptype):
        '''Writes the postConfigure input file.
        
        @param fname - output file location
        @param cluster - the Cluster instance we want to postConfigure
        '''
        self._cluster = cluster
        self._ptype = ptype
        if self._cluster.config()['idbuser'] != 'root':
            self._nonroot = True
        else:
            self._nonroot = False

        # there are a number of differences for 2.2.  cache a boolean to tell us 
        # whether or not we are in that case
        self._using22 = not ConfigSpec._version_greaterthan(self._cluster.config()['idbversion'],'3.0.0-0')
        
        wf = open( fname, 'w' )
        if len(self._cluster.machines()) > 1:
            self._write_multi(wf)
        else:
            self._write_single(wf)
        wf.close()
Пример #4
0
 def testVersionGT(self):
     self.assertTrue( ConfigSpec._version_greaterthan('3.5', '3.5.1-5'))
     self.assertFalse( ConfigSpec._version_greaterthan('3.5.1', '3.5.1-5'))
     self.assertTrue( ConfigSpec._version_greaterthan('3.5.1.1-2', '3.5.1-5'))
     self.assertTrue( ConfigSpec._version_greaterthan('3.5.2-1', '3.5.1-5'))
     self.assertTrue( ConfigSpec._version_greaterthan('3.5', '2.2'))
     self.assertFalse( ConfigSpec._version_greaterthan('3.5', '4.0'))
     self.assertTrue( ConfigSpec._version_greaterthan('3.5', '3.0'))
     self.assertFalse( ConfigSpec._version_greaterthan('3.0', '3.5'))
     self.assertTrue( ConfigSpec._version_greaterthan('3.5', '3.5'))
     self.assertFalse( ConfigSpec._version_greaterthan('3.5.1-5','3.5'))
     self.assertFalse( ConfigSpec._version_greaterthan('3.5.1','3.5.2'))
     self.assertTrue( ConfigSpec._version_greaterthan('3.5.2','3.5.1'))
     self.assertTrue( ConfigSpec._version_greaterthan('3.5.2','3.5.2'))
     self.assertTrue( ConfigSpec._version_greaterthan('3.5.2-1','3.5.2-1'))
     self.assertTrue( ConfigSpec._version_greaterthan('3.5.2-2','3.5.2-1'))
     self.assertFalse( ConfigSpec._version_greaterthan('3.5.2-2','3.5.2-3'))
     self.assertTrue( ConfigSpec._version_greaterthan('3.5.2.1-1','3.5.2.1-1'))
     self.assertTrue( ConfigSpec._version_greaterthan('3.5.2.1-2','3.5.2.1-1'))
     self.assertFalse( ConfigSpec._version_greaterthan('3.5.2.1-2','3.5.2.1-3'))
     self.assertTrue( ConfigSpec._version_greaterthan('3.5.2.1','3.5.2.0'))
     self.assertFalse( ConfigSpec._version_greaterthan('3.5.2.1','3.5.2.2'))
     self.assertTrue( ConfigSpec._version_greaterthan('3.5.2.1-1','3.5.2.1'))
     self.assertFalse( ConfigSpec._version_greaterthan('3.5.2.1','3.5.2.1-1'))
     self.assertTrue( ConfigSpec._version_greaterthan('Latest','3.5.2.1'))
     self.assertTrue( ConfigSpec._version_greaterthan('Latest','3.5'))
     self.assertTrue( ConfigSpec._version_greaterthan('Latest','4.0'))
     self.assertFalse( ConfigSpec._version_greaterthan('3.5','Latest'))
     self.assertFalse( ConfigSpec._version_greaterthan('2.2.7-2','2.2.10-1'))
     self.assertTrue( ConfigSpec._version_greaterthan('2.2.10-1','2.2.7-2'))
     self.assertTrue( ConfigSpec._version_greaterthan('4.0.0-1','4.0.0-0'))
     self.assertFalse( ConfigSpec._version_greaterthan('4.0.0-0','4.0.0-1'))
     self.assertTrue( ConfigSpec._version_greaterthan('4.0.0-1','4.0.0-1_old'))
     self.assertFalse( ConfigSpec._version_greaterthan('4.0.0-1_old','4.0.0-1'))
Пример #5
0
    def run_cmd(self):
        '''
        Prepare and run the ansible playbook command for
        the operation type specified in the constructor
        '''
        self._rundir = self._cluster.get_rundir()
        self._pkgdir = self._cluster.get_pkgdir()
        self._pkgfile = self._cluster.get_pkgfile()
        self._idbuser = self._cluster.config()['idbuser']
        eflag = self._cluster.config()['enterprise']
        if eflag:
            self._entflag = "true"
        else:
            self._entflag = "false"
        self._version = self._pkgfilenameparser.get_pkg_version(self._pkgfile)
        self._hadoop = self._cluster.config()['hadoop']
        self._hdfsflag = "false"
        if self._hadoop:
            self._hdfsflag = "true"
        self._upgfile = self._cluster.get_upgfile()
        self._upgversion = None
        if self._upgfile:
            self._upgversion = self._pkgfilenameparser.get_pkg_version(
                self._upgfile)
        m = self._cluster.machine('pm1')
        self._pm1_ip = m['ip']
        self._postconfig_opts = self._cluster.get_postconfig_opts()

        # Add -em to postconfig flags for version 4.6 and up
        if self._optype == 'pkginstall':
            if ConfigSpec._version_greaterthan(self._version, '4.6.0-0'):
                self._postconfig_opts += " -em"
            (ansible_yml, cmdargs) = self._prepare_playbook_pkginstall()
        elif self._optype == 'pkgupgrade':
            if ConfigSpec._version_greaterthan(self._upgversion, '4.6.0-0'):
                self._postconfig_opts += " -em"
            (ansible_yml, cmdargs) = self._prepare_playbook_pkgupgrade()
        elif self._optype == 'bininstall':
            if ConfigSpec._version_greaterthan(self._version, '4.6.0-0'):
                self._postconfig_opts += " -em"
            (ansible_yml, cmdargs) = self._prepare_playbook_bininstall()
        elif self._optype == 'binupgrade':
            if ConfigSpec._version_greaterthan(self._upgversion, '4.6.0-0'):
                self._postconfig_opts += " -em"
            (ansible_yml, cmdargs) = self._prepare_playbook_binupgrade()
        else:
            raise Exception("Unsupported ansible playbook type to run: %s" %
                            self._optype)

        extra_playdir = self._cluster.get_extra_playbook_dir()
        p = PlaybookMgr(os.path.basename(self._rundir), extra_playdir)

        # create ansible inventory file with list of hosts;
        # should already exist for an EM-triggered install.
        full_inv_file = '%s/%s' % (p.get_rootdir(), self._inventory_filename)
        if not os.path.exists(full_inv_file):
            machines = self._cluster.machines()
            iplist = []
            infnodelist = []
            for key in machines:
                m = machines[key]
                iplist.append(m['ip'])

                # if we are using the EM in invm mode we don't want that
                # node to participate in the normal InfiniDB install
                if key != 'em1':
                    #f.write("key: %s.calpont.com; ip: %s\n" % (key,m['ip']))
                    infnodelist.append(m['ip'])

            ipdict = {'all': iplist, 'infinidb_nodes': infnodelist}
            p.write_inventory(self._inventory_filename, ipdict)

        # create ansible.cfg file;
        # should already exist for an EM-triggered install.
        full_ans_file = '%s/%s' % (p.get_rootdir(), 'ansible.cfg')
        if not os.path.exists(full_ans_file):
            keytext = self._cluster.get_sshkey_text()
            p.config_ssh(self._idbuser, keytext)

        # execute playbook thru PlaybookMgr
        self._ansible_file = ansible_yml
        self._extra_vars = cmdargs
        rc, results, out, err = p.run_playbook(ansible_yml,
                                               self._inventory_filename,
                                               playbook_args=cmdargs)

        return rc, results, out, err