Exemplo n.º 1
0
def create_server(authTokenId,
                  novaUrl,
                  imageRef,
                  name,
                  ip,
                  network_id,
                  flavor_id=2,
                  host_name=None):
    server_name = name
    vm_entry = {
        "name": server_name,
        "imageRef": imageRef,
        "max_count": 1,
        "min_count": 1,
        "networks": [{
            "fixed_ip": ip,
            "uuid": network_id,
        }],
        "flavorRef": flavor_id
    }
    if host_name:
        vm_entry['availability_zone'] = ':' + host_name

    response, bodyJSON = \
        novaUtils.createServer(novaUrl, authTokenId, vm_entry)
    server = None
    host_key = 'OS-EXT-SVRS-ATTR:host'
    server = {'name': name, 'id': bodyJSON['server']['id']}
    return server
Exemplo n.º 2
0
def create_server_sriov(authTokenId,
                        novaUrl,
                        neutronUrl,
                        imageRef,
                        name,
                        ip,
                        network_id,
                        sriov_capacity,
                        sriov_vnic_required_vfs,
                        flavor_id=2,
                        host_name=None):
    print(novaUrl)
    sriov_port_Props = {
        "name": "powervc_attached",
        "network_id": network_id,
        "fixed_ips": [{
            "ip_address": ip
        }],
        "binding:vnic_type": "direct",
        "binding:profile": {
            "delete_with_instance": 1,
            "vnic_required_vfs": sriov_vnic_required_vfs,
            "capacity": sriov_capacity
        }
    }

    response, bodyJSON = \
        quantumUtils.createSriovPorts(neutronUrl, authTokenId, sriov_port_Props)
    print(bodyJSON['port']['id'])
    sriov_port = bodyJSON['port']['id']

    vm_entry = {
        "name": name,
        "imageRef": imageRef,
        "max_count": 1,
        "min_count": 1,
        "networks": [{
            "port": sriov_port
        }],
        "flavorRef": flavor_id,
    }
    if host_name:
        vm_entry['availability_zone'] = ':' + host_name

    response, bodyJSON = \
        novaUtils.createServer(novaUrl, authTokenId, vm_entry)
    server = None
    host_key = 'OS-EXT-SVRS-ATTR:host'
    if bodyJSON and 'server' in bodyJSON:
        server = {'name': name, 'id': bodyJSON['server']['id']}
    return server
Exemplo n.º 3
0
def create_server_md(authTokenId,
                     novaUrl,
                     imageRef,
                     name,
                     ip,
                     network_id,
                     block_device_mapping_list,
                     host_aggregate_id,
                     collocation_rule_id,
                     flavor_id=2,
                     host_name=None):
    print("entering create_server_md")
    server_name = name
    vm_entry = {
        "name": server_name,
        "imageRef": imageRef,
        "max_count": 1,
        "min_count": 1,
        "networks": [{
            "fixed_ip": ip,
            "uuid": network_id,
        }],
        "flavorRef": flavor_id,
        "block_device_mapping_v2": block_device_mapping_list
    }

    if host_name:
        vm_entry['availability_zone'] = ':' + host_name

    scheduler_hints_value = {
        "host_aggregate_id": str(host_aggregate_id),
        "group": str(collocation_rule_id)
    }
    vm_entry = {
        'server': vm_entry,
        'os:scheduler_hints': scheduler_hints_value
    }

    response, bodyJSON = \
        novaUtils.createServer(novaUrl, authTokenId, json.dumps(vm_entry))
    server = None
    host_key = 'OS-EXT-SVRS-ATTR:host'
    if bodyJSON and 'server' in bodyJSON:
        server = {'name': name, 'id': bodyJSON['server']['id']}
    return server