if debug == True:
print r.text
r.raise_for_status()
-
+
def get_tenant_data():
return {
{
"classifier-ref": [
{
- "name": "icmp",
- "instance-name": "icmp"
+ "name": "icmp-in",
+ "instance-name": "icmp",
+ "direction": "in"
+ },
+ {
+ "name": "icmp-out",
+ "instance-name": "icmp",
+ "direction": "out"
}
],
"action-ref": [
}
# Main definition - constants
-
+
# =======================
# MENUS FUNCTIONS
# =======================
-
+
# Main menu
# =======================
# MAIN PROGRAM
# =======================
-
+
# Main Program
def get_tenant_uri():
}
]
},
-
+
]
}
}
-
+
def get_tunnel_uri():
return "/restconf/config/opendaylight-inventory:nodes"
return [{
"input": {
- "endpoint-group": "clients",
+ "endpoint-group": "clients",
"network-containment" : "subnet-10.0.35.0/24",
- "l2-context": "bridge-domain1",
- "mac-address": "00:00:00:00:35:02",
+ "l2-context": "bridge-domain1",
+ "mac-address": "00:00:00:00:35:02",
"l3-address": [
{
- "ip-address": "10.0.35.2",
+ "ip-address": "10.0.35.2",
"l3-context": "l3-context-vrf-red"
}
- ],
- "port-name": "vethl-h35_2",
+ ],
+ "port-name": "vethl-h35_2",
"tenant": "tenant-red"
}
},
{
"input": {
- "endpoint-group": "clients",
+ "endpoint-group": "clients",
"network-containment" : "subnet-10.0.35.0/24",
- "l2-context": "bridge-domain1",
- "mac-address": "00:00:00:00:35:03",
+ "l2-context": "bridge-domain1",
+ "mac-address": "00:00:00:00:35:03",
"l3-address": [
{
- "ip-address": "10.0.35.3",
+ "ip-address": "10.0.35.3",
"l3-context": "l3-context-vrf-red"
}
- ],
- "port-name": "vethl-h35_3",
+ ],
+ "port-name": "vethl-h35_3",
"tenant": "tenant-red"
}
},
{
"input": {
- "endpoint-group": "clients",
+ "endpoint-group": "clients",
"network-containment" : "subnet-10.0.35.0/24",
- "l2-context": "bridge-domain1",
- "mac-address": "00:00:00:00:35:04",
+ "l2-context": "bridge-domain1",
+ "mac-address": "00:00:00:00:35:04",
"l3-address": [
{
- "ip-address": "10.0.35.4",
+ "ip-address": "10.0.35.4",
"l3-context": "l3-context-vrf-red"
}
- ],
- "port-name": "vethl-h35_4",
+ ],
+ "port-name": "vethl-h35_4",
"tenant": "tenant-red"
}
},
{
"input": {
- "endpoint-group": "clients",
+ "endpoint-group": "clients",
"network-containment" : "subnet-10.0.35.0/24",
- "l2-context": "bridge-domain1",
- "mac-address": "00:00:00:00:35:05",
+ "l2-context": "bridge-domain1",
+ "mac-address": "00:00:00:00:35:05",
"l3-address": [
{
- "ip-address": "10.0.35.5",
+ "ip-address": "10.0.35.5",
"l3-context": "l3-context-vrf-red"
}
- ],
- "port-name": "vethl-h35_5",
+ ],
+ "port-name": "vethl-h35_5",
"tenant": "tenant-red"
}
},
{
"input": {
- "endpoint-group": "webservers",
+ "endpoint-group": "webservers",
"network-containment" : "subnet-10.0.36.0/24",
- "l2-context": "bridge-domain1",
- "mac-address": "00:00:00:00:36:02",
+ "l2-context": "bridge-domain1",
+ "mac-address": "00:00:00:00:36:02",
"l3-address": [
{
- "ip-address": "10.0.36.2",
+ "ip-address": "10.0.36.2",
"l3-context": "l3-context-vrf-red"
}
- ],
- "port-name": "vethl-h36_2",
+ ],
+ "port-name": "vethl-h36_2",
"tenant": "tenant-red"
}
},
{
"input": {
- "endpoint-group": "webservers",
+ "endpoint-group": "webservers",
"network-containment" : "subnet-10.0.36.0/24",
- "l2-context": "bridge-domain1",
- "mac-address": "00:00:00:00:36:03",
+ "l2-context": "bridge-domain1",
+ "mac-address": "00:00:00:00:36:03",
"l3-address": [
{
- "ip-address": "10.0.36.3",
+ "ip-address": "10.0.36.3",
"l3-context": "l3-context-vrf-red"
}
- ],
- "port-name": "vethl-h36_3",
+ ],
+ "port-name": "vethl-h36_3",
"tenant": "tenant-red"
}
},
{
"input": {
- "endpoint-group": "webservers",
+ "endpoint-group": "webservers",
"network-containment" : "subnet-10.0.36.0/24",
- "l2-context": "bridge-domain1",
- "mac-address": "00:00:00:00:36:04",
+ "l2-context": "bridge-domain1",
+ "mac-address": "00:00:00:00:36:04",
"l3-address": [
{
- "ip-address": "10.0.36.4",
+ "ip-address": "10.0.36.4",
"l3-context": "l3-context-vrf-red"
}
- ],
- "port-name": "vethl-h36_4",
+ ],
+ "port-name": "vethl-h36_4",
"tenant": "tenant-red"
}
},{
"input": {
- "endpoint-group": "webservers",
+ "endpoint-group": "webservers",
"network-containment" : "subnet-10.0.36.0/24",
- "l2-context": "bridge-domain1",
- "mac-address": "00:00:00:00:36:05",
+ "l2-context": "bridge-domain1",
+ "mac-address": "00:00:00:00:36:05",
"l3-address": [
{
- "ip-address": "10.0.36.5",
+ "ip-address": "10.0.36.5",
"l3-context": "l3-context-vrf-red"
}
- ],
- "port-name": "vethl-h36_5",
+ ],
+ "port-name": "vethl-h36_5",
"tenant": "tenant-red"
}
}]
controller=os.environ.get('ODL')
if controller == None:
sys.exit("No controller set.")
-
+
print "tenants"
tenants=get(controller,DEFAULT_PORT,CONF_TENANT)
print tenants
-
+
print "sending tenant"
put(controller, DEFAULT_PORT, get_tenant_uri(), get_tenant_data(),True)
print "sending tunnel"
print "registering endpoints"
for endpoint in get_endpoint_data():
post(controller, DEFAULT_PORT, get_endpoint_uri(),endpoint,True)
-
-
-
-
+
+
+
+