Skip to content

Commit

Permalink
DB loader script: use created security groups
Browse files Browse the repository at this point in the history
The db loader script can create security groups and virtual machine
interfaces but by default that interfaces are associated to the default
project security group. That patch permits to associate created security
groups to virtual machines interfaces. It's choosing security groups
randomly.

Change-Id: Ide03dc62eb6dfd193a57cbe822b01e55673fc57f
Closes-Bug: #1662276
  • Loading branch information
Édouard Thuleau committed Feb 6, 2017
1 parent a96dc1e commit 068e87f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/config/utils/db-loader/contrail_db_loader/main.py
Expand Up @@ -175,7 +175,8 @@ def create_resources(self):
self._rules_per_security_group)
elif resource.type == 'virtual-machine-interface':
_, time_elapsed = resource.create_resources(
self._resource_map['virtual-network'].amount_per_project)
self._resource_map['virtual-network'].amount_per_project,
self._resource_map['security-group'].amount_per_project)
else:
_, time_elapsed = resource.create_resources()
logger.info("%d resources were created to load %d '%s' in "
Expand Down
Expand Up @@ -26,7 +26,7 @@ def total_amount(self):
return self._project_amount * self._amount_per_project * 3

@timeit(return_time_elapsed=True)
def create_resources(self, vn_per_project):
def create_resources(self, vn_per_project, sg_per_project):
vms = []
with self._uuid_cf.batch(queue_size=self._batch_size) as uuid_batch,\
self._fqname_cf.batch(queue_size=self._batch_size) as \
Expand Down Expand Up @@ -57,6 +57,7 @@ def create_resources(self, vn_per_project):
for project_idx in range(self._project_amount):
for resource_idx in range(self._amount_per_project):
vn_idx = randint(0, vn_per_project - 1)
sg_idx = randint(0, sg_per_project - 1)
fq_name = [
'default-domain',
'project-%d' % project_idx,
Expand Down Expand Up @@ -121,7 +122,7 @@ def create_resources(self, vn_per_project):
'to': [
'default-domain',
'project-%d' % project_idx,
'default',
'security-group-%d' % sg_idx,
],
'attr': None,
}],
Expand Down

0 comments on commit 068e87f

Please sign in to comment.