Ejemplo n.º 1
0
    def test_all_hosts_config(self):
        SUMMARY = """
      {
        "items" : [ {
          "name" : "blacklisted_parcel_products",
          "value" : "foo,bar"
        } ]
      }
      """
        FULL = """
      {
        "items" : [ {
          "name" : "blacklisted_parcel_products",
          "value" : "foo,bar",
          "required" : false,
          "default" : "",
          "displayName" : "Blacklisted Products",
          "description" : "Parcels for blacklisted products will not be distributed to the host, nor activated for process execution. Already distributed parcels will be undistributed. Already running process will not be affected until the next restart.",
          "validationState" : "OK"
        }, {
          "name" : "rm_enabled",
          "required" : false,
          "default" : "false",
          "displayName" : "Enable Resource Management",
          "description" : "Enables resource management for all roles on this host.",
          "validationState" : "OK",
          "validationWarningsSuppressed" : false
        } ]
      }
      """

        resource = utils.MockResource(self)
        cms = ClouderaManager(resource)

        resource.expect("GET",
                        "/cm/allHosts/config",
                        retdata=json.loads(SUMMARY))
        cfg = cms.get_all_hosts_config()
        self.assertIsInstance(cfg, dict)
        self.assertEqual(1, len(cfg))
        self.assertEqual('foo,bar', cfg.get('blacklisted_parcel_products'))

        resource.expect("GET",
                        "/cm/allHosts/config",
                        params={'view': 'full'},
                        retdata=json.loads(FULL))
        cfg = cms.get_all_hosts_config(view='full')
        self.assertIsInstance(cfg, dict)
        self.assertEqual(2, len(cfg))
        self.assertIsInstance(cfg['blacklisted_parcel_products'], ApiConfig)
        self.assertFalse(cfg['blacklisted_parcel_products'].required)
        self.assertEqual('OK', cfg['rm_enabled'].validationState)

        cfg = {'blacklisted_parcel_products': 'bar'}
        resource.expect("PUT",
                        "/cm/allHosts/config",
                        data=config_to_json(cfg),
                        retdata=json.loads(SUMMARY))
        cms.update_all_hosts_config(cfg)
Ejemplo n.º 2
0
    def update_config(self, config):
        """
    Update the host's configuration.

    @param config Dictionary with configuration to update.
    @return Dictionary with updated configuration.
    """
        path = self._path() + '/config'
        resp = self._get_resource_root().put(path, data=config_to_json(config))
        return json_to_config(resp)
Ejemplo n.º 3
0
  def update_config(self, config):
    """
    Update the host's configuration.

    @param config Dictionary with configuration to update.
    @return Dictionary with updated configuration.
    """
    path = self._path() + '/config'
    resp = self._get_resource_root().put(path, data = config_to_json(config))
    return json_to_config(resp)
Ejemplo n.º 4
0
  def update_config(self, config):
    """
    Update the CM configuration.

    @param: config Dictionary with configuration to update.
    @return: Dictionary with updated configuration.
    """
    resp = self._get_resource_root().put('/cm/config',
        data = config_to_json(config))
    return json_to_config(resp, False)
Ejemplo n.º 5
0
    def update_config(self, config):
        """
    Update the CM configuration.

    @param: config Dictionary with configuration to update.
    @return: Dictionary with updated configuration.
    """
        resp = self._get_resource_root().put('/cm/config',
                                             data=config_to_json(config))
        return json_to_config(resp, False)
Ejemplo n.º 6
0
  def test_all_hosts_config(self):
    SUMMARY = """
      {
        "items" : [ {
          "name" : "blacklisted_parcel_products",
          "value" : "foo,bar"
        } ]
      }
      """
    FULL = """
      {
        "items" : [ {
          "name" : "blacklisted_parcel_products",
          "value" : "foo,bar",
          "required" : false,
          "default" : "",
          "displayName" : "Blacklisted Products",
          "description" : "Parcels for blacklisted products will not be distributed to the host, nor activated for process execution. Already distributed parcels will be undistributed. Already running process will not be affected until the next restart.",
          "validationState" : "OK"
        }, {
          "name" : "rm_enabled",
          "required" : false,
          "default" : "false",
          "displayName" : "Enable Resource Management",
          "description" : "Enables resource management for all roles on this host.",
          "validationState" : "OK",
          "validationWarningsSuppressed" : false
        } ]
      }
      """

    resource = utils.MockResource(self)
    cms = ClouderaManager(resource)

    resource.expect("GET", "/cm/allHosts/config", retdata=json.loads(SUMMARY))
    cfg = cms.get_all_hosts_config()
    self.assertIsInstance(cfg, dict)
    self.assertEqual(1, len(cfg))
    self.assertEqual('foo,bar', cfg.get('blacklisted_parcel_products'))

    resource.expect("GET", "/cm/allHosts/config", params={ 'view' : 'full' },
        retdata=json.loads(FULL))
    cfg = cms.get_all_hosts_config(view='full')
    self.assertIsInstance(cfg, dict)
    self.assertEqual(2, len(cfg))
    self.assertIsInstance(cfg['blacklisted_parcel_products'], ApiConfig)
    self.assertFalse(cfg['blacklisted_parcel_products'].required)
    self.assertEqual('OK', cfg['rm_enabled'].validationState)

    cfg = { 'blacklisted_parcel_products' : 'bar' }
    resource.expect("PUT", "/cm/allHosts/config", data=config_to_json(cfg),
        retdata=json.loads(SUMMARY))
    cms.update_all_hosts_config(cfg)