renaming and adding more scripts
diff --git a/apps/fpcagent/fpcagent.json b/apps/fpcagent/fpcagent.json
index a54290a..6b26cbf 100644
--- a/apps/fpcagent/fpcagent.json
+++ b/apps/fpcagent/fpcagent.json
@@ -2,8 +2,8 @@
"apps": {
"org.onosproject.fpcagent": {
"fpcagent": {
- "dpn-subscriber-uri": "tcp://*:5560",
- "dpn-publisher-uri": "tcp://*:5559",
+ "dpn-subscriber-uri": "tcp://*:5566",
+ "dpn-publisher-uri": "tcp://*:5555",
"dpn-client-threads": 5,
"node-id": "node0",
"network-id": "network1",
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
index fc7e265..7929e59 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcManager.java
@@ -48,7 +48,7 @@
/* Services */
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- private TenantService tenantService;
+ private FpcRpcService fpcRpcService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
private ModelConverter modelConverter;
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcManager.java
similarity index 82%
rename from apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java
rename to apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcManager.java
index 7300e03..fd10302 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcManager.java
@@ -25,11 +25,14 @@
import org.onlab.packet.Ip4Prefix;
import org.onosproject.config.DynamicConfigService;
import org.onosproject.config.DynamicConfigStore;
-import org.onosproject.config.Filter;
+import org.onosproject.fpcagent.protocols.DpnCommunicationService;
+import org.onosproject.fpcagent.protocols.DpnNgicCommunicator;
+import org.onosproject.fpcagent.protocols.DpnP4Communicator;
import org.onosproject.fpcagent.util.*;
import org.onosproject.yang.gen.v1.fpc.rev20150105.fpc.DefaultConnectionInfo;
import org.onosproject.yang.gen.v1.fpc.rev20150105.fpc.P4DpnControlProtocol;
import org.onosproject.yang.gen.v1.fpc.rev20150105.fpc.ZmqDpnControlProtocol;
+import org.onosproject.yang.gen.v1.fpc.rev20150105.fpc.connectioninfo.ConnectionsKeys;
import org.onosproject.yang.gen.v1.fpc.rev20150105.fpc.connectioninfo.DefaultConnections;
import org.onosproject.yang.gen.v1.fpc.rev20150105.fpc.deregisterclient.DefaultDeregisterClientOutput;
import org.onosproject.yang.gen.v1.fpc.rev20150105.fpc.registerclient.DefaultRegisterClientInput;
@@ -44,6 +47,7 @@
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configurebundles.configurebundlesoutput.DefaultBundles;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configuredpn.DefaultConfigureDpnInput;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configuredpn.DefaultConfigureDpnOutput;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.instructions.Instructions;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.instructions.instructions.instrtype.Instr3GppMob;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.opinput.opbody.CreateOrUpdate;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.opinput.opbody.DeleteOrQuery;
@@ -58,6 +62,7 @@
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.DefaultFpcMobility;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.DefaultFpcPolicy;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.DefaultFpcTopology;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.ContextsKeys;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.DefaultContexts;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpctopology.DefaultDpns;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcContextId;
@@ -75,7 +80,6 @@
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
import java.util.Optional;
import java.util.concurrent.*;
@@ -84,7 +88,7 @@
@Component(immediate = true)
@Service
-public class TenantManager implements TenantService, IetfDmmFpcagentService, org.onosproject.yang.gen.v1.fpc.rev20150105.FpcService {
+public class FpcRpcManager implements FpcRpcService, IetfDmmFpcagentService, org.onosproject.yang.gen.v1.fpc.rev20150105.FpcService {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -104,8 +108,20 @@
@Activate
protected void activate() {
- CacheManager.addManager(this);
+ init();
+ registry.registerRpcService(this);
+ log.info("Tenant Service Started");
+ }
+
+ @Deactivate
+ protected void deactivate() {
+ registry.unregisterRpcService(this);
+ log.info("Tenant Service Stopped");
+ }
+
+ private void init() {
FpcUtil.modelConverter = modelConverter;
+ FpcUtil.dynamicConfigService = dynamicConfigService;
getResourceId();
// Create the Default Tenant and added to the Tenants structure.
@@ -128,77 +144,6 @@
createNode(tenants, root);
createNode(fpcAgentInfo, root);
createNode(defaultConnectionInfo, root);
-
- registry.registerRpcService(this);
-
- log.info("Tenant Service Started");
- }
-
- @Deactivate
- protected void deactivate() {
- registry.unregisterRpcService(this);
-
- log.info("Tenant Service Stopped");
- }
-
- @Override
- public Optional<DefaultTenants> getTenants() {
- Filter filter = Filter.builder().build();
- DataNode dataNode = dynamicConfigService.readNode(tenants, filter);
-
- return getModelObjects(dataNode, null)
- .stream()
- .map(modelObject -> (DefaultTenants) modelObject)
- .findFirst();
- }
-
- @Override
- public Optional<DefaultTenant> getTenant(FpcIdentity tenantId) {
- Filter filter = Filter.builder().build();
- DataNode dataNode = dynamicConfigService.readNode(getTenantResourceId(tenantId), filter);
-
- return getModelObjects(dataNode, tenants)
- .stream()
- .map(modelObject -> (DefaultTenant) modelObject)
- .findFirst();
- }
-
- @Override
- public Optional<DefaultTenant> getTenant(ClientIdentifier clientId) {
- return Optional.empty();
- }
-
- @Override
- public List<ModelObject> getModelObjects(DataNode dataNode, ResourceId resourceId) {
- ResourceData data = getResourceData(dataNode, resourceId);
- ModelObjectData modelData = modelConverter.createModel(data);
- return modelData.modelObjects();
- }
-
- @Override
- public void createNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId) {
- ResourceData dataNode = modelConverter.createDataNode(
- DefaultModelObjectData.builder()
- .identifier(modelObjectId)
- .addModelObject(innerModelObject)
- .build()
- );
- dataNode.dataNodes().forEach(
- node -> dynamicConfigService.createNode(dataNode.resourceId(), node)
- );
- }
-
- @Override
- public void updateNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId) {
- ResourceData dataNode = modelConverter.createDataNode(
- DefaultModelObjectData.builder()
- .identifier(modelObjectId)
- .addModelObject(innerModelObject)
- .build()
- );
- dataNode.dataNodes().forEach(
- node -> dynamicConfigService.updateNode(dataNode.resourceId(), node)
- );
}
@Override
@@ -209,16 +154,20 @@
) throws Exception {
DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
Collection<Callable<Object>> tasks = new ArrayList<>();
-
+ FpcIdentity tenantId = clientInfo.tenantId();
DefaultCommonSuccess defaultCommonSuccess = new DefaultCommonSuccess();
- CacheManager cacheManager = CacheManager.getInstance(clientInfo.tenantId());
+ CacheManager cacheManager = CacheManager.getInstance(tenantId);
for (Contexts context : create.contexts()) {
+ Instructions instructions = context.instructions();
+ if (instructions == null) {
+ throw new RuntimeException("Instructions are empty.");
+ }
// add context to response.
defaultCommonSuccess.addToContexts(context);
// check if mobility exists and if the context id exists.
- if (CacheManager.getInstance(clientInfo.tenantId()).contextsCache.get(context.contextId()).isPresent()) {
+ if (CacheManager.getInstance(tenantId).contextsCache.get(context.contextId()).isPresent()) {
// throw exception if trying to create a Context that already exists.
throw new RuntimeException("Context tried to create already exists. Please issue update operation..");
}
@@ -242,7 +191,7 @@
}
// handle only 3GPP instructions.
- if (!(context.instructions().instrType() instanceof Instr3GppMob)) {
+ if (!(instructions.instrType() instanceof Instr3GppMob)) {
throw new RuntimeException("No 3GPP instructions where given.");
}
@@ -268,7 +217,7 @@
}
// Extract variables
- Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
+ Instr3GppMob instr3GppMob = (Instr3GppMob) instructions.instrType();
String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
@@ -302,13 +251,14 @@
op_id
);
- ModelObjectId modelObjectId = defaultTenantBuilder()
+ ModelObjectId modelObjectId = tenantBuilder(tenantId)
.addChild(DefaultFpcMobility.class)
.build();
createNode(convertContext, modelObjectId);
cacheManager.contextsCache.put(convertContext.contextId(), Optional.of(convertContext));
}));
+ // FIXME why downlink is in session while uplink is not?
if (commands.contains("downlink")) {
tasks.add(Executors.callable(() -> {
dpnCommunicationService.modify_bearer(
@@ -321,7 +271,7 @@
op_id
);
- ModelObjectId modelObjectId = defaultTenantBuilder()
+ ModelObjectId modelObjectId = tenantBuilder(tenantId)
.addChild(DefaultFpcMobility.class)
.build();
createNode(convertContext, modelObjectId);
@@ -363,32 +313,48 @@
) throws Exception {
DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
Collection<Callable<Object>> tasks = new ArrayList<>();
+ FpcIdentity tenantId = clientInfo.tenantId();
DefaultCommonSuccess defaultCommonSuccess = new DefaultCommonSuccess();
- CacheManager cacheManager = CacheManager.getInstance(clientInfo.tenantId());
+ CacheManager cacheManager = CacheManager.getInstance(tenantId);
for (Contexts context : update.contexts()) {
+ Instructions instructions = context.instructions();
+ if (instructions == null) {
+ throw new RuntimeException("Instructions are empty.");
+ }
// add updated context to response.
defaultCommonSuccess.addToContexts(context);
// check if contexts are populated and if they include the wanted context to update.
- if (!CacheManager.getInstance(clientInfo.tenantId()).contextsCache.get(context.contextId()).isPresent()) {
+ if (!CacheManager.getInstance(tenantId).contextsCache.get(context.contextId()).isPresent()) {
// throw exception if wanted context does not exist.
throw new RuntimeException("Context doesn't exist. Please issue create operation..");
}
for (Dpns dpn : context.dpns()) {
+ Optional<DefaultDpns> optionalDpn = cacheManager.dpnsCache.get(dpn.dpnId());
// check if dpns exists and if there is a DPN registered for the wanted identifier.
- if (!cacheManager.dpnsCache.get(dpn.dpnId()).isPresent()) {
+ if (!optionalDpn.isPresent()) {
// throw exception if DPN ID is not registered.
throw new RuntimeException("DPN ID is not registered to the topology.");
}
+ final DpnCommunicationService dpnCommunicationService;
+ Class<? extends FpcDpnControlProtocol> controlProtocol = optionalDpn.get().controlProtocol();
+ if (controlProtocol.isAssignableFrom(ZmqDpnControlProtocol.class)) {
+ dpnCommunicationService = new DpnNgicCommunicator();
+ } else if (controlProtocol.isAssignableFrom(P4DpnControlProtocol.class)) {
+ dpnCommunicationService = new DpnP4Communicator();
+ } else {
+ throw new RuntimeException("Control Protocol is not supported.");
+ }
+
// handle only 3GPP instructions.
- if (!(context.instructions().instrType() instanceof Instr3GppMob)) {
+ if (!(instructions.instrType() instanceof Instr3GppMob)) {
throw new RuntimeException("No 3GPP instructions where given.");
}
// from DPN ID find the Network and Node Identifiers
- Optional<String> key = cacheManager.dpnsCache.get(dpn.dpnId())
+ Optional<String> key = optionalDpn
.map(node -> node.nodeId() + "/" + node.networkId());
if (!key.isPresent()) {
throw new RuntimeException("DPN does not have node and network ID defined.");
@@ -404,7 +370,7 @@
throw new RuntimeException("mobprofileParameters are not instance of ThreegppTunnel");
}
- Instr3GppMob instr3GppMob = (Instr3GppMob) context.instructions().instrType();
+ Instr3GppMob instr3GppMob = (Instr3GppMob) instructions.instrType();
String commands = Bits.toString(instr3GppMob.instr3GppMob().bits());
Ip4Address s1u_enodeb_ipv4 = Ip4Address.valueOf(context.ul().tunnelLocalAddress().toString()),
@@ -416,49 +382,51 @@
BigInteger opId = operationId.uint64();
+ // TODO dpn.direction()
+
DefaultContexts convertContext = convertContext(context);
if (commands.contains("downlink")) {
if (context.dl().lifetime() >= 0L) {
-// tasks.add(Executors.callable(() -> {
-// dpnCommunicationService.modify_bearer(
-// topic_id,
-// s1u_sgw_ipv4,
-// s1u_enb_gtpu_teid,
-// s1u_enodeb_ipv4,
-// contextId,
-// cId,
-// opId
-// );
-//
-// ModelObjectId modelObjectId = defaultTenantBuilder()
-// .addChild(DefaultFpcMobility.class)
-// .build();
-// updateNode(convertContext, modelObjectId);
-// cacheManager.contextsCache.put(convertContext.contextId(), Optional.of(convertContext));
-// }));
+ tasks.add(Executors.callable(() -> {
+ dpnCommunicationService.modify_bearer(
+ topic_id,
+ s1u_sgw_ipv4,
+ s1u_enb_gtpu_teid,
+ s1u_enodeb_ipv4,
+ contextId,
+ cId,
+ opId
+ );
+
+ ModelObjectId modelObjectId = tenantBuilder(tenantId)
+ .addChild(DefaultFpcMobility.class)
+ .build();
+ updateNode(convertContext, modelObjectId);
+ cacheManager.contextsCache.put(convertContext.contextId(), Optional.of(convertContext));
+ }));
} else {
// TODO delete bearer
}
}
if (commands.contains("uplink")) {
if (context.ul().lifetime() >= 0L) {
-// tasks.add(Executors.callable(() -> {
-// dpnCommunicationService.modify_bearer(
-// topic_id,
-// s1u_sgw_ipv4,
-// s1u_enb_gtpu_teid,
-// s1u_enodeb_ipv4,
-// contextId,
-// cId,
-// opId
-// );
-//
-// ModelObjectId modelObjectId = defaultTenantBuilder()
-// .addChild(DefaultFpcMobility.class)
-// .build();
-// updateNode(convertContext, modelObjectId);
-// cacheManager.contextsCache.put(convertContext.contextId(), Optional.of(convertContext));
-// }));
+ tasks.add(Executors.callable(() -> {
+ dpnCommunicationService.modify_bearer(
+ topic_id,
+ s1u_sgw_ipv4,
+ s1u_enb_gtpu_teid,
+ s1u_enodeb_ipv4,
+ contextId,
+ cId,
+ opId
+ );
+
+ ModelObjectId modelObjectId = tenantBuilder(tenantId)
+ .addChild(DefaultFpcMobility.class)
+ .build();
+ updateNode(convertContext, modelObjectId);
+ cacheManager.contextsCache.put(convertContext.contextId(), Optional.of(convertContext));
+ }));
} else {
// TODO delete bearer
}
@@ -492,7 +460,8 @@
) throws Exception {
DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
Collection<Callable<Object>> tasks = new ArrayList<>();
- CacheManager cacheManager = CacheManager.getInstance(clientInfo.tenantId());
+ FpcIdentity tenantId = clientInfo.tenantId();
+ CacheManager cacheManager = CacheManager.getInstance(tenantId);
DefaultDeleteSuccess defaultDeleteSuccess = new DefaultDeleteSuccess();
for (Targets target : delete.targets()) {
defaultDeleteSuccess.addToTargets(target);
@@ -503,21 +472,32 @@
// find context that this target is about.
FpcContextId fpcContextId = FpcContextId.of(FpcIdentity.fromString(trgt));
- Optional<DefaultContexts> defaultContexts = CacheManager.getInstance(clientInfo.tenantId()).contextsCache.get(fpcContextId);
+ Optional<DefaultContexts> defaultContexts = CacheManager.getInstance(tenantId).contextsCache.get(fpcContextId);
if (!defaultContexts.isPresent()) {
throw new RuntimeException("Context doesn't exist. Please issue create operation..");
}
DefaultContexts context = defaultContexts.get();
for (Dpns dpn : context.dpns()) {
+ Optional<DefaultDpns> optionalDpn = cacheManager.dpnsCache.get(dpn.dpnId());
// check if dpns exists and if there is a DPN registered for the wanted identifier.
- if (!cacheManager.dpnsCache.get(dpn.dpnId()).isPresent()) {
+ if (!optionalDpn.isPresent()) {
// throw exception if DPN ID is not registered.
throw new RuntimeException("DPN ID is not registered to the topology.");
}
+ final DpnCommunicationService dpnCommunicationService;
+ Class<? extends FpcDpnControlProtocol> controlProtocol = optionalDpn.get().controlProtocol();
+ if (controlProtocol.isAssignableFrom(ZmqDpnControlProtocol.class)) {
+ dpnCommunicationService = new DpnNgicCommunicator();
+ } else if (controlProtocol.isAssignableFrom(P4DpnControlProtocol.class)) {
+ dpnCommunicationService = new DpnP4Communicator();
+ } else {
+ throw new RuntimeException("Control Protocol is not supported.");
+ }
+
// from DPN ID find the Network and Node Identifiers
- Optional<String> key = cacheManager.dpnsCache.get(dpn.dpnId())
+ Optional<String> key = optionalDpn
.map(node -> node.nodeId() + "/" + node.networkId());
if (!key.isPresent()) {
throw new RuntimeException("DPN does not have node and network ID defined.");
@@ -541,25 +521,25 @@
if (targetStr.endsWith("ul") || targetStr.endsWith("dl")) {
// TODO delete bearer
} else {
-// tasks.add(Executors.callable(() -> {
-// dpnCommunicationService.delete_session(
-// topic_id,
-// context.contextId().fpcIdentity().union().int64(),
-// client_id,
-// op_id
-// );
-//
-// ContextsKeys contextsKeys = new ContextsKeys();
-// contextsKeys.contextId(context.contextId());
-//
-// ResourceId resourceVal = getResourceVal(defaultTenantBuilder()
-// .addChild(DefaultFpcMobility.class)
-// .addChild(DefaultContexts.class, contextsKeys)
-// .build());
-//
-// dynamicConfigService.deleteNode(resourceVal);
-// cacheManager.contextsCache.put(context.contextId(), Optional.empty());
-// }));
+ tasks.add(Executors.callable(() -> {
+ dpnCommunicationService.delete_session(
+ topic_id,
+ context.contextId().fpcIdentity().union().int64(),
+ client_id,
+ op_id
+ );
+
+ ContextsKeys contextsKeys = new ContextsKeys();
+ contextsKeys.contextId(context.contextId());
+
+ ResourceId resourceVal = getResourceVal(tenantBuilder(tenantId)
+ .addChild(DefaultFpcMobility.class)
+ .addChild(DefaultContexts.class, contextsKeys)
+ .build());
+
+ dynamicConfigService.deleteNode(resourceVal);
+ cacheManager.contextsCache.put(context.contextId(), Optional.empty());
+ }));
}
}
}
@@ -722,6 +702,9 @@
try {
for (ModelObject modelObject : getModelObjects(rpcInput.data(), configure)) {
DefaultConfigureInput input = (DefaultConfigureInput) modelObject;
+ if (!clientInfo.containsKey(input.clientId())) {
+ throw new RuntimeException("Client Identifier is not registered.");
+ }
switch (input.opType()) {
case CREATE:
configureOutput = configureCreate(
@@ -764,7 +747,7 @@
.addModelObject(configureOutput)
.build()
);
- log.debug("Time Elapsed {} ms", timer.stop().elapsed(TimeUnit.MILLISECONDS));
+ log.info("Time Elapsed {} ms", timer.stop().elapsed(TimeUnit.MILLISECONDS));
return new RpcOutput(status, dataNode.dataNodes().get(0));
}
@@ -776,6 +759,9 @@
try {
for (ModelObject modelObject : getModelObjects(rpcInput.data(), configureBundles)) {
DefaultConfigureBundlesInput input = (DefaultConfigureBundlesInput) modelObject;
+ if (!clientInfo.containsKey(input.clientId())) {
+ throw new RuntimeException("Client Identifier is not registered.");
+ }
for (org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configurebundles.configurebundlesinput.Bundles bundle : input.bundles()) {
DefaultConfigureOutput configureOutput = new DefaultConfigureOutput();
switch (bundle.opType()) {
@@ -853,7 +839,6 @@
Stopwatch timer = Stopwatch.createStarted();
DefaultRegisterClientOutput registerClientOutput = new DefaultRegisterClientOutput();
RpcOutput.Status status = RpcOutput.Status.RPC_SUCCESS;
-
try {
for (ModelObject modelObject : getModelObjects(rpcInput.data(), registerClient)) {
DefaultRegisterClientInput input = (DefaultRegisterClientInput) modelObject;
@@ -867,7 +852,13 @@
registerClientOutput.supportsAckModel(input.supportsAckModel());
registerClientOutput.tenantId(input.tenantId());
- // TODO create node to DCS
+ DefaultConnections defaultConnections = new DefaultConnections();
+ defaultConnections.clientId(input.clientId().toString());
+
+ ModelObjectId modelObjectId = ModelObjectId.builder()
+ .addChild(DefaultConnectionInfo.class)
+ .build();
+ createNode(defaultConnections, modelObjectId);
}
} catch (Exception e) {
// if there is an exception respond with an error.
@@ -903,7 +894,15 @@
DefaultConnections defaultConnections = new DefaultConnections();
defaultConnections.clientId(input.clientId().toString());
- // TODO delete node from DCS
+ ConnectionsKeys connectionsKeys = new ConnectionsKeys();
+ connectionsKeys.clientId(input.clientId().toString());
+
+ ResourceId resourceVal = getResourceVal(ModelObjectId.builder()
+ .addChild(DefaultConnectionInfo.class)
+ .addChild(DefaultConnections.class, connectionsKeys)
+ .build());
+
+ dynamicConfigService.deleteNode(resourceVal);
}
} catch (Exception e) {
// if there is an exception respond with an error.
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcService.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcService.java
new file mode 100644
index 0000000..8d5c150
--- /dev/null
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/FpcRpcService.java
@@ -0,0 +1,60 @@
+package org.onosproject.fpcagent;
+
+import com.google.common.annotations.Beta;
+import org.onosproject.yang.gen.v1.fpc.rev20150105.fpc.registerclient.DefaultRegisterClientInput;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.OpIdentifier;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configure.DefaultConfigureOutput;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configuredpn.DefaultConfigureDpnInput;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configuredpn.DefaultConfigureDpnOutput;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.opinput.opbody.CreateOrUpdate;
+import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.opinput.opbody.DeleteOrQuery;
+
+@Beta
+public interface FpcRpcService {
+
+ /**
+ * Handles create Configure operations that are invoked through RPC.
+ *
+ * @param create RPC Input converted
+ * @param clientInfo Client Identifier
+ * @param operationId Operation Identifier
+ * @return Result of the configuration
+ */
+ DefaultConfigureOutput configureCreate(
+ CreateOrUpdate create,
+ DefaultRegisterClientInput clientInfo,
+ OpIdentifier operationId
+ ) throws Exception;
+
+ /**
+ * Handles update Configure operations that are invoked through RPC.
+ *
+ * @param update RPC Input converted
+ * @param clientInfo Client Identifier
+ * @param operationId Operation Identifier
+ * @return Result of the configuration
+ */
+ DefaultConfigureOutput configureUpdate(
+ CreateOrUpdate update,
+ DefaultRegisterClientInput clientInfo,
+ OpIdentifier operationId
+ ) throws Exception;
+
+ /**
+ * Handles delete Configure operations that are invoked through RPC.
+ *
+ * @param delete RPC Input converted
+ * @param clientInfo Client Identifier
+ * @param operationId Operation Identifier
+ * @return Result of the configuration
+ */
+ DefaultConfigureOutput configureDelete(
+ DeleteOrQuery delete,
+ DefaultRegisterClientInput clientInfo,
+ OpIdentifier operationId
+ ) throws Exception;
+
+ DefaultConfigureDpnOutput configureDpnAdd(DefaultConfigureDpnInput input) throws Exception;
+
+ DefaultConfigureDpnOutput configureDpnRemove(DefaultConfigureDpnInput input) throws Exception;
+}
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java
deleted file mode 100644
index f412c5f..0000000
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/TenantService.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package org.onosproject.fpcagent;
-
-import com.google.common.annotations.Beta;
-import org.onosproject.yang.gen.v1.fpc.rev20150105.fpc.registerclient.DefaultRegisterClientInput;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ClientIdentifier;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.DefaultTenants;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.OpIdentifier;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configure.DefaultConfigureOutput;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configuredpn.DefaultConfigureDpnInput;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.configuredpn.DefaultConfigureDpnOutput;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.opinput.opbody.CreateOrUpdate;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.opinput.opbody.DeleteOrQuery;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.DefaultTenant;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcIdentity;
-import org.onosproject.yang.model.*;
-
-import java.util.List;
-import java.util.Optional;
-
-@Beta
-public interface TenantService {
- /**
- * Returns the root level node for Tenants.
- * Tenants is an interface that includes a List of Tenant objects.
- *
- * @return Optional Tenants
- */
- Optional<DefaultTenants> getTenants();
-
- /**
- * Creates a Node inside the Dynamic Configuration Store.
- *
- * @param innerModelObject inner model object to create
- * @param modelObjectId Model Object ID
- */
- void createNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId);
-
- /**
- * Updates a Node inside the Dynamic Configuration Store.
- *
- * @param innerModelObject inner model object to update
- * @param modelObjectId Model Object ID
- */
- void updateNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId);
-
- /**
- * Converts DataNode to a ModelObject.
- *
- * @param dataNode DataNode
- * @param appId Resource Identifier
- * @return Model Object
- */
- List<ModelObject> getModelObjects(DataNode dataNode, ResourceId appId);
-
- /**
- * Get Tenant by its Identifier.
- *
- * @param tenantId Tenant Identifier
- * @return Optional Tenant
- */
- Optional<DefaultTenant> getTenant(FpcIdentity tenantId);
-
- Optional<DefaultTenant> getTenant(ClientIdentifier clientId);
-
- /**
- * Handles create Configure operations that are invoked through RPC.
- *
- * @param create RPC Input converted
- * @param clientInfo Client Identifier
- * @param operationId Operation Identifier
- * @return Result of the configuration
- */
- DefaultConfigureOutput configureCreate(
- CreateOrUpdate create,
- DefaultRegisterClientInput clientInfo,
- OpIdentifier operationId
- ) throws Exception;
-
- /**
- * Handles update Configure operations that are invoked through RPC.
- *
- * @param update RPC Input converted
- * @param clientInfo Client Identifier
- * @param operationId Operation Identifier
- * @return Result of the configuration
- */
- DefaultConfigureOutput configureUpdate(
- CreateOrUpdate update,
- DefaultRegisterClientInput clientInfo,
- OpIdentifier operationId
- ) throws Exception;
-
- /**
- * Handles delete Configure operations that are invoked through RPC.
- *
- * @param delete RPC Input converted
- * @param clientInfo Client Identifier
- * @param operationId Operation Identifier
- * @return Result of the configuration
- */
- DefaultConfigureOutput configureDelete(
- DeleteOrQuery delete,
- DefaultRegisterClientInput clientInfo,
- OpIdentifier operationId
- ) throws Exception;
-
- DefaultConfigureDpnOutput configureDpnAdd(DefaultConfigureDpnInput input) throws Exception;
-
- DefaultConfigureDpnOutput configureDpnRemove(DefaultConfigureDpnInput input) throws Exception;
-}
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/DpnCommunicationService.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnCommunicationService.java
similarity index 98%
rename from apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/DpnCommunicationService.java
rename to apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnCommunicationService.java
index e1bcd17..7405169 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/DpnCommunicationService.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnCommunicationService.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.fpcagent.util;
+package org.onosproject.fpcagent.protocols;
import org.onlab.packet.Ip4Address;
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/DpnNgicCommunicator.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnNgicCommunicator.java
similarity index 99%
rename from apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/DpnNgicCommunicator.java
rename to apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnNgicCommunicator.java
index f444e11..7740ec6 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/DpnNgicCommunicator.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnNgicCommunicator.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.fpcagent.util;
+package org.onosproject.fpcagent.protocols;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.Ip4Prefix;
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/DpnP4Communicator.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnP4Communicator.java
similarity index 97%
rename from apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/DpnP4Communicator.java
rename to apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnP4Communicator.java
index 6fb7eb9..5b12e05 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/DpnP4Communicator.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/protocols/DpnP4Communicator.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onosproject.fpcagent.util;
+package org.onosproject.fpcagent.protocols;
import org.onlab.packet.Ip4Address;
import org.onosproject.yang.gen.v1.fpc.rev20150105.fpc.P4DpnControlProtocol;
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/CacheManager.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/CacheManager.java
index ebc3644..1b0bae3 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/CacheManager.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/CacheManager.java
@@ -20,7 +20,6 @@
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Maps;
-import org.onosproject.fpcagent.TenantManager;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.DefaultTenant;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.DefaultContexts;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpctopology.DefaultDpns;
@@ -33,6 +32,8 @@
import java.util.Optional;
import java.util.concurrent.ConcurrentMap;
+import static org.onosproject.fpcagent.util.FpcUtil.getTenant;
+
/**
* Cache Manager.
*/
@@ -44,8 +45,6 @@
public LoadingCache<FpcContextId, Optional<DefaultContexts>> contextsCache;
public LoadingCache<FpcDpnId, Optional<DefaultDpns>> dpnsCache;
- private static TenantManager tenantManager;
-
private CacheManager(FpcIdentity identity) {
contextsCache = CacheBuilder.newBuilder()
.maximumSize(100)
@@ -54,7 +53,7 @@
@Override
public Optional<DefaultContexts> load(FpcContextId fpcContextId) throws Exception {
try {
- Optional<DefaultTenant> defaultTenant = tenantManager.getTenant(identity);
+ Optional<DefaultTenant> defaultTenant = getTenant(identity);
if (defaultTenant.isPresent()) {
DefaultTenant tenant = defaultTenant.get();
log.debug("tenant {}", defaultTenant);
@@ -82,7 +81,7 @@
@Override
public Optional<DefaultDpns> load(FpcDpnId fpcDpnId) throws Exception {
try {
- Optional<DefaultTenant> defaultTenant = tenantManager.getTenant(identity);
+ Optional<DefaultTenant> defaultTenant = getTenant(identity);
if (defaultTenant.isPresent()) {
DefaultTenant tenant = defaultTenant.get();
log.debug("tenant {}", tenant);
@@ -109,7 +108,4 @@
return cacheInfo.get(identity);
}
- public static void addManager(TenantManager manager) {
- tenantManager = manager;
- }
}
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/Converter.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/Converter.java
index 5e61d74..fd4ba4a 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/Converter.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/Converter.java
@@ -1,15 +1,12 @@
package org.onosproject.fpcagent.util;
-import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ClientIdentifier;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.tenants.tenant.fpcmobility.DefaultContexts;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcContextId;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcDpnGroupId;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcIdentity;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.FpcPortId;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpccontext.Dl;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpccontext.Dpns;
import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpccontext.Ul;
-import org.onosproject.yang.gen.v1.ietfdmmfpcbase.rev20160803.ietfdmmfpcbase.fpcidentity.FpcIdentityUnion;
import org.onosproject.yang.gen.v1.ietfdmmthreegpp.rev20160803.ietfdmmthreegpp.EbiType;
import org.onosproject.yang.gen.v1.ietfdmmthreegpp.rev20160803.ietfdmmthreegpp.ImsiType;
import org.onosproject.yang.gen.v1.ietfinettypes.rev20130715.ietfinettypes.IpPrefix;
@@ -19,12 +16,9 @@
import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;
-import java.util.function.Function;
public class Converter {
private static final Logger log = LoggerFactory.getLogger(Converter.class);
- public static Function<String, FpcIdentity> getFpcIdentity = (v) -> new FpcIdentity(new FpcIdentityUnion(v));
- public static Function<String, ClientIdentifier> getClientIdentity = (v) -> new ClientIdentifier(getFpcIdentity.apply(v));
/**
* Short to Byte
diff --git a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/FpcUtil.java b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/FpcUtil.java
index f528442..0141b36 100644
--- a/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/FpcUtil.java
+++ b/apps/fpcagent/src/main/java/org/onosproject/fpcagent/util/FpcUtil.java
@@ -17,6 +17,8 @@
package org.onosproject.fpcagent.util;
import com.google.common.collect.Maps;
+import org.onosproject.config.DynamicConfigService;
+import org.onosproject.config.Filter;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.ClientIdentifier;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.DefaultTenants;
import org.onosproject.yang.gen.v1.ietfdmmfpcagent.rev20160803.ietfdmmfpcagent.OpIdentifier;
@@ -32,11 +34,10 @@
import org.slf4j.LoggerFactory;
import java.math.BigInteger;
-import java.util.AbstractMap;
-import java.util.Arrays;
-import java.util.Map;
+import java.util.*;
-import static org.onosproject.fpcagent.util.Converter.*;
+import static org.onosproject.fpcagent.util.Converter.fromIntToLong;
+import static org.onosproject.fpcagent.util.Converter.toBigInt;
/**
* Helper class which stores all the static variables.
@@ -49,26 +50,10 @@
public static final String UNKNOWN_EVENT = "FPC Agent listener: unknown event: {}";
public static final String EVENT_NULL = "Event cannot be null";
public static final String FPC_APP_ID = "org.onosproject.fpcagent";
-
+ public static final FpcIdentity defaultIdentity = FpcIdentity.fromString("default");
private static final Logger log = LoggerFactory.getLogger(FpcUtil.class);
private static final Map<String, FpcDpnId> uplinkDpnMap = Maps.newConcurrentMap();
private static final Map<String, Short> nodeToTopicMap = Maps.newConcurrentMap();
-
- public static ModelConverter modelConverter = null;
- // Resource ID for Configure DPN RPC command
- public static ResourceId configureDpn;
- // Resource ID for Configure RPC command
- public static ResourceId configure;
- // Resource ID for tenants data
- public static ResourceId tenants;
- public static ResourceId defaultTenant;
- public static ResourceId configureBundles;
- public static ResourceId registerClient;
- public static ResourceId deregisterClinet;
- public static ResourceId module;
-
- public static final FpcIdentity defaultIdentity = getFpcIdentity.apply("default");
-
private static final byte DPN_HELLO = 0b0000_0001;
private static final byte DPN_BYE = 0b0000_0010;
private static final byte DOWNLINK_DATA_NOTIFICATION = 0b0000_0101;
@@ -76,6 +61,18 @@
private static final byte DPN_OVERLOAD_INDICATION = 0b0000_0101;
private static final byte DPN_REPLY = 0b0000_0100;
private static final String DOWNLINK_DATA_NOTIFICATION_STRING = "Downlink-Data-Notification";
+ public static DynamicConfigService dynamicConfigService = null;
+ public static ModelConverter modelConverter = null;
+ // Resource ID for Configure DPN RPC command
+ public static ResourceId configureDpn;
+ // Resource ID for Configure RPC command
+ public static ResourceId configure;
+ // Resource ID for tenants data
+ public static ResourceId tenants;
+ public static ResourceId configureBundles;
+ public static ResourceId registerClient;
+ public static ResourceId deregisterClinet;
+ public static ResourceId module;
/**
* Returns resource id from model converter.
@@ -104,11 +101,6 @@
tenants = getResourceVal(tenantsId);
- ModelObjectId defaultTenantId = defaultTenantBuilder()
- .build();
-
- defaultTenant = getResourceVal(defaultTenantId);
-
configure = ResourceId.builder()
.addBranchPointSchema("/", null)
.addBranchPointSchema("configure", "urn:ietf:params:xml:ns:yang:fpcagent")
@@ -170,9 +162,9 @@
}
}
- public static ModelObjectId.Builder defaultTenantBuilder() {
+ public static ModelObjectId.Builder tenantBuilder(FpcIdentity fpcIdentity) {
TenantKeys tenantKeys = new TenantKeys();
- tenantKeys.tenantId(defaultIdentity);
+ tenantKeys.tenantId(fpcIdentity);
return ModelObjectId.builder()
.addChild(DefaultTenants.class)
@@ -272,6 +264,93 @@
}
/**
+ * Returns the root level node for Tenants.
+ * Tenants is an interface that includes a List of Tenant objects.
+ *
+ * @return Optional Tenants
+ */
+ public static Optional<DefaultTenants> getTenants() {
+ Filter filter = Filter.builder().build();
+ DataNode dataNode = dynamicConfigService.readNode(tenants, filter);
+
+ return getModelObjects(dataNode, null)
+ .stream()
+ .map(modelObject -> (DefaultTenants) modelObject)
+ .findFirst();
+ }
+
+ public static Optional<DefaultTenant> getTenant(FpcIdentity tenantId) {
+ Filter filter = Filter.builder().build();
+ DataNode dataNode = dynamicConfigService.readNode(getTenantResourceId(tenantId), filter);
+
+ return getModelObjects(dataNode, tenants)
+ .stream()
+ .map(modelObject -> (DefaultTenant) modelObject)
+ .findFirst();
+ }
+
+ /**
+ * Get Tenant by its Identifier.
+ *
+ * @param clientId Tenant Identifier
+ * @return Optional Tenant
+ */
+
+ public static Optional<DefaultTenant> getTenant(ClientIdentifier clientId) {
+ return Optional.empty();
+ }
+
+ /**
+ * Converts DataNode to a ModelObject.
+ *
+ * @param dataNode DataNode
+ * @param resourceId Resource Identifier
+ * @return Model Object
+ */
+
+ public static List<ModelObject> getModelObjects(DataNode dataNode, ResourceId resourceId) {
+ ResourceData data = getResourceData(dataNode, resourceId);
+ ModelObjectData modelData = modelConverter.createModel(data);
+ return modelData.modelObjects();
+ }
+
+ /**
+ * Creates a Node inside the Dynamic Configuration Store.
+ *
+ * @param innerModelObject inner model object to create
+ * @param modelObjectId Model Object ID
+ */
+ public static void createNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId) {
+ ResourceData dataNode = modelConverter.createDataNode(
+ DefaultModelObjectData.builder()
+ .identifier(modelObjectId)
+ .addModelObject(innerModelObject)
+ .build()
+ );
+ dataNode.dataNodes().forEach(
+ node -> dynamicConfigService.createNode(dataNode.resourceId(), node)
+ );
+ }
+
+ /**
+ * Updates a Node inside the Dynamic Configuration Store.
+ *
+ * @param innerModelObject inner model object to update
+ * @param modelObjectId Model Object ID
+ */
+ public static void updateNode(InnerModelObject innerModelObject, ModelObjectId modelObjectId) {
+ ResourceData dataNode = modelConverter.createDataNode(
+ DefaultModelObjectData.builder()
+ .identifier(modelObjectId)
+ .addModelObject(innerModelObject)
+ .build()
+ );
+ dataNode.dataNodes().forEach(
+ node -> dynamicConfigService.updateNode(dataNode.resourceId(), node)
+ );
+ }
+
+ /**
* Provides basic status changes,
*/
public static class DPNStatusIndication {
diff --git a/scripts/addDPN.sh b/scripts/addDPN.sh
index 18e5e42..8a1d141 100755
--- a/scripts/addDPN.sh
+++ b/scripts/addDPN.sh
@@ -12,7 +12,8 @@
],
"node-id": "node'$1'",
"network-id": "network'$1'",
- "control-protocol": "zmq-dpn-control-protocol"
+ "control-protocol": "zmq-dpn-control-protocol",
+ "abstract": false
}
]
}' 'http://localhost:8181/onos/restconf/data/ietf-dmm-fpcagent:tenants/tenant=default/fpc-topology'
@@ -30,7 +31,8 @@
],
"node-id": "node'$1'",
"network-id": "network'$1'",
- "control-protocol": "zmq-dpn-control-protocol"
+ "control-protocol": "zmq-dpn-control-protocol",
+ "abstract": false
}
]
}' 'http://localhost:8181/onos/restconf/data/ietf-dmm-fpcagent:tenants/tenant='$2'/fpc-topology'
diff --git a/scripts/benchmark.sh b/scripts/benchmark.sh
index 08e90c5..0e2bbc5 100755
--- a/scripts/benchmark.sh
+++ b/scripts/benchmark.sh
@@ -1,10 +1,11 @@
#!/bin/sh
-rm -rf create.log delete.log
-
-./registerClient.sh 1 default &> /dev/null
+echo "Register Client.."
+./registerClient.sh 1 &> /dev/null
+echo "Add DPN.."
./addDPN.sh 1 &> /dev/null
+echo "Running 100 configure create.."
for (( i=1; i<=100; i++)); do
./configure.sh create $i 1 &> /dev/null &
if ! (($i % 10)); then
@@ -14,6 +15,7 @@
wait
+echo "Running 100 configure delete.."
for (( i=1; i<=100; i++)); do
./configure.sh delete $i &> /dev/null &
if ! (($i % 10)); then
@@ -21,5 +23,7 @@
fi
done
+echo "Delete DPN.."
./deleteDPN.sh 1 &> /dev/null
+echo "Deregister Client.."
./deregisterClient.sh 1 &> /dev/null
diff --git a/scripts/forwarder_device.py b/scripts/forwarder_controller.py
similarity index 91%
copy from scripts/forwarder_device.py
copy to scripts/forwarder_controller.py
index 04f2a18..e7231ec 100755
--- a/scripts/forwarder_device.py
+++ b/scripts/forwarder_controller.py
@@ -15,13 +15,13 @@
# Socket facing clients
frontend = context.socket(zmq.SUB)
- frontend.bind("tcp://*:5559")
+ frontend.bind("tcp://*:5555")
frontend.setsockopt(zmq.SUBSCRIBE, "")
# Socket facing services
backend = context.socket(zmq.PUB)
- backend.bind("tcp://*:5560")
+ backend.bind("tcp://*:5556")
zmq.device(zmq.FORWARDER, frontend, backend)
diff --git a/scripts/forwarder_device.py b/scripts/forwarder_dp.py
similarity index 91%
rename from scripts/forwarder_device.py
rename to scripts/forwarder_dp.py
index 04f2a18..e8ea572 100755
--- a/scripts/forwarder_device.py
+++ b/scripts/forwarder_dp.py
@@ -15,13 +15,13 @@
# Socket facing clients
frontend = context.socket(zmq.SUB)
- frontend.bind("tcp://*:5559")
+ frontend.bind("tcp://*:5565")
frontend.setsockopt(zmq.SUBSCRIBE, "")
# Socket facing services
backend = context.socket(zmq.PUB)
- backend.bind("tcp://*:5560")
+ backend.bind("tcp://*:5566")
zmq.device(zmq.FORWARDER, frontend, backend)
diff --git a/scripts/forwarder_subscriber_with_ACK.py b/scripts/forwarder_subscriber_with_ACK.py
index fbc5088..9bf086b 100755
--- a/scripts/forwarder_subscriber_with_ACK.py
+++ b/scripts/forwarder_subscriber_with_ACK.py
@@ -62,8 +62,8 @@
print "Ready to receive messages. Press Ctrl+C when ready to exit."
-subscriber_uri = "tcp://localhost:5560"
-publisher_uri = "tcp://localhost:5559"
+subscriber_uri = "tcp://localhost:5556"
+publisher_uri = "tcp://localhost:5565"
# Socket to talk to server
context = zmq.Context()
sub_socket = context.socket(zmq.SUB)
diff --git a/scripts/registerClient.sh b/scripts/registerClient.sh
index 36d108a..a7cd5c4 100755
--- a/scripts/registerClient.sh
+++ b/scripts/registerClient.sh
@@ -20,6 +20,26 @@
}
}' 'http://localhost:8181/onos/restconf/operations/fpc:register-client'
echo ""
+elif [ "$#" -eq 1 ]; then
+ echo ""
+ curl -i -s \
+ --header "Content-type: application/json" \
+ --request POST \
+ -u onos:rocks \
+ --data '{
+ "input": {
+ "client-id": "'$1'",
+ "tenant-id": "default",
+ "supported-features": [
+ "urn:ietf:params:xml:ns:yang:fpcagent:fpc-bundles",
+ "urn:ietf:params:xml:ns:yang:fpcagent:operation-ref-scope",
+ "urn:ietf:params:xml:ns:yang:fpcagent:fpc-agent-assignments",
+ "urn:ietf:params:xml:ns:yang:fpcagent:instruction-bitset"
+ ],
+ "endpoint-uri": "http://127.0.0.1:9997/"
+ }
+ }' 'http://localhost:8181/onos/restconf/operations/fpc:register-client'
+ echo ""
else
echo "usage: "$0" clientId tenantId"
fi