use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute in project netvirt by opendaylight.
the class HwvtepHAUtil method deletePSNodesOfNode.
/**
* Delete PS data of HA node of Config Data tree.
*
* @param key Node object
* @param haNode Ha Node from which to be deleted
* @param tx Transaction
*/
public static void deletePSNodesOfNode(InstanceIdentifier<Node> key, Node haNode, TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
// read from switches attribute and clean up them
HwvtepGlobalAugmentation globalAugmentation = haNode.augmentation(HwvtepGlobalAugmentation.class);
if (globalAugmentation == null) {
return;
}
HashMap<InstanceIdentifier<Node>, Boolean> deleted = new HashMap<>();
List<Switches> switches = new ArrayList<>(globalAugmentation.nonnullSwitches().values());
if (switches != null) {
for (Switches switche : switches) {
InstanceIdentifier<Node> psId = (InstanceIdentifier<Node>) switche.getSwitchRef().getValue();
deleteNodeIfPresent(tx, psId);
deleted.put(psId, Boolean.TRUE);
}
}
// also read from managed by attribute of switches and cleanup them as a back up if the above cleanup fails
Optional<Topology> topologyOptional = tx.read(key.firstIdentifierOf(Topology.class)).get();
String deletedNodeId = key.firstKeyOf(Node.class).getNodeId().getValue();
if (topologyOptional.isPresent()) {
Topology topology = topologyOptional.get();
if (topology.getNode() != null) {
for (Node psNode : topology.nonnullNode().values()) {
PhysicalSwitchAugmentation ps = psNode.augmentation(PhysicalSwitchAugmentation.class);
if (ps != null) {
InstanceIdentifier<Node> iid = (InstanceIdentifier<Node>) ps.getManagedBy().getValue();
String nodeIdVal = iid.firstKeyOf(Node.class).getNodeId().getValue();
if (deletedNodeId.equals(nodeIdVal)) {
InstanceIdentifier<Node> psNodeId = convertToInstanceIdentifier(psNode.getNodeId().getValue());
if (deleted.containsKey(psNodeId)) {
deleteNodeIfPresent(tx, psNodeId);
}
}
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute in project bgpcep by opendaylight.
the class LinkstateAttributeParser method serializeAttribute.
/**
* Serialize linkstate attributes.
*
* @param attribute DataObject representing LinkstatePathAttribute
* @param byteAggregator ByteBuf where all serialized data are aggregated
*/
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
final Attributes1 pathAttributes1 = ((Attributes) attribute).getAugmentation(Attributes1.class);
if (pathAttributes1 == null) {
return;
}
final LinkStateAttribute linkState = pathAttributes1.getLinkStateAttribute();
final ByteBuf lsBuffer = Unpooled.buffer();
if (linkState instanceof LinkAttributesCase) {
LinkAttributesParser.serializeLinkAttributes((LinkAttributesCase) linkState, lsBuffer);
} else if (linkState instanceof NodeAttributesCase) {
NodeAttributesParser.serializeNodeAttributes((NodeAttributesCase) linkState, lsBuffer);
} else if (linkState instanceof PrefixAttributesCase) {
PrefixAttributesParser.serializePrefixAttributes((PrefixAttributesCase) linkState, lsBuffer);
} else if (linkState instanceof TeLspAttributesCase) {
TeLspAttributesParser.serializeLspAttributes(this.rsvpTeObjectRegistry, (TeLspAttributesCase) linkState, lsBuffer);
byteAggregator.writeBytes(lsBuffer);
return;
}
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, getType(), lsBuffer, byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute in project bgpcep by opendaylight.
the class XROSRLGSubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
Preconditions.checkArgument(subobject.getSubobjectType() instanceof SrlgCase, "Unknown subobject instance. Passed %s. Needed SrlgCase.", subobject.getSubobjectType().getClass());
final SrlgSubobject specObj = ((SrlgCase) subobject.getSubobjectType()).getSrlg();
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
Preconditions.checkArgument(specObj.getSrlgId() != null, "SrlgId is mandatory.");
writeUnsignedInt(specObj.getSrlgId().getValue(), body);
Preconditions.checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
writeUnsignedByte(null, body);
writeUnsignedByte((short) subobject.getAttribute().getIntValue(), body);
XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute in project bgpcep by opendaylight.
the class MultiExitDiscriminatorAttributeParser method serializeAttribute.
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
final MultiExitDisc multiExitDisc = ((Attributes) attribute).getMultiExitDisc();
if (multiExitDisc == null) {
return;
}
AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, Unpooled.copyInt(multiExitDisc.getMed().intValue()), byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute in project bgpcep by opendaylight.
the class NextHopAttributeParser method serializeAttribute.
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
final CNextHop cNextHop = ((Attributes) attribute).getCNextHop();
if (cNextHop == null) {
return;
}
final ByteBuf nextHopBuffer = Unpooled.buffer();
NextHopUtil.serializeNextHop(cNextHop, nextHopBuffer);
AttributeUtil.formatAttribute(AttributeUtil.TRANSITIVE, TYPE, nextHopBuffer, byteAggregator);
}
Aggregations