Exemple #1
0
def stress_port():
    # TODO This should be creating the network and subnet for the port
    client = horde.get_client()
    port_dict = {"port": {"network_id": horde.CONF["network_id"]}}
    if horde.CONF["auth_strategy"] == "noauth":
        port_dict["port"]["tenant_id"] = horde.CONF["tenant_name"]

    try:
        port = client.create_port(port_dict)
        p = port["port"]
        if "mac_address" not in p:
            raise Exception("No MAC address found")
        if "fixed_ips" not in p:
            raise Exception("No MAC address found")
        for ip in p["fixed_ips"]:
            if "subnet_id" not in ip:
                raise Exception("No subnet found")
            if "ip_address" not in ip:
                raise Exception("No ip_address found")
            if len(ip["subnet_id"]) == 0:
                raise Exception("Subnet is empty")
            if len(ip["ip_address"]) == 0:
                raise Exception("IP address is empty")
    except Exception as e:
        return (False, e)
    return (True, port)
Exemple #2
0
def endpoint_test():
    client = horde.get_client()
    net_dict = {"network": {"name": "testnetwork"}}

    def _rescue_nil(func, *args):
        try:
            func(*args)
        except Exception as e:
            print "Delete failed", traceback.format_exc(e)

    try:
        net_resource = test_create(client, "network", net_dict)
        subnet_dict = {
            "subnet": {"network_id": net_resource["network"]["id"], "cidr": "192.168.0.0/24", "ip_version": 4}
        }
        port_dict = {"port": {"network_id": net_resource["network"]["id"]}}
        subnet_resource = test_create(client, "subnet", subnet_dict)
        port_resource = test_create(client, "port", port_dict)

        test_list(client, "ports", port_resource["port"])
        test_list(client, "subnets", subnet_resource["subnet"])
        test_list(client, "networks", net_resource["network"])

        test_show(client, "port", port_resource["port"])
        test_show(client, "subnet", subnet_resource["subnet"])
        test_show(client, "network", net_resource["network"])

        print "Network, subnet and port created"
    except Exception as e:
        print e
    finally:
        _rescue_nil(client.delete_port, port_resource["port"]["id"])
        _rescue_nil(client.delete_subnet, subnet_resource["subnet"]["id"])
        _rescue_nil(client.delete_network, net_resource["network"]["id"])
        print "Finished deleteing network, subnet and port"
Exemple #3
0
def teardown(port):
    # This isn't working perfectly, and we need to find out why

    teardown_retries = 0
    # auth_retries = 0
    while True:
        try:
            client = horde.get_client()
            if isinstance(port, dict):
                client.delete_port(port["port"]["id"])
            break
        # This needs to break out unless it's auth
        # except neutronclient.Exception:
        #   continue
        #   auth_retries += 1
        except Exception as e:
            teardown_retries += 1
            if teardown_retries == horde.CONF["teardown_retries"]:
                print e
                break