コード例 #1
0
ファイル: mgmgctl.py プロジェクト: bhyvex/mgmtcl
def start_vm(template_id, tag, count, node):
    from management_api import ManagementApi
    from management_api import NotFoundException
    mgmt_api = ManagementApi(host)
    new_ids = None
    try:
        new_ids = mgmt_api.start_vm(template_id, count, tag=tag, node=node)
    except NotFoundException:
        template_id_from_list = mgmt_api.search_template_by_name(template_id)
        if template_id_from_list:
            new_ids = mgmt_api.start_vm(template_id_from_list,
                                        count,
                                        tag=tag,
                                        node=node)
        else:
            click.echo("Template not found")
            exit(-1)
    if new_ids:
        click.echo("\nvms created")
        vms_created = []
        for new_id in new_ids:
            vm_info = mgmt_api.show_vm(new_id)
            info_to_show = {
                'id': new_id,
                'state': vm_info.get('instance_state')
            }
            vms_created.append(info_to_show)
        from formatter import Formatter
        formatter = Formatter()
        click.echo(formatter.format_list_of_dicts(vms_created))
    else:
        click.echo("\ncreate failed")
コード例 #2
0
ファイル: mgmgctl.py プロジェクト: bhyvex/mgmtcl
def list_templates():
    from management_api import ManagementApi
    mgmt_api = ManagementApi(host)

    result = mgmt_api.list_registry()
    from formatter import Formatter
    formatter = Formatter()
    click.echo(formatter.format_list_of_dicts(result))
コード例 #3
0
ファイル: mgmgctl.py プロジェクト: bhyvex/mgmtcl
def list_vms():
    from management_api import ManagementApi
    mgmt_api = ManagementApi(host)
    list_of_vms = mgmt_api.list()
    click.echo("\nvms:\n")
    from formatter import Formatter
    formatter = Formatter()
    click.echo(formatter.format_list_of_dicts(list_of_vms))
    click.echo("\n")
コード例 #4
0
ファイル: mgmgctl.py プロジェクト: bhyvex/mgmtcl
def show_node(node_id):
    from management_api import ManagementApi
    from management_api import NotFoundException
    mgmt_api = ManagementApi(host)
    try:
        result = mgmt_api.show_node(node_id)
    except NotFoundException:
        click.echo("no such node")
        exit(-1)
    from formatter import Formatter
    formatter = Formatter()
    click.echo(formatter.format_list_of_dicts(result))