コード例 #1
0
    def configureKeytab(cls):
        with open(cls.keytab, 'rb') as fd:
            content = fd.read()

        content = encodeFileContent(content)

        cls.client.call('nuauth', 'upload_krb_keytab', content)
コード例 #2
0
ファイル: templateConfig.py プロジェクト: maximerobin/Ufwi
    def _test_restore(self, force=False):
        if self.local_ha_state == "CONNECTED" and not force:
            raise Exception("Watchout ! You're restoring while on a HA setup. It will deconfigure the primary.")

        state = "after a restoration"
        self.next_apply_restore = True

        try:
            with open('./test_archive/archive.tar.gz', 'rb') as handle:
                content = handle.read()
        except:
            raise Exception("'./test_archive/archive.tar.gz' wasn't found")

        # For this archive, the NTP configuration is 172.16.0.11
        self.to_save_ip = u'172.16.0.11'

        last_applied_sequence_number = self.nucentral_last_applied_sequence_number()

        ############################################################# Restore !
        self.client.call('nurestore', 'restore', encodeFileContent(content))
        #######################################################################

        new_saved_sequence_number = self.nucentral_last_saved_sequence_number()
        new_applied_sequence_number = self.nucentral_last_applied_sequence_number()

        # For this archive, the sequence number is 117
        errors = []

        if not new_saved_sequence_number == 117:
            errors.append("The new saved sequence is not 117 as it should be %s." % state)
        if not last_applied_sequence_number == new_applied_sequence_number:
            errors.append("The applied sequence number has changed %s." % state)
        # End state should be : Applicable
        config_state = self.client.call('config', 'state')
        if not config_state  == "Applicable":
            error = "config.state is not 'Applicable' %s (%s)." % (state, config_state)
            errors.append(error)

        assert not errors, errors

        # Check files : modified, existing, non existing
        # Existing :
        should_exist = (RUNNING, NTP)
        self.check_exists(should_exist, state)
        # Non Existing
        shouldnt_exist = (SAVED, DIFF)
        self.check_doesnt_exist(shouldnt_exist, state)
        # Modified
        should_contain = (RUNNING,)
        self.check_contains(should_contain, self.to_save_ip)
        # UnModified
        shouldnt_contain = (NTP,)
        self.check_doesnt_contain(shouldnt_contain, self.to_save_ip)

        # Test parameters
        self.saved_ip = self.to_save_ip