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


Python Cluster.load_from_json方法代码示例

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


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

示例1: show_cluster

# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import load_from_json [as 别名]
def show_cluster(argv):
    """
    show detail information about a cluster
    :param argv: sys.argv
    :return: None
    """
    if len(argv) < 3:
        print_help()
        exit(1)
    cluster_name = argv[2]
    cluster = Cluster.load_from_json(cluster_name)

    if cluster is None:
        print cluster_name, " cluster not found"
        exit(1)

    cluster.print_description()
开发者ID:pengchengxu,项目名称:ambari-agent-simulator,代码行数:19,代码来源:launcher_cluster.py

示例2: up_cluster

# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import load_from_json [as 别名]
def up_cluster(argv):
    """
    run all Ambari-agents in Docker container and VMs,
    run Ambari-server if there is according to the configuration file
    :param argv: sys.argv
    :return: None
    """
    if len(argv) < 3:
        print_help()
        exit(1)

    cluster_name = argv[2]
    cluster = Cluster.load_from_json(cluster_name)

    if cluster is None:
        print cluster_name, " cluster not found"
        exit(1)

    if cluster.state != Cluster.STATE_FREE:
        print cluster_name, " cluster is already running"
        exit(1)

    ambari_server = cluster.get_ambari_server_vm()
    if ambari_server is None:
        print "Unable to run cluster", cluster_name,\
            " no Ambari-server in this cluster, you can only merge this cluster into another one"
        exit(1)

    print "Configuring cluster"
    print "Check output folder: ", Config.ATTRIBUTES["output_folder"]

    cluster.run_cluster(ambari_server.weave_internal_ip, ambari_server.external_ip)
    data = Data()
    data.set_cluster_state(cluster_name, Cluster.STATE_RUNNING)

    # reset terminal. The SSH subprocess call of the program cause the terminal display to be abnormal.
    # This is an unsolved minor issue.
    subprocess.call(["reset"])

    print "Complete"
开发者ID:pengchengxu,项目名称:ambari-agent-simulator,代码行数:42,代码来源:launcher_cluster.py

示例3: len

# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import load_from_json [as 别名]
    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

# configure the VM to run Ambari-server and set Weave network
# argv 1: the name of cluster

from config import Config
from cluster import Cluster
import sys


if __name__ == "__main__":
    if len(sys.argv) < 2:
        print "configure the VM to run Ambari-server and set Weave network"
        print "Arg: <the name of cluster>"
        exit(1)

    Config.load()

    cluster_name = sys.argv[1]
    cluster = Cluster.load_from_json(cluster_name)

    vm = cluster.get_ambari_server_vm()
    vm.run_ambari_server()
开发者ID:pengchengxu,项目名称:ambari-agent-simulator,代码行数:32,代码来源:launcher_ambari_server.py

示例4: merge_cluster

# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import load_from_json [as 别名]
def merge_cluster(argv):
    """
    Merge the cluster to another running cluster
    :param argv: sys.argv
    :return: None
    """
    if len(argv) < 4:
        print_help()
        exit(1)

    merged_cluster_name = argv[2]
    merged_cluster = Cluster.load_from_json(merged_cluster_name)
    if merged_cluster is None:
        print merged_cluster_name, " cluster not found"
        exit(1)

    if merged_cluster.state != Cluster.STATE_FREE:
        print merged_cluster_name, " cluster is already running"
        exit(1)

    weave_ip = ""
    external_ip = ""
    extended_cluster_name = ""
    if len(argv) == 4:
        extended_cluster_name = argv[3]
        extended_cluster = Cluster.load_from_json(extended_cluster_name)
        if extended_cluster is None:
            print extended_cluster_name, " cluster not found"
            exit(1)

        if extended_cluster.state != Cluster.STATE_RUNNING:
            if extended_cluster.state == Cluster.STATE_FREE:
                print extended_cluster_name, " cluster is not running, can't be extended"
            elif extended_cluster.state.startswith(Cluster.STATE_MERGE):
                print extended_cluster_name, " cluster is merged to another cluster, can't be extended"
            exit(1)

        ambari_server = extended_cluster.get_ambari_server_vm()
        weave_ip = ambari_server.weave_internal_ip
        external_ip = ambari_server.external_ip

    elif len(argv) == 5:
        weave_ip = argv[3]
        external_ip = argv[4]

    else:
        print_help()
        exit(1)

    if merged_cluster.get_ambari_server_vm() is not None:
        print merged_cluster, " cluster has one VM to install Ambari-server, which will NOT be merged"

    print "Configuring cluster"
    print "Check output folder: ", Config.ATTRIBUTES["output_folder"]
    merged_cluster.run_cluster(weave_ip, external_ip)

    data = Data()
    data.set_cluster_state(merged_cluster_name, "{0} to {1}".format(Cluster.STATE_MERGE, extended_cluster_name))

    # reset terminal. The SSH subprocess call of the program cause the terminal display to be abnormal.
    # This is an unsolved minor issue.
    subprocess.call(["reset"])
    print "Complete"
开发者ID:pengchengxu,项目名称:ambari-agent-simulator,代码行数:65,代码来源:launcher_cluster.py


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