Exemple #1
0
def do_co_boot(cs, args):
    """Boot a new server."""

    boot_args, boot_kwargs = shell._boot(cs, args)

    if args.host and 'meta' in boot_kwargs:
        boot_kwargs['meta'].update({"co:target_host": args.host})
    elif args.host:
        boot_kwargs['meta'] = {"co:target_host":args.host}

    extra_boot_kwargs = utils.get_resource_manager_extra_kwargs(do_co_boot, args)
    boot_kwargs.update(extra_boot_kwargs)

    server = cs.cobalt.create(*boot_args, **boot_kwargs)

    # Keep any information (like adminPass) returned by create
    info = server._info
    server = cs.servers.get(info['id'])
    info.update(server._info)

    flavor = info.get('flavor', {})
    flavor_id = flavor.get('id', '')
    info['flavor'] = shell._find_flavor(cs, flavor_id).name

    image = info.get('image', {})
    image_id = image.get('id', '')
    info['image'] = shell._find_image(cs, image_id).name

    info.pop('links', None)
    info.pop('addresses', None)

    utils.print_dict(info)

    if args.poll:
        shell._poll_for_status(cs.servers.get, info['id'], 'building', ['active'])
Exemple #2
0
def _print_server(cs, server, minimal=False):
    # (dscannell): Note that the following method was taken from the main
    # novaclient code base. We duplicate it here to protect ourselves from
    # changes in the method signatures between versions of the novaclient.

    # By default when searching via name we will do a
    # findall(name=blah) and do a REST /details which is not the same
    # as a .get() and doesn't get the information about flavors and
    # images. This fixes it as we redo the call with the id which does a
    # .get() to get all informations.
    if not "flavor" in server._info:
        server = shell._find_server(cs, server.id)

    networks = server.networks
    info = server._info.copy()
    for network_label, address_list in networks.items():
        info["%s network" % network_label] = ", ".join(address_list)

    flavor = info.get("flavor", {})
    flavor_id = flavor.get("id", "")
    if minimal:
        info["flavor"] = flavor_id
    else:
        info["flavor"] = shell._find_flavor(cs, flavor_id).name

    image = info.get("image", {})
    if image:
        image_id = image.get("id", "")
        if minimal:
            info["image"] = image_id
        else:
            try:
                info["image"] = "%s (%s)" % (shell._find_image(cs, image_id).name, image_id)
            except:
                info["image"] = "%s (%s)" % ("Image not found", image_id)
    else:  # Booted from volume
        info["image"] = "Attempt to boot from volume - no image supplied"

    info.pop("links", None)
    info.pop("addresses", None)

    utils.print_dict(info)
Exemple #3
0
def do_gc_boot(cs, args):
    """Boot a new server."""

    boot_args, boot_kwargs = shell._boot(cs, args)

    if args.host and 'meta' in boot_kwargs:
        boot_kwargs['meta'].update({"gc:target_host": args.host})
    elif args.host:
        boot_kwargs['meta'] = {"gc:target_host": args.host}

    extra_boot_kwargs = utils.get_resource_manager_extra_kwargs(
        do_gc_boot, args)
    boot_kwargs.update(extra_boot_kwargs)

    server = cs.gridcentric.create(*boot_args, **boot_kwargs)

    # Keep any information (like adminPass) returned by create
    info = server._info
    server = cs.servers.get(info['id'])
    info.update(server._info)

    flavor = info.get('flavor', {})
    flavor_id = flavor.get('id', '')
    info['flavor'] = shell._find_flavor(cs, flavor_id).name

    image = info.get('image', {})
    image_id = image.get('id', '')
    info['image'] = shell._find_image(cs, image_id).name

    info.pop('links', None)
    info.pop('addresses', None)

    utils.print_dict(info)

    if args.poll:
        shell._poll_for_status(cs.servers.get, info['id'], 'building',
                               ['active'])
Exemple #4
0
def _print_server(cs, server, minimal=False):
    # (dscannell): Note that the following method was taken from the main
    # novaclient code base. We duplicate it here to protect ourselves from
    # changes in the method signatures between versions of the novaclient.

    # By default when searching via name we will do a
    # findall(name=blah) and do a REST /details which is not the same
    # as a .get() and doesn't get the information about flavors and
    # images. This fixes it as we redo the call with the id which does a
    # .get() to get all informations.
    if not 'flavor' in server._info:
        server = shell._find_server(cs, server.id)

    networks = server.networks
    info = server._info.copy()
    for network_label, address_list in networks.items():
        info['%s network' % network_label] = ', '.join(address_list)

    flavor = info.get('flavor', {})
    flavor_id = flavor.get('id', '')
    if minimal:
        info['flavor'] = flavor_id
    else:
        info['flavor'] = shell._find_flavor(cs, flavor_id).name

    image = info.get('image', {})
    image_id = image.get('id', '')
    if minimal:
        info['image'] = image_id
    else:
        info['image'] = shell._find_image(cs, image_id).name

    info.pop('links', None)
    info.pop('addresses', None)

    utils.print_dict(info)
Exemple #5
0
def _print_server(cs, server, minimal=False):
    # (dscannell): Note that the follow method was taken from the
    # main novaclient code base. We duplicate it here to protect ourselves
    # changes in the method signatures between versions of the novaclient.

    # By default when searching via name we will do a
    # findall(name=blah) and due a REST /details which is not the same
    # as a .get() and doesn't get the information about flavors and
    # images. This fix it as we redo the call with the id which does a
    # .get() to get all informations.
    if not 'flavor' in server._info:
        server = shell._find_server(cs, server.id)

    networks = server.networks
    info = server._info.copy()
    for network_label, address_list in networks.items():
        info['%s network' % network_label] = ', '.join(address_list)

    flavor = info.get('flavor', {})
    flavor_id = flavor.get('id', '')
    if minimal:
        info['flavor'] = flavor_id
    else:
        info['flavor'] = shell._find_flavor(cs, flavor_id).name

    image = info.get('image', {})
    image_id = image.get('id', '')
    if minimal:
        info['image'] = image_id
    else:
        info['image'] = shell._find_image(cs, image_id).name

    info.pop('links', None)
    info.pop('addresses', None)

    utils.print_dict(info)
Exemple #6
0
                        image_name = fixedimage_name
                        instance_name = fixedInstancename + "%s" % (nodeName)
                except:
                    print "\n\n --------- ERROR IN THE NODES DICTIONARY on key %s-------------" %nodeName
                    print " using defualt parameters to launch"
                    region_name = fixedRegion_name
                    flavor_name = fixedflavor_name
                    image_name = fixedimage_name
                    instance_name = fixedInstancename + "%s" % (nodeName)
                                    

                print_msg("\nLaunching VM %d/%d on region: %s" % (i+1, numNodes, region_name))
                c=nclient.Client(user, password, tenant_name, auth_url, region_name=region_name, no_cache=True)
                time.sleep(5)
            
                image1=nshell._find_image(c, image_name)
                flavor1=nshell._find_flavor(c, flavor_name)

                seclist=[]
                seclist.append(sec_group_name)

                secgroup=nshell._get_secgroup(c, sec_group_name)
                try:
                    c.security_group_rules.create(secgroup.id, "TCP", 22, 22, "10.0.0.0/8")
                except:
                    pass
                try:
                    c.security_group_rules.create(secgroup.id, "UDP", 4789, 4789, "10.0.0.0/8")
                except:
                    pass
                try: