From 00ea51d999daaa26ea62b6fd0a3a1c911bc26cba Mon Sep 17 00:00:00 2001 From: Alexis de Talhouët Date: Fri, 24 Aug 2018 08:37:11 -0400 Subject: Add SvcLogicContext interaction with netbox-client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And return proper QueryStatus as exepected by the DG. Change-Id: I6af3971a2c6a8b6eda949f7b63cd30fe361dfbc4 Issue-ID: CCSDK-462 Signed-off-by: Alexis de Talhouët --- .../sli/adaptors/netbox/api/NetboxClient.java | 44 +++-- .../sli/adaptors/netbox/impl/NetboxClientImpl.java | 194 ++++++++++++--------- .../sli/adaptors/netbox/impl/NetboxHttpClient.java | 87 ++------- .../ccsdk/sli/adaptors/netbox/model/IPAddress.java | 22 ++- .../ccsdk/sli/adaptors/netbox/model/IPStatus.java | 5 + .../ccsdk/sli/adaptors/netbox/model/Status.java | 77 -------- .../org/opendaylight/blueprint/netbox-client.xml | 3 +- 7 files changed, 172 insertions(+), 260 deletions(-) create mode 100644 netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/model/IPStatus.java delete mode 100644 netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/model/Status.java (limited to 'netbox-client/provider/src/main') diff --git a/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/api/NetboxClient.java b/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/api/NetboxClient.java index e11fe8bcc..f770d1543 100644 --- a/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/api/NetboxClient.java +++ b/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/api/NetboxClient.java @@ -15,37 +15,45 @@ */ package org.onap.ccsdk.sli.adaptors.netbox.api; -import java.sql.SQLException; -import org.onap.ccsdk.sli.adaptors.netbox.model.IPAddress; -import org.onap.ccsdk.sli.adaptors.netbox.model.Prefix; +import java.util.Map; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus; /** * This client is meant to interact both with the IPAM system, and the SDNC DB, in order to provide, at any time, * an up to date status of the assigned resources. */ -public interface NetboxClient { +public interface NetboxClient extends SvcLogicJavaPlugin { /** * Assign next available IP in prefix and store it in the SDNC database, table IPAM_IP_ASSIGNEMENT. * - * @param prefix The prefix from which to get next available IP. - * @param serviceInstanceId The service instance ID uniquely identifying the service. - * @param vfModuleId The VF module ID uniquely identifying the VF. - * @return The IPAddress - * @throws IpamException If something goes wrong while communicating with the IPAM system. - * @throws SQLException If something goes wrong while communicating with the SDNC DB. + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
service_instance_idMandatoryThe service instance ID uniquely identifying the service.
vf_module_idMandatoryThe VF module ID uniquely identifying the VF.
prefix_idMandatoryThe prefix from which to get next available IP.
*/ - IPAddress assign(Prefix prefix, String serviceInstanceId, String vfModuleId) throws IpamException, SQLException; + QueryStatus assignIpAddress(Map parameters, SvcLogicContext ctx); /** - * Release the IP and remove the entry in the SDNC database, table IPAM_IP_ASSIGNEMENT. + * Release the IP and update the entry in the SDNC database, table IPAM_IP_ASSIGNEMENT. * - * @param ip The IP to release. - * @param serviceInstanceId The service instance ID uniquely identifying the service. - * @param vfModuleId The VF module ID uniquely identifying the VF. - * @throws IpamException If something goes wrong while communicating with the IPAM system. - * @throws SQLException If something goes wrong while communicating with the SDNC DB. + * @param parameters HashMap of parameters passed by the DG to this function + * + * + * + * + * + * + * + *
parameterMandatory/Optionaldescription
service_instance_idMandatoryThe service instance ID uniquely identifying the service.
vf_module_idMandatoryThe VF module ID uniquely identifying the VF.
ip_address_idMandatoryThe IP to release.
*/ - void unassign(IPAddress ip, String serviceInstanceId, String vfModuleId) throws IpamException, SQLException; + QueryStatus unassignIpAddress(Map parameters, SvcLogicContext ctx); } diff --git a/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxClientImpl.java b/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxClientImpl.java index 036ff44d4..54700f6c7 100644 --- a/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxClientImpl.java +++ b/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxClientImpl.java @@ -15,127 +15,163 @@ */ package org.onap.ccsdk.sli.adaptors.netbox.impl; -import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.Lists; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonSerializer; +import com.google.gson.JsonSyntaxException; import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; import java.sql.SQLException; import java.util.ArrayList; -import java.util.concurrent.CompletionException; +import java.util.Map; import org.apache.http.HttpResponse; -import org.onap.ccsdk.sli.adaptors.netbox.api.IpamException; +import org.apache.http.util.EntityUtils; import org.onap.ccsdk.sli.adaptors.netbox.api.NetboxClient; import org.onap.ccsdk.sli.adaptors.netbox.model.IPAddress; -import org.onap.ccsdk.sli.adaptors.netbox.model.Prefix; -import org.onap.ccsdk.sli.adaptors.netbox.model.Status; +import org.onap.ccsdk.sli.adaptors.netbox.model.IPStatus; import org.onap.ccsdk.sli.core.dblib.DbLibService; -import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; +import org.onap.ccsdk.sli.core.sli.SvcLogicContext; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus; +import org.onap.ccsdk.sli.core.slipluginutils.SliPluginUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -public class NetboxClientImpl implements NetboxClient, SvcLogicJavaPlugin { +public class NetboxClientImpl implements NetboxClient { + + private static final Logger LOG = LoggerFactory.getLogger(NetboxClientImpl.class); private static final String NEXT_AVAILABLE_IP_IN_PREFIX_PATH = "/api/ipam/prefixes/%s/available-ips/"; private static final String IP_ADDRESS_PATH = "/api/ipam/ip-addresses/%s/"; private static final String EMPTY_STRING = ""; - private static final String ID_MISSING_MSG = "Id must be set"; + private static final String SERVICE_INSTANCE_ID_PROP = "service_instance_id"; + private static final String VF_MODULE_ID_PROP = "vf_module_id"; private static final String ASSIGN_IP_SQL_STATEMENT = - "INSERT INTO IPAM_IP_ASSIGNEMENT (service_instance_id, vf_module_id, prefix_id, ip_address_id, ip_adress, ip_status) \n" - + "VALUES (?, ?, ?, ?, ?, ?)"; + "INSERT INTO IPAM_IP_ASSIGNEMENT (service_instance_id, vf_module_id, prefix_id, ip_address_id, ip_address, ip_status, ip_response_json) \n" + + "VALUES (?, ?, ?, ?, ?, ?, ?)"; private static final String UNASSIGN_IP_SQL_STATEMENT = - "DELETE FROM IPAM_IP_ASSIGNEMENT WHERE service_instance_id = ? AND vf_module_id = ? AND ip_address_id = ?"; + "UPDATE IPAM_IP_ASSIGNEMENT SET ip_status = ? WHERE service_instance_id = ? AND vf_module_id = ? AND ip_address_id = ?"; private final NetboxHttpClient client; - private final Gson gson; + private final DbLibService dbLibService; public NetboxClientImpl(final NetboxHttpClient client, final DbLibService dbLibService) { this.client = client; this.dbLibService = dbLibService; - final JsonSerializer vlanStatusDeserializer = (val, type, context) -> val.toJson(); - gson = new GsonBuilder() - .registerTypeAdapter(Status.class, vlanStatusDeserializer) - .create(); } @Override - public IPAddress assign(final Prefix prefix, final String serviceInstanceId, final String vfModuleId) - throws IpamException, SQLException { + public QueryStatus assignIpAddress(final Map parameters, final SvcLogicContext ctx) { - checkArgument(prefix.getId() != null); try { - IPAddress ipAddress = client - .post(String.format(NEXT_AVAILABLE_IP_IN_PREFIX_PATH, prefix.getId()), EMPTY_STRING) - .thenApply(this::getIpAddress) - .toCompletableFuture() - .join(); - - ArrayList args = Lists.newArrayList(serviceInstanceId, - vfModuleId, - String.valueOf(prefix.getId()), - String.valueOf(ipAddress.getId()), - ipAddress.getAddress(), - ipAddress.getStatus().getLabel()); - dbLibService.writeData(ASSIGN_IP_SQL_STATEMENT, args, null); + SliPluginUtils + .checkParameters(parameters, new String[]{SERVICE_INSTANCE_ID_PROP, VF_MODULE_ID_PROP, "prefix_id"}, + LOG); + } catch (SvcLogicException e) { + return QueryStatus.FAILURE; + } - return ipAddress; - } catch (CompletionException e) { - // Unwrap the CompletionException and wrap in IpamException - throw new IpamException("Fail to assign IP for Prefix(id= " + prefix.getId() + "). " + e.getMessage(), - e.getCause()); + final String serviceInstanceId = parameters.get(SERVICE_INSTANCE_ID_PROP); + LOG.trace("assignIpAddress: service_instance_id = {}", serviceInstanceId); + final String vfModuleId = parameters.get(VF_MODULE_ID_PROP); + LOG.trace("assignIpAddress: vf_module_id = {}", vfModuleId); + final String prefixId = parameters.get("prefix_id"); + LOG.trace("assignIpAddress: prefix_id = {}", prefixId); + + HttpResponse httpResp; + try { + httpResp = client + .post(String.format(NEXT_AVAILABLE_IP_IN_PREFIX_PATH, prefixId), EMPTY_STRING); + } catch (IOException e) { + LOG.error("Fail to assign IP for Prefix(id={}). {}", prefixId, e.getMessage(), e.getCause()); + return QueryStatus.FAILURE; } - } - @Override - public void unassign(final IPAddress ipAddress, final String serviceInstanceId, final String vfModuleId) - throws IpamException, SQLException { + String ipamRespJson; + try { + ipamRespJson = EntityUtils.toString(httpResp.getEntity(), "UTF-8"); + } catch (IOException e) { + LOG.error("Fail to parse IPAM response for assign in Prefix(id={}). Response={}", prefixId, + httpResp.getEntity(), e); + return QueryStatus.FAILURE; + } + + if (httpResp.getStatusLine().getStatusCode() != 201) { + LOG.error("Fail to assign IP for Prefix(id={}). HTTP code 201!={}. Response={}", prefixId, + httpResp.getStatusLine().getStatusCode(), ipamRespJson); + return QueryStatus.FAILURE; + } - checkArgument(ipAddress.getId() != null); + IPAddress ipAddress; try { - client.delete(String.format(IP_ADDRESS_PATH, ipAddress.getId())) - .thenAccept(this::checkResult) - .toCompletableFuture() - .join(); - - ArrayList args = Lists.newArrayList( - serviceInstanceId, - vfModuleId, - String.valueOf(ipAddress.getId())); - dbLibService.writeData(UNASSIGN_IP_SQL_STATEMENT, args, null); + ipAddress = IPAddress.fromJson(ipamRespJson); + } catch (JsonSyntaxException e) { + LOG.error("Fail to parse IPAM JSON reponse to IPAddress POJO. IPAM JSON Response={}", ipamRespJson, e); + return QueryStatus.FAILURE; + } - } catch (CompletionException e) { - // Unwrap the CompletionException and wrap in IpamException - throw new IpamException( - "Fail to unassign IP for IPAddress(id= " + ipAddress.getId() + "). " + e.getMessage(), - e.getCause()); + ArrayList args = Lists.newArrayList(serviceInstanceId, + vfModuleId, + String.valueOf(prefixId), + String.valueOf(ipAddress.getId()), + ipAddress.getAddress(), + IPStatus.ASSIGNED.name(), + ipamRespJson); + + try { + dbLibService.writeData(ASSIGN_IP_SQL_STATEMENT, args, null); + } catch (SQLException e) { + LOG.error("Caught SQL exception", e); + return QueryStatus.FAILURE; } + + ctx.setAttribute("self_serve_netbox_ip_assignement.ip-address", ipAddress.getAddress()); + + return QueryStatus.SUCCESS; } - @VisibleForTesting - IPAddress getIpAddress(final HttpResponse response) { - if (response.getStatusLine().getStatusCode() != 201) { - throw new IllegalStateException(NetboxHttpClient.getBodyAsString(response)); + @Override + public QueryStatus unassignIpAddress(final Map parameters, final SvcLogicContext ctx) { + try { + SliPluginUtils + .checkParameters(parameters, new String[]{SERVICE_INSTANCE_ID_PROP, VF_MODULE_ID_PROP, "ip_address_id"}, + LOG); + } catch (SvcLogicException e) { + return QueryStatus.FAILURE; } - try (final Reader reader = new InputStreamReader(response.getEntity().getContent())) { - return gson.fromJson(reader, IPAddress.class); - } catch (final IOException e) { - throw new IllegalStateException(e); + + final String serviceInstanceId = parameters.get(SERVICE_INSTANCE_ID_PROP); + LOG.trace("assignIpAddress: service_instance_id = {}", serviceInstanceId); + final String vfModuleId = parameters.get(VF_MODULE_ID_PROP); + LOG.trace("assignIpAddress: vf_module_id = {}", vfModuleId); + final String ipAddressId = parameters.get("ip_address_id"); + LOG.trace("assignIpAddress: ip_address_id = {}", ipAddressId); + HttpResponse httpResp; + try { + httpResp = client.delete(String.format(IP_ADDRESS_PATH, ipAddressId)); + } catch (IOException e) { + LOG.error("Fail to unassign IP for IPAddress(id= " + ipAddressId + "). " + e.getMessage(), + e.getCause()); + return QueryStatus.FAILURE; } - } - private static void checkArgument(final boolean argument) throws IpamException { - if (!argument) { - throw new IpamException(ID_MISSING_MSG); + if (httpResp.getStatusLine().getStatusCode() - 200 >= 100) { + LOG.error("Fail to unassign IP for IPAddress(id={}). HTTP code={}.", ipAddressId, + httpResp.getStatusLine().getStatusCode()); + return QueryStatus.FAILURE; } - } - private void checkResult(final HttpResponse response) { - if (response.getStatusLine().getStatusCode() - 200 >= 100) { - throw new IllegalStateException( - "Netbox request failed with status: " + NetboxHttpClient.getBodyAsString(response)); + ArrayList args = Lists.newArrayList( + IPStatus.UNASSIGNED.name(), + serviceInstanceId, + vfModuleId, + String.valueOf(ipAddressId)); + try { + dbLibService.writeData(UNASSIGN_IP_SQL_STATEMENT, args, null); + } catch (SQLException e) { + LOG.error("Caught SQL exception", e); + return QueryStatus.FAILURE; } + + return QueryStatus.SUCCESS; } } diff --git a/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxHttpClient.java b/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxHttpClient.java index a77b4d3e9..505c5a77e 100644 --- a/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxHttpClient.java +++ b/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxHttpClient.java @@ -24,31 +24,24 @@ import java.nio.charset.Charset; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.util.Scanner; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import java.util.function.Function; import javax.net.ssl.SSLContext; -import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.concurrent.FutureCallback; +import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.entity.StringEntity; -import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; -import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.ssl.SSLContexts; import org.apache.http.ssl.TrustStrategy; -import org.onap.ccsdk.sli.adaptors.netbox.api.IpamException; import org.onap.ccsdk.sli.adaptors.netbox.property.NetboxProperties; public class NetboxHttpClient implements AutoCloseable { private static final String APPLICATION_JSON = "application/json"; - private final CloseableHttpAsyncClient client; + private final CloseableHttpClient client; private final String url; private final String token; @@ -69,16 +62,10 @@ public class NetboxHttpClient implements AutoCloseable { } catch (final NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) { throw new IllegalStateException("Can't create http client", e); } - client = HttpAsyncClientBuilder.create() + client = HttpClientBuilder.create() .setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE) .setSSLContext(sslContext) .build(); - - } - - // Has to be public for blueprint container to access it - public void init() { - client.start(); } @Override @@ -86,66 +73,22 @@ public class NetboxHttpClient implements AutoCloseable { client.close(); } - CompletionStage post(final String uri, final String requestBody) { - return sendRequest(uri, requestBody, HttpPost::new); - } - - CompletionStage delete(final String uri) { - return sendRequest(uri, HttpDelete::new); + HttpResponse post(final String uri, final String requestBody) throws IOException { + final HttpPost request = new HttpPost(url + uri); + setHeaders(request); + request.setEntity(new StringEntity(requestBody, Charset.forName("UTF-8"))); + return client.execute(request); } - static String getBodyAsString(final HttpResponse response) { - final String body; - if (response.getEntity() != null) { - try (final Scanner s = new java.util.Scanner(response.getEntity().getContent()).useDelimiter("\\A")) { - body = s.hasNext() ? s.next() : ""; - } catch (final IOException e) { - throw new IllegalStateException(e); - } - } else { - body = ""; - } - return response.toString() + "\n" + body; + HttpResponse delete(final String uri) throws IOException { + final HttpDelete request = new HttpDelete(url + uri); + setHeaders(request); + return client.execute(request); } - private CompletionStage sendRequest(final String uri, - final Function supplier) { - final T request = supplier.apply(url + uri); + private void setHeaders(final HttpRequestBase request) { request.addHeader(ACCEPT, APPLICATION_JSON); request.addHeader(CONTENT_TYPE, APPLICATION_JSON); request.addHeader(AUTHORIZATION, "Token " + token); - return sendRequest(request); - } - - private - CompletionStage sendRequest(final String uri, final String body, - final Function supplier) { - final T request = supplier.apply(url + uri); - request.addHeader(ACCEPT, APPLICATION_JSON); - request.addHeader(CONTENT_TYPE, APPLICATION_JSON); - request.addHeader(AUTHORIZATION, "Token " + token); - request.setEntity(new StringEntity(body, Charset.forName("UTF-8"))); - return sendRequest(request); - } - - private CompletionStage sendRequest(final HttpUriRequest request) { - final CompletableFuture future = new CompletableFuture<>(); - client.execute(request, new FutureCallback() { - @Override - public void completed(final HttpResponse httpResponse) { - future.complete(httpResponse); - } - - @Override - public void failed(final Exception e) { - future.completeExceptionally(new IpamException("Netbox request failed", e)); - } - - @Override - public void cancelled() { - future.cancel(false); - } - }); - return future; } } \ No newline at end of file diff --git a/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/model/IPAddress.java b/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/model/IPAddress.java index 6d62fff9f..4c2880bc4 100644 --- a/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/model/IPAddress.java +++ b/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/model/IPAddress.java @@ -15,25 +15,20 @@ */ package org.onap.ccsdk.sli.adaptors.netbox.model; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import java.util.Objects; public class IPAddress extends Identifiable { - private Status.Values status; - private String address; + private static final Gson gson = new GsonBuilder().create(); - public void setStatus(Status.Values status) { - this.status = status; - } + private String address; public void setAddress(String address) { this.address = address; } - public Status.Values getStatus() { - return status; - } - public String getAddress() { return address; } @@ -47,12 +42,15 @@ public class IPAddress extends Identifiable { return false; } IPAddress ipAddress = (IPAddress) o; - return Objects.equals(status, ipAddress.status) && - Objects.equals(address, ipAddress.address); + return Objects.equals(address, ipAddress.address); } @Override public int hashCode() { - return Objects.hash(status, address); + return Objects.hash(address); + } + + public static IPAddress fromJson(final String json) { + return gson.fromJson(json, IPAddress.class); } } diff --git a/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/model/IPStatus.java b/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/model/IPStatus.java new file mode 100644 index 000000000..05cc1ea29 --- /dev/null +++ b/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/model/IPStatus.java @@ -0,0 +1,5 @@ +package org.onap.ccsdk.sli.adaptors.netbox.model; + +public enum IPStatus { + ASSIGNED, UNASSIGNED, PENDING_ASSIGN, PENDING_UNASSIGN +} diff --git a/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/model/Status.java b/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/model/Status.java deleted file mode 100644 index c56828a80..000000000 --- a/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/model/Status.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2018 Bell Canada. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onap.ccsdk.sli.adaptors.netbox.model; - -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import com.google.gson.annotations.SerializedName; - -public class Status { - - private Integer value; - private String label; - - public Integer getValue() { - return value; - } - - public void setValue(final Integer value) { - this.value = value; - } - - public String getLabel() { - return label; - } - - public void setLabel(final String label) { - this.label = label; - } - - public JsonElement toJson() { - return new JsonPrimitive(value); - } - - public enum Values { - @SerializedName("1") - ACTIVE(1, "Active"), - @SerializedName("2") - RESERVED(2, "Reserved"); - - private final int value; - private final String label; - - Values(final int value, final String label) { - this.value = value; - this.label = label; - } - - public int getValue() { - return value; - } - - public String getLabel() { - return label; - } - - public Status getStatus() { - final Status status = new Status(); - status.setValue(value); - status.setLabel(label); - return status; - } - - } -} diff --git a/netbox-client/provider/src/main/resources/org/opendaylight/blueprint/netbox-client.xml b/netbox-client/provider/src/main/resources/org/opendaylight/blueprint/netbox-client.xml index 950fd97b0..b667dcba5 100644 --- a/netbox-client/provider/src/main/resources/org/opendaylight/blueprint/netbox-client.xml +++ b/netbox-client/provider/src/main/resources/org/opendaylight/blueprint/netbox-client.xml @@ -21,8 +21,7 @@ interface="org.onap.ccsdk.sli.core.dblib.DbLibService"/> - + -- cgit 1.2.3-korg