use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation in project netvirt by opendaylight.
the class NeutronHostConfigChangeListener method extractHostConfig.
private Map<String, String> extractHostConfig(Node node) {
Map<String, String> config = new HashMap<>();
OvsdbNodeAugmentation ovsdbNode = getOvsdbNodeAugmentation(node);
if (ovsdbNode != null && ovsdbNode.getOpenvswitchExternalIds() != null) {
for (OpenvswitchExternalIds openvswitchExternalIds : ovsdbNode.getOpenvswitchExternalIds()) {
if (openvswitchExternalIds.getExternalIdKey() != null && openvswitchExternalIds.getExternalIdKey().startsWith(OS_HOST_CONFIG_CONFIG_KEY_PREFIX)) {
// Extract the host type. Max 8 characters after
// suffix OS_HOST_CONFIG_CONFIG_KEY_PREFIX.length()
String hostType = openvswitchExternalIds.getExternalIdKey().substring(OS_HOST_CONFIG_CONFIG_KEY_PREFIX.length());
if (hostType.length() > 0) {
if (hostType.length() > HOST_TYPE_STR_LEN) {
hostType = hostType.substring(0, HOST_TYPE_STR_LEN);
}
hostType = "ODL " + hostType.toUpperCase(Locale.getDefault());
if (null != openvswitchExternalIds.getExternalIdValue()) {
config.put(hostType, openvswitchExternalIds.getExternalIdValue());
}
}
}
}
}
return config;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation in project genius by opendaylight.
the class OvsdbNodeListener method getOvsdbTepInfo.
private OvsdbTepInfo getOvsdbTepInfo(OvsdbNodeAugmentation ovsdbNodeAugmentation) {
if (ovsdbNodeAugmentation == null) {
return null;
}
List<OpenvswitchOtherConfigs> ovsdbNodeOtherConfigsList = ovsdbNodeAugmentation.getOpenvswitchOtherConfigs();
if (ovsdbNodeOtherConfigsList == null) {
// Local IP is not configured
LOG.debug("OtherConfigs list does not exist in the OVSDB Node Augmentation.");
return null;
}
OvsdbTepInfo ovsdbTepInfoObj = new OvsdbTepInfo();
for (OpenvswitchOtherConfigs otherConfigs : ovsdbNodeOtherConfigsList) {
if (ITMConstants.OTH_CFG_TEP_PARAM_KEY_LOCAL_IP.equals(otherConfigs.getOtherConfigKey())) {
String tepIp = otherConfigs.getOtherConfigValue();
ovsdbTepInfoObj.setLocalIp(tepIp);
}
}
List<OpenvswitchExternalIds> ovsdbNodeExternalIdsList = ovsdbNodeAugmentation.getOpenvswitchExternalIds();
if (ovsdbNodeExternalIdsList == null) {
LOG.debug("ExternalIds list does not exist in the OVSDB Node Augmentation.");
} else {
for (OpenvswitchExternalIds externalId : ovsdbNodeExternalIdsList) {
switch(externalId.getExternalIdKey()) {
case ITMConstants.EXT_ID_TEP_PARAM_KEY_TZNAME:
ovsdbTepInfoObj.setTzName(externalId.getExternalIdValue());
break;
case ITMConstants.EXT_ID_TEP_PARAM_KEY_BR_NAME:
ovsdbTepInfoObj.setBrName(externalId.getExternalIdValue());
break;
case ITMConstants.EXT_ID_TEP_PARAM_KEY_OF_TUNNEL:
ovsdbTepInfoObj.setOfTunnel(Boolean.parseBoolean(externalId.getExternalIdValue()));
break;
default:
break;
}
}
}
LOG.trace("ovsdbTepInfo retrieved {}", ovsdbTepInfoObj);
return ovsdbTepInfoObj;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation in project genius by opendaylight.
the class OvsdbNodeListener method processBridgeUpdate.
private void processBridgeUpdate(OvsdbBridgeAugmentation ovsdbNewBridgeAugmentation) {
String bridgeName = null;
String strDpnId = null;
OvsdbNodeAugmentation ovsdbNewNodeAugmentation = null;
if (ovsdbNewBridgeAugmentation != null) {
bridgeName = ovsdbNewBridgeAugmentation.getBridgeName().getValue();
// Read DPID from OVSDBBridgeAugmentation
strDpnId = ItmUtils.getStrDatapathId(ovsdbNewBridgeAugmentation);
if (strDpnId == null || strDpnId.isEmpty()) {
LOG.info("OvsdbBridgeAugmentation processBridgeUpdate: DPID for bridge {} is NULL.", bridgeName);
return;
}
// TBD: Move this time taking operations into DataStoreJobCoordinator
Node ovsdbNodeFromBridge = ItmUtils.getOvsdbNode(ovsdbNewBridgeAugmentation, dataBroker);
// check for OVSDB node
if (ovsdbNodeFromBridge != null) {
ovsdbNewNodeAugmentation = ovsdbNodeFromBridge.getAugmentation(OvsdbNodeAugmentation.class);
} else {
LOG.error("processBridgeUpdate: Ovsdb Node could not be fetched from Oper DS for bridge {}.", bridgeName);
return;
}
}
if (ovsdbNewNodeAugmentation != null) {
OvsdbTepInfo ovsdbTepInfo = getOvsdbTepInfo(ovsdbNewNodeAugmentation);
if (ovsdbTepInfo == null) {
LOG.trace("processBridgeUpdate: No Tep Info");
return;
}
// store TEP info required parameters
String newLocalIp = ovsdbTepInfo.getLocalIp();
String tzName = ovsdbTepInfo.getTzName();
String newBridgeName = ovsdbTepInfo.getBrName();
boolean ofTunnel = ovsdbTepInfo.getOfTunnel();
// check if Local IP is configured or not
if (newLocalIp != null && !newLocalIp.isEmpty()) {
// if it is br-int, then add TEP into Config DS
if (newBridgeName.equals(bridgeName)) {
LOG.trace("Ovs Node with bridge {} is configured with Local IP.", bridgeName);
// if flag is OFF, then no need to add TEP into ITM config DS.
if (tzName == null || tzName.equals(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
boolean defTzEnabled = itmConfig.isDefTzEnabled();
if (!defTzEnabled) {
LOG.info("TEP ({}) cannot be added into {} when def-tz-enabled flag is false.", newLocalIp, ITMConstants.DEFAULT_TRANSPORT_ZONE);
return;
}
}
LOG.trace("Local-IP: {}, TZ name: {}, Bridge Name: {}, Bridge DPID: {}," + "of-tunnel flag: {}", newLocalIp, tzName, newBridgeName, strDpnId, ofTunnel);
// Enqueue 'add TEP into new TZ' operation into DataStoreJobCoordinator
jobCoordinator.enqueueJob(newLocalIp, new OvsdbTepAddWorker(newLocalIp, strDpnId, tzName, ofTunnel, dataBroker));
} else {
LOG.trace("TEP ({}) would be added later when bridge {} gets added into Ovs Node.", newLocalIp, newBridgeName);
}
} else {
LOG.trace("Ovs Node with bridge {} is not configured with Local IP. Nothing to do.", bridgeName);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation in project genius by opendaylight.
the class OvsdbTestUtil method createNode.
public static CheckedFuture<Void, TransactionCommitFailedException> createNode(ConnectionInfo connectionInfo, String tepIp, String tzName, DataBroker dataBroker) throws Exception {
final InstanceIdentifier<Node> iid = SouthboundUtils.createInstanceIdentifier(connectionInfo);
// build Node using its builder class
NodeBuilder nodeBuilder = new NodeBuilder();
NodeId ovsdbNodeId = SouthboundUtils.createNodeId(connectionInfo.getRemoteIp(), connectionInfo.getRemotePort());
nodeBuilder.setNodeId(ovsdbNodeId);
// build OvsdbNodeAugmentation for Node
OvsdbNodeAugmentationBuilder ovsdbNodeAugBuilder = new OvsdbNodeAugmentationBuilder();
ovsdbNodeAugBuilder.setConnectionInfo(connectionInfo);
// create map of key-val pairs
Map<String, String> externalIds = new HashMap<>();
Map<String, String> otherConfigs = new HashMap<>();
if (tepIp != null && !tepIp.isEmpty()) {
otherConfigs.put(ItmTestConstants.OTHER_CFG_TEP_IP_KEY, tepIp);
}
if (tzName != null) {
externalIds.put(ItmTestConstants.EXTERNAL_ID_TZNAME_KEY, tzName);
}
// get map-keys into set.
Set<String> externalIdKeys = externalIds.keySet();
Set<String> otherConfigKeys = otherConfigs.keySet();
List<OpenvswitchExternalIds> externalIdsList = new ArrayList<>();
String externalIdValue = null;
for (String externalIdKey : externalIdKeys) {
externalIdValue = externalIds.get(externalIdKey);
if (externalIdKey != null && externalIdValue != null) {
externalIdsList.add(new OpenvswitchExternalIdsBuilder().setExternalIdKey(externalIdKey).setExternalIdValue(externalIdValue).build());
}
}
List<OpenvswitchOtherConfigs> otherConfigsList = new ArrayList<>();
String otherConfigValue = null;
for (String otherConfigKey : otherConfigKeys) {
otherConfigValue = otherConfigs.get(otherConfigKey);
if (otherConfigKey != null && otherConfigValue != null) {
otherConfigsList.add(new OpenvswitchOtherConfigsBuilder().setOtherConfigKey(otherConfigKey).setOtherConfigValue(otherConfigValue).build());
}
}
// set ExternalIds list into Node
ovsdbNodeAugBuilder.setOpenvswitchExternalIds(externalIdsList);
// set OtherConfig list into Node
ovsdbNodeAugBuilder.setOpenvswitchOtherConfigs(otherConfigsList);
// add OvsdbNodeAugmentation into Node
nodeBuilder.addAugmentation(OvsdbNodeAugmentation.class, ovsdbNodeAugBuilder.build());
Node ovsdbNode = nodeBuilder.build();
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
transaction.put(LogicalDatastoreType.OPERATIONAL, iid, ovsdbNode, true);
return transaction.submit();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation in project genius by opendaylight.
the class OvsdbSouthboundTestUtil method getConnectionInfo.
public ConnectionInfo getConnectionInfo(Node ovsdbNode) {
ConnectionInfo connectionInfo = null;
OvsdbNodeAugmentation ovsdbNodeAugmentation = extractOvsdbNode(ovsdbNode);
if (ovsdbNodeAugmentation != null) {
connectionInfo = ovsdbNodeAugmentation.getConnectionInfo();
}
return connectionInfo;
}
Aggregations