use of org.onosproject.yang.YangLiveCompilerService in project onos by opennetworkinglab.
the class YangCompileCommand method doExecute.
@Override
protected void doExecute() {
try {
InputStream yangJar = new URL(url).openStream();
YangLiveCompilerService compiler = get(YangLiveCompilerService.class);
if (compileOnly) {
ByteStreams.copy(compiler.compileYangFiles(modelId, yangJar), System.out);
} else {
ApplicationAdminService appService = get(ApplicationAdminService.class);
if (forceReinstall) {
ApplicationId appId = appService.getId(modelId);
if (appId != null && appService.getApplication(appId) != null) {
appService.uninstall(appId);
}
}
appService.install(compiler.compileYangFiles(modelId, yangJar));
appService.activate(appService.getId(modelId));
}
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.onosproject.yang.YangLiveCompilerService in project onos by opennetworkinglab.
the class YangWebResource method upload.
/**
* Compiles and registers the given yang files.
*
* @param modelId model identifier
* @param stream YANG, ZIP or JAR file
* @return 200 OK
* @throws IOException when fails to generate a file
*/
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response upload(@QueryParam("modelId") @DefaultValue("org.onosproject.model.unknown") String modelId, @FormDataParam("file") InputStream stream) throws IOException {
YangLiveCompilerService compiler = get(YangLiveCompilerService.class);
ApplicationAdminService appService = get(ApplicationAdminService.class);
modelId = getValidModelId(modelId);
appService.install(compiler.compileYangFiles(modelId, stream));
appService.activate(appService.getId(modelId));
return Response.ok().build();
}
Aggregations