aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--yardstick/orchestrator/kubernetes.py11
-rw-r--r--yardstick/tests/unit/orchestrator/test_kubernetes.py7
2 files changed, 8 insertions, 10 deletions
diff --git a/yardstick/orchestrator/kubernetes.py b/yardstick/orchestrator/kubernetes.py
index 3c7559c7d..bb01b33fa 100644
--- a/yardstick/orchestrator/kubernetes.py
+++ b/yardstick/orchestrator/kubernetes.py
@@ -316,10 +316,10 @@ class CustomResourceDefinitionObject(object):
class NetworkObject(object):
- MANDATORY_PARAMETERS = {'name', 'plugin', 'args'}
+ MANDATORY_PARAMETERS = {'plugin', 'args'}
KIND = 'Network'
- def __init__(self, **kwargs):
+ def __init__(self, name, **kwargs):
if not self.MANDATORY_PARAMETERS.issubset(kwargs):
missing_parameters = ', '.join(
str(param) for param in
@@ -327,7 +327,7 @@ class NetworkObject(object):
raise exceptions.KubernetesNetworkObjectDefinitionError(
missing_parameters=missing_parameters)
- self._name = kwargs['name']
+ self._name = name
self._plugin = kwargs['plugin']
self._args = kwargs['args']
self._crd = None
@@ -417,7 +417,7 @@ class KubernetesTemplate(object):
context_cfg = copy.deepcopy(context_cfg)
servers_cfg = context_cfg.pop('servers', {})
crd_cfg = context_cfg.pop('custom_resources', [])
- networks_cfg = context_cfg.pop('networks', [])
+ networks_cfg = context_cfg.pop('networks', {})
self.name = name
self.ssh_key = '{}-key'.format(name)
@@ -429,7 +429,8 @@ class KubernetesTemplate(object):
for rc, cfg in self.rcs.items()]
self.crd = [CustomResourceDefinitionObject(self.name, **crd)
for crd in crd_cfg]
- self.network_objs = [NetworkObject(**nobj) for nobj in networks_cfg]
+ self.network_objs = [NetworkObject(net_name, **net_data)
+ for net_name, net_data in networks_cfg.items()]
self.pods = []
def _get_rc_name(self, rc_name):
diff --git a/yardstick/tests/unit/orchestrator/test_kubernetes.py b/yardstick/tests/unit/orchestrator/test_kubernetes.py
index cc1b37569..f248338ee 100644
--- a/yardstick/tests/unit/orchestrator/test_kubernetes.py
+++ b/yardstick/tests/unit/orchestrator/test_kubernetes.py
@@ -433,13 +433,10 @@ class NetworkObjectTestCase(base.BaseUnitTestCase):
def test__init_missing_parameter(self):
with self.assertRaises(
exceptions.KubernetesNetworkObjectDefinitionError):
- kubernetes.NetworkObject(name='name', plugin='plugin')
+ kubernetes.NetworkObject('network_name', plugin='plugin')
with self.assertRaises(
exceptions.KubernetesNetworkObjectDefinitionError):
- kubernetes.NetworkObject(name='name', args='args')
- with self.assertRaises(
- exceptions.KubernetesNetworkObjectDefinitionError):
- kubernetes.NetworkObject(args='args', plugin='plugin')
+ kubernetes.NetworkObject('network_name', args='args')
@mock.patch.object(kubernetes_utils, 'get_custom_resource_definition')
def test_crd(self, mock_get_crd):