import org.oransc.ric.xappmgr.client.api.HealthApi;
import org.oransc.ric.xappmgr.client.api.XappApi;
import org.oransc.ric.xappmgr.client.invoker.ApiClient;
+import org.oransc.ric.xappmgr.client.model.AllXappConfig;
import org.oransc.ric.xappmgr.client.model.AllXapps;
+import org.oransc.ric.xappmgr.client.model.ConfigMetadata;
import org.oransc.ric.xappmgr.client.model.SubscriptionRequest;
import org.oransc.ric.xappmgr.client.model.SubscriptionResponse;
+import org.oransc.ric.xappmgr.client.model.XAppConfig;
import org.oransc.ric.xappmgr.client.model.XAppInfo;
import org.oransc.ric.xappmgr.client.model.Xapp;
import org.oransc.ric.xappmgr.client.model.Xapp.StatusEnum;
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private final AllXapps allXapps;
+ private final AllXappConfig allXappConfigs;
public XappManagerMockConfiguration() {
logger.info("Configuring mock xApp Manager");
- Xapp ac = new Xapp().name("Admission Control").version("v3").status(StatusEnum.FAILED);
- ac.addInstancesItem(
- new XappInstance().name("cdef-3456").ip("3.4.5.6").port(200).status(XappInstance.StatusEnum.RUNNING));
- Xapp an = new Xapp().name("ANR Control").version("v0").status(StatusEnum.SUPERSEDED);
- an.addInstancesItem(
- new XappInstance().name("fedc-8765").ip("8.7.6.5").port(400).status(XappInstance.StatusEnum.RUNNING));
- Xapp dc = new Xapp().name("Dual Connectivity").version("v2").status(StatusEnum.DELETED);
- dc.addInstancesItem(
- new XappInstance().name("def0-6789").ip("6.7.8.9").port(300).status(XappInstance.StatusEnum.COMPLETED));
+ final String[] appNames = { "AdmissionControl", "Automatic Neighbor Relation", "Dual Connectivity" };
+ final String configJson = " { \"config\" : \"example\" }";
+ final String descriptorJson = " { \"descriptor\" : \"example\" }";
+ allXappConfigs = new AllXappConfig();
allXapps = new AllXapps();
- allXapps.add(ac);
- allXapps.add(an);
- allXapps.add(dc);
+ for (String n : appNames) {
+ ConfigMetadata metadata = new ConfigMetadata().configName("config-" + n).name(n).namespace("namespace");
+ XAppConfig config = new XAppConfig().config(configJson).descriptor(descriptorJson).metadata(metadata);
+ allXappConfigs.add(config);
+ Xapp xapp = new Xapp().name(n).version("version").status(StatusEnum.UNKNOWN);
+ xapp.addInstancesItem(new XappInstance().name("abcd-1234").ip("1.2.3.4").port(200)
+ .status(XappInstance.StatusEnum.RUNNING));
+ allXapps.add(xapp);
+ }
}
@Bean
XappApi mockApi = mock(XappApi.class);
when(mockApi.getApiClient()).thenReturn(mockClient);
- SubscriptionResponse subRes = new SubscriptionResponse().eventType(SubscriptionResponse.EventTypeEnum.ALL)
- .id("subid").version(1);
- when(mockApi.addSubscription(any(SubscriptionRequest.class))).thenReturn(subRes);
+ when(mockApi.getAllXappConfig()).thenReturn(allXappConfigs);
+
+ when(mockApi.createXappConfig(any(XAppConfig.class))).thenReturn(new XAppConfig());
+
+ when(mockApi.modifyXappConfig(any(XAppConfig.class))).thenReturn(new XAppConfig());
doAnswer(i -> {
return null;
- }).when(mockApi).deleteSubscription(any(String.class));
+ }).when(mockApi).deleteXappConfig(any(ConfigMetadata.class));
when(mockApi.deployXapp(any(XAppInfo.class))).thenReturn(new Xapp());
return null;
}).when(mockApi).undeployXapp(any(String.class));
+ SubscriptionResponse subRes = new SubscriptionResponse().eventType(SubscriptionResponse.EventTypeEnum.ALL)
+ .id("subid").version(1);
+ when(mockApi.addSubscription(any(SubscriptionRequest.class))).thenReturn(subRes);
+
+ doAnswer(i -> {
+ return null;
+ }).when(mockApi).deleteSubscription(any(String.class));
+
return mockApi;
}
import org.oransc.ric.portal.dashboard.model.SuccessTransport;
import org.oransc.ric.xappmgr.client.api.HealthApi;
import org.oransc.ric.xappmgr.client.api.XappApi;
+import org.oransc.ric.xappmgr.client.model.AllXappConfig;
import org.oransc.ric.xappmgr.client.model.AllXapps;
+import org.oransc.ric.xappmgr.client.model.ConfigMetadata;
+import org.oransc.ric.xappmgr.client.model.XAppConfig;
import org.oransc.ric.xappmgr.client.model.XAppInfo;
import org.oransc.ric.xappmgr.client.model.Xapp;
import org.slf4j.Logger;
return new SuccessTransport(200, DashboardApplication.getImplementationVersion(HealthApi.class));
}
- @ApiOperation(value = "Calls the xApp Manager liveness health check.")
+ @ApiOperation(value = "Health check of xApp Manager - Liveness probe.")
@RequestMapping(value = "/health/alive", method = RequestMethod.GET)
public Object getHealth(HttpServletResponse response) {
logger.debug("getHealthAlive");
response.setStatus(healthApi.getApiClient().getStatusCode().value());
return null;
} catch (HttpStatusCodeException ex) {
- logger.warn("getHealthAlive failed: {}", ex.toString());
+ logger.error("getHealthAlive failed: {}", ex.toString());
return ResponseEntity.status(HttpServletResponse.SC_BAD_GATEWAY).body(ex.getResponseBodyAsString());
}
}
- @ApiOperation(value = "Calls the xApp Manager readiness health check.")
+ @ApiOperation(value = "Readiness check of xApp Manager - Readiness probe.")
@RequestMapping(value = "/health/ready", method = RequestMethod.GET)
public Object getHealthReady(HttpServletResponse response) {
logger.debug("getHealthReady");
response.setStatus(healthApi.getApiClient().getStatusCode().value());
return null;
} catch (HttpStatusCodeException ex) {
- logger.warn("getHealthReady failed: {}", ex.toString());
+ logger.error("getHealthReady failed: {}", ex.toString());
return ResponseEntity.status(HttpServletResponse.SC_BAD_GATEWAY).body(ex.getResponseBodyAsString());
}
}
- @ApiOperation(value = "Calls the xApp Manager to get the list of xApps.", response = AllXapps.class)
+ @ApiOperation(value = "Returns the configuration of all xapps.", response = AllXappConfig.class)
+ @RequestMapping(value = "/config", method = RequestMethod.GET)
+ public Object getAllXappConfig() {
+ logger.debug("getAllXappConfig");
+ try {
+ return xappApi.getAllXappConfig();
+ } catch (HttpStatusCodeException ex) {
+ logger.error("getAllXappConfig failed: {}", ex.toString());
+ return ResponseEntity.status(HttpServletResponse.SC_BAD_GATEWAY).body(ex.getResponseBodyAsString());
+ }
+ }
+
+ @ApiOperation(value = "Create xApp config.")
+ @RequestMapping(value = "/config", method = RequestMethod.POST)
+ public Object createXappConfig(@RequestBody XAppConfig xAppConfig) {
+ logger.debug("createXappConfig {}", xAppConfig);
+ try {
+ return xappApi.createXappConfig(xAppConfig);
+ } catch (HttpStatusCodeException ex) {
+ logger.error("undeployXapp failed: {}", ex.toString());
+ return ResponseEntity.status(HttpServletResponse.SC_BAD_GATEWAY).body(ex.getResponseBodyAsString());
+ }
+ }
+
+ @ApiOperation(value = "Modify xApp config.")
+ @RequestMapping(value = "/config", method = RequestMethod.PUT)
+ public Object modifyXappConfig(@RequestBody XAppConfig xAppConfig) {
+ logger.debug("modifyXappConfig {}", xAppConfig);
+ try {
+ return xappApi.modifyXappConfig(xAppConfig);
+ } catch (HttpStatusCodeException ex) {
+ logger.error("modifyXappConfig failed: {}", ex.toString());
+ return ResponseEntity.status(HttpServletResponse.SC_BAD_GATEWAY).body(ex.getResponseBodyAsString());
+ }
+ }
+
+ @ApiOperation(value = "Delete xApp configuration.")
+ @RequestMapping(value = "/config/{xAppName}", method = RequestMethod.DELETE)
+ public Object deleteXappConfig(@RequestBody ConfigMetadata configMetadata, HttpServletResponse response) {
+ logger.debug("deleteXappConfig {}", configMetadata);
+ try {
+ xappApi.deleteXappConfig(configMetadata);
+ response.setStatus(healthApi.getApiClient().getStatusCode().value());
+ return null;
+ } catch (HttpStatusCodeException ex) {
+ logger.error("deleteXappConfig failed: {}", ex.toString());
+ return ResponseEntity.status(HttpServletResponse.SC_BAD_GATEWAY).body(ex.getResponseBodyAsString());
+ }
+ }
+
+ @ApiOperation(value = "Returns the status of all xapps.", response = AllXapps.class)
@RequestMapping(value = "/xapps", method = RequestMethod.GET)
public Object getAllXapps() {
logger.debug("getAllXapps");
try {
return xappApi.getAllXapps();
} catch (HttpStatusCodeException ex) {
- logger.warn("getAllXapps failed: {}", ex.toString());
+ logger.error("getAllXapps failed: {}", ex.toString());
return ResponseEntity.status(HttpServletResponse.SC_BAD_GATEWAY).body(ex.getResponseBodyAsString());
}
}
- @ApiOperation(value = "Calls the xApp Manager to get the named xApp.", response = Xapp.class)
+ @ApiOperation(value = "Returns the status of a given xapp.", response = Xapp.class)
@RequestMapping(value = "/xapps/{xAppName}", method = RequestMethod.GET)
public Object getXapp(@PathVariable("xAppName") String xAppName) {
logger.debug("getXapp {}", xAppName);
try {
return xappApi.getXappByName(xAppName);
} catch (HttpStatusCodeException ex) {
- logger.warn("getXapp failed: {}", ex.toString());
+ logger.error("getXapp failed: {}", ex.toString());
return ResponseEntity.status(HttpServletResponse.SC_BAD_GATEWAY).body(ex.getResponseBodyAsString());
}
}
- @ApiOperation(value = "Calls the xApp Manager to deploy the specified Xapp.", response = Xapp.class)
+ @ApiOperation(value = "Deploy a xapp.", response = Xapp.class)
@RequestMapping(value = "/xapps", method = RequestMethod.POST)
public Object deployXapp(@RequestBody XAppInfo xAppInfo) {
logger.debug("deployXapp {}", xAppInfo);
try {
return xappApi.deployXapp(xAppInfo);
} catch (HttpStatusCodeException ex) {
- logger.warn("deployXapp failed: {}", ex.toString());
+ logger.error("deployXapp failed: {}", ex.toString());
return ResponseEntity.status(HttpServletResponse.SC_BAD_GATEWAY).body(ex.getResponseBodyAsString());
}
}
- @ApiOperation(value = "Calls the xApp Manager to undeploy the named Xapp.")
+ @ApiOperation(value = "Undeploy an existing xapp.")
@RequestMapping(value = "/xapps/{xAppName}", method = RequestMethod.DELETE)
public Object undeployXapp(@PathVariable("xAppName") String xAppName, HttpServletResponse response) {
logger.debug("undeployXapp {}", xAppName);
response.setStatus(healthApi.getApiClient().getStatusCode().value());
return null;
} catch (HttpStatusCodeException ex) {
- logger.warn("undeployXapp failed: {}", ex.toString());
+ logger.error("undeployXapp failed: {}", ex.toString());
return ResponseEntity.status(HttpServletResponse.SC_BAD_GATEWAY).body(ex.getResponseBodyAsString());
}
}