コード例 #1
0
def _get_configuration(resource_root, cluster_name , type , tag="version1"):
  """
  Get configuration of a cluster
  @param resource_root: The root Resource .
  @param cluster_name: cluster_name
  @param type: type of config
  @return: A ConfigModel object
  """
  dic = resource_root.get(paths.CONFIGURATION_PATH % (cluster_name, type, tag))
  config_model = utils.ModelUtils.create_model(ConfigModel , dic["items"][0], resource_root, "NO_KEY")
  ref_clss = utils.getREF_class_name("cluster_name")
  config_model._setattr(ref_clss, dic["items"][0]['Config']['cluster_name'])
  return config_model
コード例 #2
0
def _get_configuration(resource_root, cluster_name, type, tag="version1"):
    """
  Get configuration of a cluster
  @param resource_root: The root Resource .
  @param cluster_name: cluster_name
  @param type: type of config
  @return: A ConfigModel object
  """
    dic = resource_root.get(paths.CONFIGURATION_PATH %
                            (cluster_name, type, tag))
    config_model = utils.ModelUtils.create_model(ConfigModel, dic["items"][0],
                                                 resource_root, "NO_KEY")
    ref_clss = utils.getREF_class_name("cluster_name")
    config_model._setattr(ref_clss, dic["items"][0]['Config']['cluster_name'])
    return config_model
コード例 #3
0
def _get_all_configuration(resource_root, cluster_name, type):
    """
  Gets ALL configuration of a cluster of a given type
  @param resource_root: The root Resource .
  @param cluster_name: cluster_name
  @param type: type of config
  @return: A ConfigModel object
  """
    dic = resource_root.get(paths.CONFIGURATION_ALL_PATH %
                            (cluster_name, type))

    if len(dic["items"]) == 0:
        return None

    objects = []
    for cfgm in dic["items"]:
        config_model = utils.ModelUtils.create_model(ConfigModel, cfgm,
                                                     resource_root, "NO_KEY")
        ref_clss = utils.getREF_class_name("cluster_name")
        config_model._setattr(ref_clss, cfgm['Config']['cluster_name'])
        objects.append(config_model)
    return ModelList(objects)