Esempio n. 1
0
    def load(self):
        ''' Loading data '''
        self.logger.debug('load - BEGIN')
        data = GecosAccessData()

        # Check previous saved data (in memory cache)
        if self.previous_saved_data is not None:
            return self.previous_saved_data

        # Get data from data file
        jsonUtil = JSONUtil()
        json_data = jsonUtil.loadJSONFromFile(self.data_file)
        if json_data is not None:

            data.set_login(json_data['gcc_username'].encode('utf-8'))
            data.set_url(json_data['uri_gcc'].encode('utf-8'))

            # Password is not stored!
            data.set_password(None)

        if data.get_url() is None or data.get_url().strip() == '':
            data = None

        self.logger.debug('load - END')
        return data
    def runTest(self):
        dao = GecosAccessDataDAO()

        print "Try to load original data..."
        originalData = dao.load()

        print "Set test data..."
        newData = GecosAccessData()
        newData.set_url('test_url')
        newData.set_login('test_login')
        dao.save(newData)

        print "Load and check test data..."
        newData = dao.load()

        self.assertEqual(newData.get_url(), 'test_url')
        self.assertEqual(newData.get_login(), 'test_login')

        wddao = WorkstationDataDAO()
        wd = wddao.load()

        dao.delete(newData)
        self.assertFalse(os.path.isfile('/etc/gcc.control'))

        if originalData is not None:
            print "Restore original data..."
            dao.save(originalData)
            wddao.save(wd)
Esempio n. 3
0
    def runTest(self):
        obj = GecosAccessData()
        
        obj.set_url('test_url')
        self.assertEqual(obj.get_url(), 'test_url')
        self.assertEqual(obj.url, 'test_url')

        obj.set_login('test_login')
        self.assertEqual(obj.get_login(), 'test_login')
        self.assertEqual(obj.login, 'test_login')

        obj.set_password('test_password')
        self.assertEqual(obj.get_password(), 'test_password')
        self.assertEqual(obj.password, 'test_password')
Esempio n. 4
0
        sys.exit()

    # Save Chef client certificate in a PEM file
    if not save_file('c:\\chef\\client.pem', client_pem):
        logging.error("There was an error while saving the client certificate")
        if not debug_mode:
            gecosCC.unregister_chef_node(gecosAccessData,
                                         workstationData.get_node_name())
        clean_connection_files_on_error()
        sys.exit()

    logging.info("- Create c:\\chef/client.rb")

    chef_admin_name = gecosAccessData.get_login()

    chef_url = gecosAccessData.get_url()
    chef_url = chef_url.split('//')[1].split(':')[0]
    chef_url = "https://" + chef_url + '/'

    if (conf is not None and conf.has_key("chef")
            and conf["chef"].has_key("chef_server_uri")
            and not 'localhost' in conf["chef"]["chef_server_uri"]):
        chef_url = conf["chef"]["chef_server_uri"]
        logging.debug("chef_url retrieved from GECOS auto conf")

    if (conf is not None and conf.has_key("chef")
            and conf["chef"].has_key("chef_admin_name")):
        chef_admin_name = conf["chef"]["chef_admin_name"]
        logging.debug("chef_admin_name retrieved from GECOS auto conf")

    # Check Chef HTTPS certificate