diff options
author | Sawyer Bergeron <sbergeron@iol.unh.edu> | 2020-10-22 19:00:45 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2020-10-22 19:00:45 +0000 |
commit | 204076852d5518ae515d79c362d5e4beea17d8e4 (patch) | |
tree | bfad74f1ce2d9b7ad7eda231d79582bebb5a588e | |
parent | c9c18a40b54af4a2fa501e55d0d5147d14a0a62d (diff) | |
parent | 9f426a2ab31b60383e1c73fb2948c06656435ba3 (diff) |
Merge "Fix quick booking allocation of private vlans for pods"2.0.99
-rw-r--r-- | src/account/models.py | 6 | ||||
-rw-r--r-- | src/dashboard/testing_utils.py | 8 | ||||
-rw-r--r-- | src/resource_inventory/resource_manager.py | 7 | ||||
-rw-r--r-- | src/workflow/resource_bundle_workflow.py | 2 |
4 files changed, 12 insertions, 11 deletions
diff --git a/src/account/models.py b/src/account/models.py index 2d0293f..40de4d8 100644 --- a/src/account/models.py +++ b/src/account/models.py @@ -80,12 +80,12 @@ class VlanManager(models.Model): # if they use QinQ or a vxlan overlay, for example allow_overlapping = models.BooleanField() - def get_vlan(self, count=1): + def get_vlans(self, count=1): """ - Return the ID of available vlans, but does not reserve them. + Return the IDs of available vlans as a list[int], but does not reserve them. Will throw index exception if not enough vlans are available. - If count == 1, the return value is an int. Otherwise, it is a list of ints. + Always returns a list of ints """ allocated = [] vlans = json.loads(self.vlans) diff --git a/src/dashboard/testing_utils.py b/src/dashboard/testing_utils.py index d7a346e..5be6379 100644 --- a/src/dashboard/testing_utils.py +++ b/src/dashboard/testing_utils.py @@ -96,11 +96,11 @@ def make_network(name, lab, grb, public): lab.vlan_manager.reserve_public_vlan(public_net.vlan) network.vlan_id = public_net.vlan else: - private_net = lab.vlan_manager.get_vlan() - if not private_net: + private_nets = lab.vlan_manager.get_vlans(count=1) + if not private_nets: raise Exception("No more generic vlans are available") - lab.vlan_manager.reserve_vlans([private_net]) - network.vlan_id = private_net + lab.vlan_manager.reserve_vlans(private_nets) + network.vlan_id = private_nets[0] network.save() return network diff --git a/src/resource_inventory/resource_manager.py b/src/resource_inventory/resource_manager.py index 81f4747..140cc09 100644 --- a/src/resource_inventory/resource_manager.py +++ b/src/resource_inventory/resource_manager.py @@ -77,9 +77,10 @@ class ResourceManager: vlan_manager.reserve_public_vlan(public_net.vlan) networks[network.name] = public_net.vlan else: - vlan = vlan_manager.get_vlan() - vlan_manager.reserve_vlans(vlan) - networks[network.name] = vlan + # already throws if can't get requested count, so can always index in @ 0 + vlans = vlan_manager.get_vlans(count=1) + vlan_manager.reserve_vlans(vlans[0]) + networks[network.name] = vlans[0] return networks def instantiateTemplate(self, resource_template): diff --git a/src/workflow/resource_bundle_workflow.py b/src/workflow/resource_bundle_workflow.py index 404224e..63a9519 100644 --- a/src/workflow/resource_bundle_workflow.py +++ b/src/workflow/resource_bundle_workflow.py @@ -294,7 +294,7 @@ class Define_Nets(WorkflowStep): if lab is None or lab.vlan_manager is None: return None try: - vlans = lab.vlan_manager.get_vlan(count=lab.vlan_manager.block_size) + vlans = lab.vlan_manager.get_vlans(count=lab.vlan_manager.block_size) self.repo_put(self.repo.VLANS, vlans) return vlans except Exception: |