Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
mockmodel.py | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/mockmodel.py b/mockmodel.py
index 142e81f..ae5cbc1 100644
--- a/mockmodel.py
+++ b/mockmodel.py
@@ -26,21 +26,25 @@ from collections import defaultdict
from lxml import objectify
from lxml.builder import E
-from wok.exception import NotFoundError, OperationFailed
+from wok.exception import InvalidParameter, NotFoundError, OperationFailed
from wok.objectstore import ObjectStore
from wok.utils import add_task
from wok.xmlutils.utils import xml_item_update
from wok.plugins.kimchi import imageinfo
+from wok.plugins.kimchi import netinfo
from wok.plugins.kimchi import osinfo
from wok.plugins.kimchi.model import cpuinfo
from wok.plugins.kimchi.model.groups import PAMGroupsModel
from wok.plugins.kimchi.model.host import DeviceModel
from wok.plugins.kimchi.model.host import DevicesModel
+from wok.plugins.kimchi.model.interfaces import InterfaceModel
+from wok.plugins.kimchi.model.interfaces import InterfacesModel
from wok.plugins.kimchi.model.libvirtstoragepool import IscsiPoolDef
from wok.plugins.kimchi.model.libvirtstoragepool import NetfsPoolDef
from wok.plugins.kimchi.model.libvirtstoragepool import StoragePoolDef
from wok.plugins.kimchi.model.model import Model
+from wok.plugins.kimchi.model.networks import NetworksModel
from wok.plugins.kimchi.model.storagepools import StoragePoolModel
from wok.plugins.kimchi.model.storagepools import StoragePoolsModel
from wok.plugins.kimchi.model.storagevolumes import StorageVolumeModel
@@ -123,6 +127,11 @@ class MockModel(Model):
DeviceModel.is_device_3D_controller = \
self._mock_device_is_device_3D_controller
DevicesModel.get_list = self._mock_devices_get_list
+ InterfacesModel.get_list = self._mock_interfaces_get_list
+ InterfaceModel.lookup = self._mock_interface_lookup
+ NetworksModel._set_network_vepa = self.networks_set_network_vepa
+ self.networks = NetworksModel(conn=self.conn,
+ objstore_loc=objstore_loc)
StoragePoolsModel._check_lvm = self._check_lvm
StoragePoolModel._update_lvm_disks = self._update_lvm_disks
StoragePoolModel._pool_used_by_template = self._pool_used_by_template
@@ -350,6 +359,36 @@ class MockModel(Model):
def _mock_device_lookup(self, dev_name):
return self._mock_devices.devices[dev_name]
+ def _mock_interfaces_get_list(self):
+ return list(set(netinfo.all_favored_interfaces()) -
+ set(self.networks.get_all_networks_interfaces())) + \
+ ['eth-mock0']
+
+ def _mock_interface_lookup(self, name):
+ if name == 'eth-mock0':
+ return {'name': "eth-mock0",
+ 'type': "nic",
+ 'status': "active",
+ 'link_detected': "yes",
+ 'ipaddr': "",
+ 'netmask': ""}
+
+ try:
+ return netinfo.get_interface_info(name)
+ except ValueError:
+ raise NotFoundError("KCHIFACE0001E", {'name': name})
+
+ def networks_set_network_vepa(self, params):
+ for iface in params['interfaces']:
+ if iface == 'eth-mock0':
+ continue
+
+ if ('vlan_id' in params or not (netinfo.is_bare_nic(iface) or
+ netinfo.is_bonding(iface))):
+ raise InvalidParameter('KCHNET0028E', {'name': iface})
+
+ params['forward'] = {'mode': 'vepa', 'devs':
params['interfaces']}
+
def _mock_partitions_get_list(self):
return self._mock_partitions.partitions.keys()
--
1.9.1