public void initDefaultConfig() throws Exception {
int port = ApiTestCommon.findFreePort();
ApiTestCommon.launchContrailServer(port);
s_logger.debug("initDefaultConfig: test api server launched <localhost" + ", " + port + ">");
ApiConnector api = ApiConnectorFactory.build("localhost", port);
Class<?extends ApiObjectBase>[] vncClasses = new Class[] {
Domain.class,
VirtualNetwork.class,
VirtualMachine.class,
NetworkIpam.class,
InstanceIp.class,
ServiceInstance.class,
FloatingIp.class,
NetworkPolicy.class,
Project.class
};
HashMap<Class<?extends ApiObjectBase>, List<HashMap<String, ApiObjectBase>>> map = new HashMap<Class<?extends ApiObjectBase>, List<HashMap<String, ApiObjectBase>>>();
for (Class<?extends ApiObjectBase> cls: vncClasses) {
List<?extends ApiObjectBase> vncList = (List<?extends ApiObjectBase>)api.list(cls, null);
List<HashMap<String, ApiObjectBase>> objList = new ArrayList<HashMap<String, ApiObjectBase>>();
HashMap<String, ApiObjectBase> uuidMap = new HashMap<String, ApiObjectBase>();
HashMap<String, ApiObjectBase> fqnMap = new HashMap<String, ApiObjectBase>();
objList.add(uuidMap);
objList.add(fqnMap);
for (ApiObjectBase obj:vncList) {
api.read(obj);
uuidMap.put(obj.getUuid(), obj);
fqnMap.put(StringUtils.join(obj.getQualifiedName(), ':'), obj);
}
map.put(cls, objList);
}