support segmentation_id for vlan provider network 61/36861/6
authorJingLu5 <lvjing5@huawei.com>
Mon, 3 Jul 2017 10:34:53 +0000 (10:34 +0000)
committerJing Lu <lvjing5@huawei.com>
Tue, 4 Jul 2017 09:39:24 +0000 (09:39 +0000)
If a network specified in the test case is a vlan provider network, new attribute "segmentation_id" can be used to specify the desired vlan tag in the test case network section:

networks:
  test-net:
    cidr: '192.168.1.0/24'
    provider: "vlan"
    physical_network: 'physnet1'
    segmentation_id: "1000"

If the "segmentation_id" attribute is absent, a random vlan tag will be allocated to the network.

Change-Id: Ic53852447a3c1bd8feb9ebd42d35f1ade3684be1
Signed-off-by: JingLu5 <lvjing5@huawei.com>
yardstick/benchmark/contexts/heat.py
yardstick/benchmark/contexts/model.py
yardstick/orchestrator/heat.py

index aa134d6..fed8fc3 100644 (file)
@@ -152,7 +152,8 @@ class HeatContext(Context):
         for network in self.networks.values():
             template.add_network(network.stack_name,
                                  network.physical_network,
-                                 network.provider)
+                                 network.provider,
+                                 network.segmentation_id)
             template.add_subnet(network.subnet_stack_name, network.stack_name,
                                 network.subnet_cidr)
 
index 1f8c6f1..5077a97 100644 (file)
@@ -107,6 +107,7 @@ class Network(Object):
         self.router = None
         self.physical_network = attrs.get('physical_network', 'physnet1')
         self.provider = attrs.get('provider', None)
+        self.segmentation_id = attrs.get('segmentation_id', None)
 
         if "external_network" in attrs:
             self.router = Router("router", self.name,
index a99d463..fd6c4f6 100644 (file)
@@ -1,4 +1,4 @@
-##############################################################################
+#############################################################################
 # Copyright (c) 2015-2017 Ericsson AB and others.
 #
 # All rights reserved. This program and the accompanying materials
@@ -230,7 +230,8 @@ name (i.e. %s).\
             'value': {'get_resource': name}
         }
 
-    def add_network(self, name, physical_network='physnet1', provider=None):
+    def add_network(self, name, physical_network='physnet1', provider=None,
+                    segmentation_id=None):
         """add to the template a Neutron Net"""
         log.debug("adding Neutron::Net '%s'", name)
         if provider is None:
@@ -247,6 +248,9 @@ name (i.e. %s).\
                     'physical_network': physical_network
                 }
             }
+            if segmentation_id:
+                seg_id_dit = {'segmentation_id': segmentation_id}
+                self.resources[name]["properties"].update(seg_id_dit)
 
     def add_server_group(self, name, policies):     # pragma: no cover
         """add to the template a ServerGroup"""