aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/os-net-config/samples/nfvswitch.json2
-rw-r--r--etc/os-net-config/samples/nfvswitch.yaml4
-rw-r--r--os_net_config/impl_ifcfg.py12
-rw-r--r--os_net_config/objects.py19
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py4
-rw-r--r--os_net_config/tests/test_objects.py10
6 files changed, 22 insertions, 29 deletions
diff --git a/etc/os-net-config/samples/nfvswitch.json b/etc/os-net-config/samples/nfvswitch.json
index 2d8af8a..b081de9 100644
--- a/etc/os-net-config/samples/nfvswitch.json
+++ b/etc/os-net-config/samples/nfvswitch.json
@@ -2,7 +2,7 @@
"network_config": [
{
"type": "nfvswitch_bridge",
- "cpus": "2,3,4,5",
+ "options": "-c 2,3,4,5",
"members": [
{
"type": "interface",
diff --git a/etc/os-net-config/samples/nfvswitch.yaml b/etc/os-net-config/samples/nfvswitch.yaml
index 5af3f70..d7571ae 100644
--- a/etc/os-net-config/samples/nfvswitch.yaml
+++ b/etc/os-net-config/samples/nfvswitch.yaml
@@ -1,7 +1,7 @@
network_config:
-
type: nfvswitch_bridge
- cpus: "2,3,4,5"
+ options: "-c 2,3,4,5"
members:
-
type: interface
@@ -22,4 +22,4 @@ network_config:
vlan_id: 202
addresses:
-
- ip_netmask: 172.16.1.6/24 \ No newline at end of file
+ ip_netmask: 172.16.1.6/24
diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py
index ab8b094..56f2b33 100644
--- a/os_net_config/impl_ifcfg.py
+++ b/os_net_config/impl_ifcfg.py
@@ -63,7 +63,7 @@ class IfcfgNetConfig(os_net_config.NetConfig):
self.interface_data = {}
self.ivsinterface_data = {}
self.nfvswitch_intiface_data = {}
- self.nfvswitch_cpus = None
+ self.nfvswitch_options = None
self.vlan_data = {}
self.route_data = {}
self.route6_data = {}
@@ -446,7 +446,7 @@ class IfcfgNetConfig(os_net_config.NetConfig):
is running, the nfvswitch virtual switch will be available.
:param bridge: The NfvswitchBridge object to add.
"""
- self.nfvswitch_cpus = bridge.cpus
+ self.nfvswitch_options = bridge.options
def add_bond(self, bond):
"""Add an OvsBond object to the net config object.
@@ -583,9 +583,9 @@ class IfcfgNetConfig(os_net_config.NetConfig):
nfvswitch_internal_ifaces):
"""Generate configuration content for nfvswitch."""
- cpu_str = ""
- if self.nfvswitch_cpus:
- cpu_str = " -c " + self.nfvswitch_cpus
+ options_str = ""
+ if self.nfvswitch_options:
+ options_str = self.nfvswitch_options
ifaces = []
for iface in nfvswitch_ifaces:
@@ -599,7 +599,7 @@ class IfcfgNetConfig(os_net_config.NetConfig):
ifaces.append(iface)
internal_str = ''.join(ifaces)
- data = "SETUP_ARGS=\"%s%s%s\"" % (cpu_str, iface_str, internal_str)
+ data = "SETUP_ARGS=\"%s%s%s\"" % (options_str, iface_str, internal_str)
return data
def apply(self, cleanup=False, activate=True):
diff --git a/os_net_config/objects.py b/os_net_config/objects.py
index 8fab1ab..3c67ada 100644
--- a/os_net_config/objects.py
+++ b/os_net_config/objects.py
@@ -628,7 +628,7 @@ class NfvswitchBridge(_BaseOpts):
def __init__(self, name='nfvswitch', use_dhcp=False, use_dhcpv6=False,
addresses=None, routes=None, mtu=1500, members=None,
nic_mapping=None, persist_mapping=False, defroute=True,
- dhclient_args=None, dns_servers=None, cpus=""):
+ dhclient_args=None, dns_servers=None, options=""):
addresses = addresses or []
routes = routes or []
members = members or []
@@ -638,7 +638,7 @@ class NfvswitchBridge(_BaseOpts):
nic_mapping, persist_mapping,
defroute, dhclient_args,
dns_servers)
- self.cpus = cpus
+ self.options = options
self.members = members
for member in self.members:
if isinstance(member, OvsBond) or isinstance(member, LinuxBond):
@@ -667,16 +667,9 @@ class NfvswitchBridge(_BaseOpts):
msg = 'Members must be a list.'
raise InvalidConfigException(msg)
- cpus = ''
- cpus_json = json.get('cpus')
- if cpus_json:
- if isinstance(cpus_json, basestring):
- cpus = cpus_json
- else:
- msg = '"cpus" must be a string of numbers separated by commas.'
- raise InvalidConfigException(msg)
- else:
- msg = 'Config "cpus" is mandatory.'
+ options = json.get('options')
+ if not options:
+ msg = 'Config "options" is mandatory.'
raise InvalidConfigException(msg)
return NfvswitchBridge(name, use_dhcp=use_dhcp, use_dhcpv6=use_dhcpv6,
@@ -684,7 +677,7 @@ class NfvswitchBridge(_BaseOpts):
members=members, nic_mapping=nic_mapping,
persist_mapping=persist_mapping,
defroute=defroute, dhclient_args=dhclient_args,
- dns_servers=dns_servers, cpus=cpus)
+ dns_servers=dns_servers, options=options)
class LinuxTeam(_BaseOpts):
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py
index c3acbc8..8586daa 100644
--- a/os_net_config/tests/test_impl_ifcfg.py
+++ b/os_net_config/tests/test_impl_ifcfg.py
@@ -318,7 +318,7 @@ IPADDR=172.16.2.7
NETMASK=255.255.255.0
"""
-_NFVSWITCH_CONFIG = ('SETUP_ARGS=\" -c 2,3,4,5 -u em1 -m storage5\"')
+_NFVSWITCH_CONFIG = ('SETUP_ARGS=\"-c 2,3,4,5 -u em1 -m storage5\"')
_OVS_IFCFG_PATCH_PORT = """# This file is autogenerated by os-net-config
DEVICE=br-pub-patch
@@ -590,7 +590,7 @@ class TestIfcfgNetConfig(base.TestCase):
iface_name = nfvswitch_internal.name
bridge = objects.NfvswitchBridge(members=[interface,
nfvswitch_internal],
- cpus="2,3,4,5")
+ options="-c 2,3,4,5")
self.provider.add_interface(interface)
self.provider.add_nfvswitch_internal(nfvswitch_internal)
self.provider.add_nfvswitch_bridge(bridge)
diff --git a/os_net_config/tests/test_objects.py b/os_net_config/tests/test_objects.py
index 26b16ad..7500392 100644
--- a/os_net_config/tests/test_objects.py
+++ b/os_net_config/tests/test_objects.py
@@ -407,7 +407,7 @@ class TestNfvswitchBridge(base.TestCase):
def test_from_json(self):
data = """{
"type": "nfvswitch_bridge",
-"cpus": "2,3,4,5",
+"options": "-c 2,3,4,5",
"members": [
{"type": "interface","name": "nic1"},
{"type": "interface","name": "nic2"}
@@ -416,7 +416,7 @@ class TestNfvswitchBridge(base.TestCase):
"""
bridge = objects.object_from_json(json.loads(data))
self.assertEqual("nfvswitch", bridge.name)
- self.assertEqual("2,3,4,5", bridge.cpus)
+ self.assertEqual("-c 2,3,4,5", bridge.options)
interface1 = bridge.members[0]
self.assertEqual("nic1", interface1.name)
self.assertEqual(False, interface1.ovs_port)
@@ -431,7 +431,7 @@ class TestNfvswitchInterface(base.TestCase):
def test_nfvswitch_internal_from_json(self):
data = """{
"type": "nfvswitch_bridge",
-"cpus": "2,3,4,5",
+"options": "-c 2,3,4,5",
"members": [
{"type": "nfvswitch_internal", "name": "storage", "vlan_id": 202},
{"type": "nfvswitch_internal", "name": "api", "vlan_id": 201}
@@ -440,7 +440,7 @@ class TestNfvswitchInterface(base.TestCase):
"""
bridge = objects.object_from_json(json.loads(data))
self.assertEqual("nfvswitch", bridge.name)
- self.assertEqual("2,3,4,5", bridge.cpus)
+ self.assertEqual("-c 2,3,4,5", bridge.options)
interface1 = bridge.members[0]
self.assertEqual("storage202", interface1.name)
interface2 = bridge.members[1]
@@ -451,7 +451,7 @@ class TestNfvswitchInterface(base.TestCase):
def test_bond_interface_from_json(self):
data = """{
"type": "nfvswitch_bridge",
-"cpus": "2,3,4,5",
+"options": "-c 2,3,4,5",
"members": [{
"type": "linux_bond", "name": "bond1", "members":
[{"type": "interface", "name": "nic2"},