コード例 #1
0
def create_node_pool(container_engine_client, module):
    create_node_pool_details = CreateNodePoolDetails()
    for attribute in create_node_pool_details.attribute_map.keys():
        if attribute in module.params:
            setattr(create_node_pool_details, attribute,
                    module.params[attribute])

    node_labels = module.params['initial_node_labels']
    if node_labels:
        initial_node_labels = []
        for d in node_labels:
            keyvalue = KeyValue()
            if d.get("key", None) and d.get("value", None):
                keyvalue.key = d.get("key")
                keyvalue.value = d.get("value")
                initial_node_labels.append(keyvalue)
        create_node_pool_details.initial_node_labels = initial_node_labels

    result = oci_ce_utils.create_and_wait(
        resource_type="node_pool",
        create_fn=container_engine_client.create_node_pool,
        kwargs_create={"create_node_pool_details": create_node_pool_details},
        client=container_engine_client,
        get_fn=container_engine_client.get_node_pool,
        get_param="node_pool_id",
        module=module)
    return result
コード例 #2
0
def create_node_pool(container_engine_client, module):
    create_node_pool_details = CreateNodePoolDetails()
    for attribute in create_node_pool_details.attribute_map.keys():
        if attribute in module.params:
            setattr(create_node_pool_details, attribute,
                    module.params[attribute])

    node_labels = module.params["initial_node_labels"]
    if node_labels:
        initial_node_labels = []
        for d in node_labels:
            keyvalue = KeyValue()
            if d.get("key", None) and d.get("value", None):
                keyvalue.key = d.get("key")
                keyvalue.value = d.get("value")
                initial_node_labels.append(keyvalue)
        create_node_pool_details.initial_node_labels = initial_node_labels
    # Note: `wait` is "True" by default for `oci_node_pool`, unlike other resources because a node pool is only useful
    # if atleast one node in the node pool reaches ACTIVE state (Installation of Helm components are delayed until a
    # node is available).
    result = oci_ce_utils.create_and_wait(
        resource_type="node_pool",
        create_fn=container_engine_client.create_node_pool,
        kwargs_create={"create_node_pool_details": create_node_pool_details},
        client=container_engine_client,
        get_fn=container_engine_client.get_node_pool,
        get_param="node_pool_id",
        module=module,
    )
    return result