Exemple #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)
Exemple #2
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)