use of org.onosproject.net.key.DeviceKeyAdminService in project onos by opennetworkinglab.
the class DeviceKeyRemoveCommand method doExecute.
@Override
protected void doExecute() {
DeviceKeyAdminService service = get(DeviceKeyAdminService.class);
service.removeKey(DeviceKeyId.deviceKeyId(id));
}
use of org.onosproject.net.key.DeviceKeyAdminService in project onos by opennetworkinglab.
the class DeviceKeyWebResource method addDeviceKey.
/**
* Adds a new device key from the JSON input stream.
*
* @param stream device key JSON stream
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
* @onos.rsModel Devicekey
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response addDeviceKey(InputStream stream) {
try {
DeviceKeyAdminService service = get(DeviceKeyAdminService.class);
ObjectNode root = readTreeFromStream(mapper(), stream);
DeviceKey deviceKey = codec(DeviceKey.class).decode(root, this);
service.addKey(deviceKey);
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder().path("keys").path(deviceKey.deviceKeyId().id());
return Response.created(locationBuilder.build()).build();
} catch (IOException ioe) {
throw new IllegalArgumentException(ioe);
}
}
use of org.onosproject.net.key.DeviceKeyAdminService in project onos by opennetworkinglab.
the class DeviceKeyAddCommand method doExecute.
@Override
protected void doExecute() {
DeviceKeyAdminService service = get(DeviceKeyAdminService.class);
DeviceKey deviceKey = null;
if (type.equalsIgnoreCase(COMMUNITY_NAME)) {
deviceKey = DeviceKey.createDeviceKeyUsingCommunityName(DeviceKeyId.deviceKeyId(id), label, communityName);
} else if (type.equalsIgnoreCase(USERNAME)) {
deviceKey = DeviceKey.createDeviceKeyUsingUsernamePassword(DeviceKeyId.deviceKeyId(id), label, username, password);
} else {
print("Invalid Device key type: {}", type);
return;
}
service.addKey(deviceKey);
print("Device Key successfully added.");
}
Aggregations