Merge branch 'master' into xos_auto_scaling_app_changes
diff --git a/xos/configurations/cord/README-VTN.md b/xos/configurations/cord/README-VTN.md
index d585d5c..8c25be8 100644
--- a/xos/configurations/cord/README-VTN.md
+++ b/xos/configurations/cord/README-VTN.md
@@ -31,6 +31,7 @@
# we need NAT rule so the neutron vtn plugin can talk to onos
# change 172.17.0.2 to the IP address for the ONOS container (use "docker inspect")
iptables -t nat -A PREROUTING -i br-ex -p tcp --dport 8101 -j DNAT --to-destination 172.17.0.2
+ iptables -t nat -A PREROUTING -i br-ex -p tcp --dport 8181 -j DNAT --to-destination 172.17.0.2
Compute nodes (all of them):
diff --git a/xos/model_policies/model_policy_Slice.py b/xos/model_policies/model_policy_Slice.py
index bbfbcc4..308d8cb 100644
--- a/xos/model_policies/model_policy_Slice.py
+++ b/xos/model_policies/model_policy_Slice.py
@@ -24,63 +24,68 @@
print "MODEL POLICY: slice existing_controllers=", existing_controllers
- all_controllers = Controller.objects.all()
+ all_controllers = Controller.objects.all()
for controller in all_controllers:
if controller not in existing_controllers:
print "MODEL POLICY: slice adding controller", controller
sd = ControllerSlice(slice=slice, controller=controller)
sd.save()
- # make sure slice has at least 1 public and 1 private networkd
- public_nets = []
- private_nets = []
- networks = Network.objects.filter(owner=slice)
- for network in networks:
- if not network.autoconnect:
- continue
- if network.template.name == 'Public dedicated IPv4':
- public_nets.append(network)
- elif network.template.name == 'Public shared IPv4':
- public_nets.append(network)
- elif network.template.name == 'Private':
- private_nets.append(network)
- if not public_nets:
- # ensure there is at least one public network, and default it to dedicated
- nat_net = Network(
- name = slice.name+'-nat',
- template = NetworkTemplate.objects.get(name='Public shared IPv4'),
- owner = slice
- )
- nat_net.save()
- public_nets.append(nat_net)
- print "MODEL POLICY: slice", slice, "made nat-net"
+ if slice.network in ["host", "bridged"]:
+ # Host and Bridged docker containers need no networks and they will
+ # only get in the way.
+ print "MODEL POLICY: Skipping network creation"
+ else:
+ # make sure slice has at least 1 public and 1 private networkd
+ public_nets = []
+ private_nets = []
+ networks = Network.objects.filter(owner=slice)
+ for network in networks:
+ if not network.autoconnect:
+ continue
+ if network.template.name == 'Public dedicated IPv4':
+ public_nets.append(network)
+ elif network.template.name == 'Public shared IPv4':
+ public_nets.append(network)
+ elif network.template.name == 'Private':
+ private_nets.append(network)
+ if not public_nets:
+ # ensure there is at least one public network, and default it to dedicated
+ nat_net = Network(
+ name = slice.name+'-nat',
+ template = NetworkTemplate.objects.get(name='Public shared IPv4'),
+ owner = slice
+ )
+ nat_net.save()
+ public_nets.append(nat_net)
+ print "MODEL POLICY: slice", slice, "made nat-net"
- if not private_nets:
- private_net = Network(
- name = slice.name+'-private',
- template = NetworkTemplate.objects.get(name='Private'),
- owner = slice
- )
- private_net.save()
- print "MODEL POLICY: slice", slice, "made private net"
- private_nets = [private_net]
- # create slice networks
- public_net_slice = None
- private_net_slice = None
- net_slices = NetworkSlice.objects.filter(slice=slice, network__in=private_nets+public_nets)
- for net_slice in net_slices:
- if net_slice.network in public_nets:
- public_net_slice = net_slice
- elif net_slice.network in private_nets:
- private_net_slice = net_slice
- if not public_net_slice:
- public_net_slice = NetworkSlice(slice=slice, network=public_nets[0])
- public_net_slice.save()
- print "MODEL POLICY: slice", slice, "made public_net_slice"
- if not private_net_slice:
- private_net_slice = NetworkSlice(slice=slice, network=private_nets[0])
- private_net_slice.save()
- print "MODEL POLICY: slice", slice, "made private_net_slice"
+ if not private_nets:
+ private_net = Network(
+ name = slice.name+'-private',
+ template = NetworkTemplate.objects.get(name='Private'),
+ owner = slice
+ )
+ private_net.save()
+ print "MODEL POLICY: slice", slice, "made private net"
+ private_nets = [private_net]
+ # create slice networks
+ public_net_slice = None
+ private_net_slice = None
+ net_slices = NetworkSlice.objects.filter(slice=slice, network__in=private_nets+public_nets)
+ for net_slice in net_slices:
+ if net_slice.network in public_nets:
+ public_net_slice = net_slice
+ elif net_slice.network in private_nets:
+ private_net_slice = net_slice
+ if not public_net_slice:
+ public_net_slice = NetworkSlice(slice=slice, network=public_nets[0])
+ public_net_slice.save()
+ print "MODEL POLICY: slice", slice, "made public_net_slice"
+ if not private_net_slice:
+ private_net_slice = NetworkSlice(slice=slice, network=private_nets[0])
+ private_net_slice.save()
+ print "MODEL POLICY: slice", slice, "made private_net_slice"
print "MODEL POLICY: slice", slice, "DONE"
diff --git a/xos/observers/vtn/steps/sync_tenant.py b/xos/observers/vtn/steps/sync_tenant.py
index 45f8722..5e8d0a2 100644
--- a/xos/observers/vtn/steps/sync_tenant.py
+++ b/xos/observers/vtn/steps/sync_tenant.py
@@ -17,6 +17,9 @@
logger = Logger(level=logging.INFO)
+# XXX should save and load this
+glo_saved_vtn_maps = []
+
class SyncTenant(SyncStep):
provides=[Tenant]
observes=Tenant
@@ -24,10 +27,13 @@
def __init__(self, **args):
SyncStep.__init__(self, **args)
- self.saved_vtn_maps = [] # TODO: load this
def call(self, **args):
+ global glo_saved_vtn_maps
+
logger.info("sync'ing vtn services")
+
+ vtn_maps = []
for service in Service.objects.all():
for id in service.get_vtn_src_ids():
dependencies = service.get_vtn_dependencies_ids()
@@ -36,13 +42,16 @@
vtn_maps.append( (id, dependency) )
for vtn_map in vtn_maps:
- if not (vtn_map in self.saved_vtn_maps):
- pass # call vtn rest api to add map
+ if not (vtn_map in glo_saved_vtn_maps):
+ print "XXX", vtn_map, glo_saved_vtn_maps
+ # call vtn rest api to add map
+ print "POST /onos/cordvtn/service-dependency/%s/%s" % (vtn_map[0], vtn_map[1])
- for vtn_map in self.saved_vtn_maps:
+ for vtn_map in glo_saved_vtn_maps:
if not vtn_map in vtn_maps:
- pass # call vtn rest api to delete map
+ # call vtn rest api to delete map
+ print "DELETE /onos/cordvtn/service-dependency/%s" % (vtn_map[0],)
- self.saved_vtn_maps = vtn_maps
+ glo_saved_vtn_maps = vtn_maps
# TODO: save this
diff --git a/xos/tosca/samples/vtn.yaml b/xos/tosca/samples/vtn.yaml
index 5ce4670..38db047 100644
--- a/xos/tosca/samples/vtn.yaml
+++ b/xos/tosca/samples/vtn.yaml
@@ -24,7 +24,7 @@
node: service_ONOS_VTN
relationship: tosca.relationships.TenantOfService
properties:
- dependencies: org.onosproject.openstackswitching, org.onosproject.cordvtn
+ dependencies: org.onosproject.openflow, org.onosproject.dhcp, org.onosproject.openstackswitching, org.onosproject.cordvtn
rest_onos/v1/network/configuration/: { get_artifact: [ SELF, vtn_network_cfg_json, LOCAL_FILE ] }
artifacts:
vtn_network_cfg_json: /root/setup/vtn-network-cfg.json