当前位置: 首页>>代码示例>>Python>>正文


Python AmbariConfig.set方法代码示例

本文整理汇总了Python中ambari_agent.AmbariConfig.AmbariConfig.set方法的典型用法代码示例。如果您正苦于以下问题:Python AmbariConfig.set方法的具体用法?Python AmbariConfig.set怎么用?Python AmbariConfig.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ambari_agent.AmbariConfig.AmbariConfig的用法示例。


在下文中一共展示了AmbariConfig.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_osdisks_remote

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
 def test_osdisks_remote(self, communicate_mock, popen_mock,
                         get_os_version_mock, get_os_type_mock):
   get_os_type_mock.return_value = "suse"
   get_os_version_mock.return_value = "11"
   Hardware.osdisks()
   popen_mock.assert_called_with(['timeout', '10', "df","-kPT"], stdout=-1)
   config = AmbariConfig()
   Hardware.osdisks(config)
   popen_mock.assert_called_with(['timeout', '10', "df","-kPT"], stdout=-1)
   config.add_section(AmbariConfig.AMBARI_PROPERTIES_CATEGORY)
   config.set(AmbariConfig.AMBARI_PROPERTIES_CATEGORY, Hardware.CHECK_REMOTE_MOUNTS_KEY, "true")
   Hardware.osdisks(config)
   popen_mock.assert_called_with(['timeout', '10', "df","-kPT"], stdout=-1)
   config.set(AmbariConfig.AMBARI_PROPERTIES_CATEGORY, Hardware.CHECK_REMOTE_MOUNTS_KEY, "false")
   Hardware.osdisks(config)
   popen_mock.assert_called_with(['timeout', '10', "df","-kPT", "-l"], stdout=-1)
   config.set(AmbariConfig.AMBARI_PROPERTIES_CATEGORY, Hardware.CHECK_REMOTE_MOUNTS_TIMEOUT_KEY, "0")
   Hardware.osdisks(config)
   popen_mock.assert_called_with(['timeout', '10', "df","-kPT","-l"], stdout=-1)
   config.set(AmbariConfig.AMBARI_PROPERTIES_CATEGORY, Hardware.CHECK_REMOTE_MOUNTS_TIMEOUT_KEY, "1")
   Hardware.osdisks(config)
   popen_mock.assert_called_with(["timeout","1","df","-kPT","-l"], stdout=-1)
   config.set(AmbariConfig.AMBARI_PROPERTIES_CATEGORY, Hardware.CHECK_REMOTE_MOUNTS_TIMEOUT_KEY, "2")
   Hardware.osdisks(config)
   popen_mock.assert_called_with(["timeout","2","df","-kPT","-l"], stdout=-1)
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:27,代码来源:TestHardware.py

示例2: test_read_write_component

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
  def test_read_write_component(self):
    config = AmbariConfig().getConfig()
    tmpdir = tempfile.gettempdir()
    config.set('agent', 'prefix', tmpdir)

    tags1 = { "global": "version1", "core-site": "version2" }
    handler = ActualConfigHandler(config, {})
    handler.write_actual(tags1)
    handler.write_actual_component('FOO', tags1)

    output1 = handler.read_actual_component('FOO')
    output2 = handler.read_actual_component('GOO')

    self.assertEquals(tags1, output1)
    self.assertEquals(None, output2)
    
    tags2 = { "global": "version1", "core-site": "version2" }
    handler.write_actual(tags2)

    output3 = handler.read_actual()
    output4 = handler.read_actual_component('FOO')
    self.assertEquals(tags2, output3)
    self.assertEquals(tags1, output4)
    os.remove(os.path.join(tmpdir, "FOO_" + ActualConfigHandler.CONFIG_NAME))
    os.remove(os.path.join(tmpdir, ActualConfigHandler.CONFIG_NAME))
开发者ID:maduhu,项目名称:HDP2.5-ambari,代码行数:27,代码来源:TestActualConfigHandler.py

示例3: test_build

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
  def test_build(self, read_actual_component_mock):
    for component in LiveStatus.COMPONENTS:
      config = AmbariConfig().getConfig()
      config.set('agent', 'prefix', "ambari_agent" + os.sep + "dummy_files")
      livestatus = LiveStatus('', component['serviceName'], component['componentName'], {}, config, {})
      livestatus.versionsHandler.versionsFilePath = "ambari_agent" + os.sep + "dummy_files" + os.sep + "dummy_current_stack"
      result = livestatus.build()
      print "LiveStatus of {0}: {1}".format(component['serviceName'], str(result))
      self.assertEquals(len(result) > 0, True, 'Livestatus should not be empty')
      if component['componentName'] == 'GANGLIA_SERVER':
        self.assertEquals(result['stackVersion'],'{"stackName":"HDP","stackVersion":"1.2.2"}',
                      'Livestatus should contain component stack version')

    # Test build status for CLIENT component (in LiveStatus.CLIENT_COMPONENTS)
    read_actual_component_mock.return_value = "some tags"
    livestatus = LiveStatus('c1', 'HDFS', 'HDFS_CLIENT', { }, config, {})
    result = livestatus.build()
    self.assertTrue(len(result) > 0, 'Livestatus should not be empty')
    self.assertTrue(result.has_key('configurationTags'))
    # Test build status with forsed_component_status
    ## Alive
    livestatus = LiveStatus('c1', 'HDFS', 'HDFS_CLIENT', { }, config, {})
    result = livestatus.build(forsed_component_status = LiveStatus.LIVE_STATUS)
    self.assertTrue(len(result) > 0, 'Livestatus should not be empty')
    self.assertTrue(result['status'], LiveStatus.LIVE_STATUS)
    ## Dead
    livestatus = LiveStatus('c1', 'HDFS', 'HDFS_CLIENT', { }, config, {})
    result = livestatus.build(forsed_component_status = LiveStatus.DEAD_STATUS)
    self.assertTrue(len(result) > 0, 'Livestatus should not be empty')
    self.assertTrue(result['status'], LiveStatus.DEAD_STATUS)

    livestatus = LiveStatus('c1', 'TEZ', 'TEZ_CLIENT', { }, config, {})
    result = livestatus.build(forsed_component_status = LiveStatus.LIVE_STATUS)
    self.assertTrue(len(result) > 0, 'Livestatus should not be empty')
    self.assertTrue(result['status'], LiveStatus.LIVE_STATUS)
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:37,代码来源:TestLiveStatus.py

示例4: test_status_command_without_globals_section

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
 def test_status_command_without_globals_section(self, stopped_method,
                                                 read_stack_version_method):
   config = AmbariConfig().getConfig()
   config.set('agent', 'prefix', TestStackVersionsFileHandler.dummyVersionsFile)
   queue = ActionQueue(config)
   statusCommand = {
     "serviceName" : 'HDFS',
     "commandType" : "STATUS_COMMAND",
     "clusterName" : "",
     "componentName" : "DATANODE",
     'configurations':{}
   }
   queue.stopped = stopped_method
   stopped_method.side_effect = [False, False, True, True, True]
   read_stack_version_method.return_value="1.3.0"
   queue.IDLE_SLEEP_TIME = 0.001
   queue.put(statusCommand)
   queue.run()
   returned_result = queue.resultQueue.get()
   returned_result[1]['status'] = 'INSTALLED' # Patch live value
   self.assertEquals(returned_result, ('STATUS_COMMAND',
                                       {'clusterName': '',
                                        'componentName': 'DATANODE',
                                        'msg': '',
                                        'serviceName': 'HDFS',
                                        'stackVersion': '1.3.0',
                                        'status': 'INSTALLED'}))
开发者ID:adamosloizou,项目名称:fiware-cosmos-ambari,代码行数:29,代码来源:TestActionQueue.py

示例5: test_registration_build

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
  def test_registration_build(self, get_os_version_mock, get_os_type_mock, run_os_cmd_mock):
    config = AmbariConfig().getConfig()
    tmpdir = tempfile.gettempdir()
    config.set('agent', 'prefix', tmpdir)
    config.set('agent', 'current_ping_port', '33777')
    get_os_type_mock.return_value = "suse"
    get_os_version_mock.return_value = "11"
    run_os_cmd_mock.return_value = (3, "", "")
    ver_file = os.path.join(tmpdir, "version")
    with open(ver_file, "w") as text_file:
      text_file.write("1.3.0")

    register = Register(config)
    data = register.build(1)
    #print ("Register: " + pprint.pformat(data))
    self.assertEquals(len(data['hardwareProfile']) > 0, True, "hardwareProfile should contain content")
    self.assertEquals(data['hostname'] != "", True, "hostname should not be empty")
    self.assertEquals(data['publicHostname'] != "", True, "publicHostname should not be empty")
    self.assertEquals(data['responseId'], 1)
    self.assertEquals(data['timestamp'] > 1353678475465L, True, "timestamp should not be empty")
    self.assertEquals(len(data['agentEnv']) > 0, True, "agentEnv should not be empty")
    self.assertEquals(data['agentVersion'], '1.3.0', "agentVersion should not be empty")
    print data['agentEnv']['umask']
    self.assertEquals(not data['agentEnv']['umask']== "", True, "agents umask should not be empty")
    self.assertEquals(data['currentPingPort'] == 33777, True, "current ping port should be 33777")
    self.assertEquals(data['prefix'], config.get('agent', 'prefix'), 'The prefix path does not match')
    self.assertEquals(len(data), 9)

    os.remove(ver_file)
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:31,代码来源:TestRegistration.py

示例6: test_add_reg_listener_to_controller

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
 def test_add_reg_listener_to_controller(self, FileCache_mock):
   FileCache_mock.return_value = None
   dummy_controller = MagicMock()
   config = AmbariConfig().getConfig()
   tempdir = tempfile.gettempdir()
   config.set('agent', 'prefix', tempdir)
   CustomServiceOrchestrator(config, dummy_controller)
   self.assertTrue(dummy_controller.registration_listeners.append.called)
开发者ID:maduhu,项目名称:HDP2.5-ambari,代码行数:10,代码来源:TestCustomServiceOrchestrator.py

示例7: test_server_hostname

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
 def test_server_hostname(self):
   hostname.cached_server_hostname = None
   config = AmbariConfig()
   default_server_hostname = config.get('server', 'hostname')
   config.set('server', 'hostname', 'ambari-host')
   self.assertEquals('ambari-host', hostname.server_hostname(config),
                     "hostname should equal the socket-based hostname")
   config.set('server', 'hostname', default_server_hostname)
   pass
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:11,代码来源:TestHostname.py

示例8: test_dump_command_to_json

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
 def test_dump_command_to_json(self, FileCache_mock, unlink_mock,
                               isfile_mock, hostname_mock,
                               decompress_cluster_host_info_mock):
   FileCache_mock.return_value = None
   hostname_mock.return_value = "test.hst"
   command = {
     'commandType': 'EXECUTION_COMMAND',
     'role': u'DATANODE',
     'roleCommand': u'INSTALL',
     'commandId': '1-1',
     'taskId': 3,
     'clusterName': u'cc',
     'serviceName': u'HDFS',
     'configurations':{'global' : {}},
     'configurationTags':{'global' : { 'tag': 'v1' }},
     'clusterHostInfo':{'namenode_host' : ['1'],
                        'slave_hosts'   : ['0', '1'],
                        'all_hosts'     : ['h1.hortonworks.com', 'h2.hortonworks.com'],
                        'all_ping_ports': ['8670:0,1']},
     'hostLevelParams':{}
   }
   
   decompress_cluster_host_info_mock.return_value = {'namenode_host' : ['h2.hortonworks.com'],
                        'slave_hosts'   : ['h1.hortonworks.com', 'h2.hortonworks.com'],
                        'all_hosts'     : ['h1.hortonworks.com', 'h2.hortonworks.com'],
                        'all_ping_ports': ['8670', '8670']}
   
   config = AmbariConfig()
   tempdir = tempfile.gettempdir()
   config.set('agent', 'prefix', tempdir)
   dummy_controller = MagicMock()
   orchestrator = CustomServiceOrchestrator(config, dummy_controller)
   isfile_mock.return_value = True
   # Test dumping EXECUTION_COMMAND
   json_file = orchestrator.dump_command_to_json(command)
   self.assertTrue(os.path.exists(json_file))
   self.assertTrue(os.path.getsize(json_file) > 0)
   if get_platform() != PLATFORM_WINDOWS:
     self.assertEqual(oct(os.stat(json_file).st_mode & 0777), '0600')
   self.assertTrue(json_file.endswith("command-3.json"))
   self.assertTrue(decompress_cluster_host_info_mock.called)
   os.unlink(json_file)
   # Test dumping STATUS_COMMAND
   command['commandType']='STATUS_COMMAND'
   decompress_cluster_host_info_mock.reset_mock()
   json_file = orchestrator.dump_command_to_json(command)
   self.assertTrue(os.path.exists(json_file))
   self.assertTrue(os.path.getsize(json_file) > 0)
   if get_platform() != PLATFORM_WINDOWS:
     self.assertEqual(oct(os.stat(json_file).st_mode & 0777), '0600')
   self.assertTrue(json_file.endswith("status_command.json"))
   self.assertFalse(decompress_cluster_host_info_mock.called)
   os.unlink(json_file)
   # Testing side effect of dump_command_to_json
   self.assertEquals(command['public_hostname'], "test.hst")
   self.assertEquals(command['agentConfigParams']['agent']['parallel_execution'], 0)
   self.assertTrue(unlink_mock.called)
开发者ID:maduhu,项目名称:HDP2.5-ambari,代码行数:59,代码来源:TestCustomServiceOrchestrator.py

示例9: run_simulation

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
def run_simulation():
  Controller.logger = MagicMock()
  sendRequest_method = MagicMock()

  tmpfile = tempfile.gettempdir()

  config = AmbariConfig().getConfig()
  config.set('agent', 'prefix', tmpfile)

  scriptsDir = os.path.join(os.getcwd(), os.pardir,os.pardir,
    os.pardir, 'main', 'upgrade_stack')
  config.set('stack', 'upgradeScriptsDir', scriptsDir)

  ver_file = os.path.join(tmpfile, "version")

  with open(ver_file, "w") as text_file:
      text_file.write(agent_version)

  controller = Controller.Controller(config)
  controller.sendRequest = sendRequest_method
  controller.netutil.HEARTBEAT_IDDLE_INTERVAL_SEC = 0.1
  controller.netutil.HEARTBEAT_NOT_IDDLE_INTERVAL_SEC = 0.1
  controller.range = 1

  for responce in responces:
    queue.put(responce)

  def send_stub(url, data):
    logger.info("Controller sends data to %s :" % url)
    logger.info(pprint.pformat(data))
    if not queue.empty():
      responce = queue.get()
    else:
      responce = responces[-1]
      logger.info("There is no predefined responce available, sleeping for 30 sec")
      time.sleep(30)
    responce = json.loads(responce)
    responseId.inc()
    responce["responseId"] = responseId.val()
    responce = json.dumps(responce)
    logger.info("Returning data to Controller:" + responce)
    return responce

  sendRequest_method.side_effect = send_stub

  logger.setLevel(logging.DEBUG)
  formatter = logging.Formatter("%(asctime)s %(filename)s:%(lineno)d - \
        %(message)s")
  stream_handler = logging.StreamHandler()
  stream_handler.setFormatter(formatter)
  logger.addHandler(stream_handler)
  logger.info("Starting")

  controller.start()
  controller.actionQueue.IDLE_SLEEP_TIME = 0.1
  controller.run()
开发者ID:adamosloizou,项目名称:fiware-cosmos-ambari,代码行数:58,代码来源:ControllerTester.py

示例10: test_ambari_config_get

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
 def test_ambari_config_get(self):
   config = AmbariConfig()
   #default
   self.assertEqual(config.get("security", "keysdir"), "/tmp/ambari-agent")
   #non-default
   config.set("security", "keysdir", "/tmp/non-default-path")
   self.assertEqual(config.get("security", "keysdir"), "/tmp/non-default-path")
   #whitespace handling
   config.set("security", "keysdir", " /tmp/non-stripped")
   self.assertEqual(config.get("security", "keysdir"), "/tmp/non-stripped")
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:12,代码来源:TestAmbariConfig.py

示例11: test_server_hostnames

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
 def test_server_hostnames(self):
   hostname.cached_server_hostnames = []
   config = AmbariConfig()
   default_server_hostname = config.get('server', 'hostname')
   config.set('server', 'hostname', 'ambari-host')
   server_hostnames = hostname.server_hostnames(config)
   self.assertEquals(['ambari-host'], server_hostnames,
                     "expected host name ['ambari-host']; got {0}".format(server_hostnames))
   config.set('server', 'hostname', default_server_hostname)
   pass
开发者ID:maduhu,项目名称:HDP2.5-ambari,代码行数:12,代码来源:TestHostname.py

示例12: test_process_command

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
  def test_process_command(self, execute_status_command_mock,
                           execute_command_mock, print_exc_mock):
    dummy_controller = MagicMock()
    config = AmbariConfig()
    config.set('agent', 'tolerate_download_failures', "true")
    actionQueue = ActionQueue(config, dummy_controller)
    execution_command = {
      'commandType' : ActionQueue.EXECUTION_COMMAND,
    }
    status_command = {
      'commandType' : ActionQueue.STATUS_COMMAND,
    }
    wrong_command = {
      'commandType' : "SOME_WRONG_COMMAND",
    }
    # Try wrong command
    actionQueue.process_command(wrong_command)
    self.assertFalse(execute_command_mock.called)
    self.assertFalse(execute_status_command_mock.called)
    self.assertFalse(print_exc_mock.called)

    execute_command_mock.reset_mock()
    execute_status_command_mock.reset_mock()
    print_exc_mock.reset_mock()
    # Try normal execution
    actionQueue.process_command(execution_command)
    self.assertTrue(execute_command_mock.called)
    self.assertFalse(execute_status_command_mock.called)
    self.assertFalse(print_exc_mock.called)

    execute_command_mock.reset_mock()
    execute_status_command_mock.reset_mock()
    print_exc_mock.reset_mock()

    actionQueue.process_command(status_command)
    self.assertFalse(execute_command_mock.called)
    self.assertTrue(execute_status_command_mock.called)
    self.assertFalse(print_exc_mock.called)

    execute_command_mock.reset_mock()
    execute_status_command_mock.reset_mock()
    print_exc_mock.reset_mock()

    # Try exception to check proper logging
    def side_effect(self):
      raise Exception("TerribleException")
    execute_command_mock.side_effect = side_effect
    actionQueue.process_command(execution_command)
    self.assertTrue(print_exc_mock.called)

    print_exc_mock.reset_mock()

    execute_status_command_mock.side_effect = side_effect
    actionQueue.process_command(execution_command)
    self.assertTrue(print_exc_mock.called)
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:57,代码来源:TestActionQueue.py

示例13: test_read_write

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
  def test_read_write(self):
    config = AmbariConfig().getConfig()
    tmpdir = tempfile.gettempdir()
    config.set('agent', 'prefix', tmpdir)

    tags = { "global": "version1", "core-site": "version2" }
    handler = ActualConfigHandler(config, tags)
    handler.write_actual(tags)
    output = handler.read_actual()
    self.assertEquals(tags, output)
    os.remove(os.path.join(tmpdir, ActualConfigHandler.CONFIG_NAME))
开发者ID:maduhu,项目名称:HDP2.5-ambari,代码行数:13,代码来源:TestActualConfigHandler.py

示例14: test_read_agent_version

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
 def test_read_agent_version(self, get_os_version_mock, get_os_type_mock):
   config = AmbariConfig().getConfig()
   tmpdir = tempfile.gettempdir()
   config.set('agent', 'prefix', tmpdir)
   config.set('agent', 'current_ping_port', '33777')
   ver_file = os.path.join(tmpdir, "version")
   reference_version = "1.3.0"
   with open(ver_file, "w") as text_file:
     text_file.write(reference_version)
   version = self.controller.read_agent_version(config)
   os.remove(ver_file)
   self.assertEqual(reference_version, version)
开发者ID:maduhu,项目名称:HDP2.5-ambari,代码行数:14,代码来源:TestController.py

示例15: test_build

# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import set [as 别名]
 def test_build(self):
   for component in LiveStatus.COMPONENTS:
     config = AmbariConfig().getConfig()
     config.set('agent', 'prefix', "dummy_files")
     livestatus = LiveStatus('', component['serviceName'], component['componentName'], {}, config)
     livestatus.versionsHandler.versionsFilePath = os.path.join("dummy_files","dummy_current_stack")
     result = livestatus.build()
     print "LiveStatus of {0}: {1}".format(component['serviceName'], str(result))
     self.assertEquals(len(result) > 0, True, 'Livestatus should not be empty')
     if component['componentName'] == 'GANGLIA_SERVER':
       self.assertEquals(result['stackVersion'],'{"stackName":"HDP","stackVersion":"1.2.2"}',
                     'Livestatus should contain component stack version')
开发者ID:adamosloizou,项目名称:fiware-cosmos-ambari,代码行数:14,代码来源:TestLiveStatus.py


注:本文中的ambari_agent.AmbariConfig.AmbariConfig.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。