From 27844684c55fe1c01d701cfbe562d644aa221858 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 23 Jan 2026 16:57:28 +0530 Subject: [PATCH] changes Signed-off-by: Abhishek Kumar --- .../cloudstack/veeam/api/ApiService.java | 8 +- .../veeam/api/ClustersRouteHandler.java | 12 +- .../veeam/api/DataCentersRouteHandler.java | 52 ++++-- .../veeam/api/HostsRouteHandler.java | 111 ++++++++++++ .../veeam/api/NetworksRouteHandler.java | 123 +++++++++++++ .../cloudstack/veeam/api/VmsRouteHandler.java | 1 - .../veeam/api/VnicProfilesRouteHandler.java | 123 +++++++++++++ .../ClusterVOToClusterConverter.java | 12 +- ...ataCenterJoinVOToDataCenterConverter.java} | 10 +- .../converter/HostJoinVOToHostConverter.java | 113 ++++++++++++ .../NetworkVOToNetworkConverter.java | 80 +++++++++ .../NetworkVOToVnicProfileConverter.java | 65 +++++++ .../apache/cloudstack/veeam/api/dto/Api.java | 2 +- .../api/dto/{Summary.java => ApiSummary.java} | 4 +- .../cloudstack/veeam/api/dto/Certificate.java | 36 ++++ .../apache/cloudstack/veeam/api/dto/Cpu.java | 11 ++ .../veeam/api/dto/HardwareInformation.java | 51 ++++++ .../apache/cloudstack/veeam/api/dto/Host.java | 169 ++++++++++++++++++ .../cloudstack/veeam/api/dto/HostSummary.java | 40 +++++ .../cloudstack/veeam/api/dto/Hosts.java | 33 ++++ .../cloudstack/veeam/api/dto/Network.java | 85 +++++++++ .../veeam/api/dto/NetworkUsages.java | 42 +++++ .../cloudstack/veeam/api/dto/Networks.java | 33 ++++ .../cloudstack/veeam/api/dto/OsVersion.java | 41 +++++ .../cloudstack/veeam/api/dto/VnicProfile.java | 99 ++++++++++ .../veeam/api/dto/VnicProfiles.java | 49 +++++ .../veeam/filter/BearerOrBasicAuthFilter.java | 2 +- .../cloudstack/veeam/sso/SsoService.java | 4 +- .../spring-veeam-control-service-context.xml | 5 +- 29 files changed, 1377 insertions(+), 39 deletions(-) create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/HostsRouteHandler.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/NetworksRouteHandler.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/VnicProfilesRouteHandler.java rename plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/{DataCenterVOToDataCenterConverter.java => DataCenterJoinVOToDataCenterConverter.java} (91%) create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/HostJoinVOToHostConverter.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/NetworkVOToNetworkConverter.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/NetworkVOToVnicProfileConverter.java rename plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/{Summary.java => ApiSummary.java} (95%) create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Certificate.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/HardwareInformation.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Host.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/HostSummary.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Hosts.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Network.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/NetworkUsages.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Networks.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/OsVersion.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/VnicProfile.java create mode 100644 plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/VnicProfiles.java diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/ApiService.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/ApiService.java index bb37c300d84..24a9dbb730e 100644 --- a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/ApiService.java +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/ApiService.java @@ -18,6 +18,7 @@ package org.apache.cloudstack.veeam.api; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.time.OffsetDateTime; import java.time.ZoneOffset; import java.util.ArrayList; @@ -37,11 +38,12 @@ import org.apache.cloudstack.veeam.api.dto.ProductInfo; import org.apache.cloudstack.veeam.api.dto.Ref; import org.apache.cloudstack.veeam.api.dto.SpecialObjectRef; import org.apache.cloudstack.veeam.api.dto.SpecialObjects; -import org.apache.cloudstack.veeam.api.dto.Summary; +import org.apache.cloudstack.veeam.api.dto.ApiSummary; import org.apache.cloudstack.veeam.api.dto.SummaryCount; import org.apache.cloudstack.veeam.api.dto.Version; import org.apache.cloudstack.veeam.utils.Negotiation; +import com.cloud.utils.UuidUtils; import com.cloud.utils.component.ManagerBase; public class ApiService extends ManagerBase implements RouteHandler { @@ -99,7 +101,7 @@ public class ApiService extends ManagerBase implements RouteHandler { /* ---------------- Product info ---------------- */ ProductInfo productInfo = new ProductInfo(); - productInfo.instanceId = UUID.randomUUID().toString(); + productInfo.instanceId = UuidUtils.nameUUIDFromBytes(VeeamControlService.BindAddress.value().getBytes(StandardCharsets.UTF_8)).toString(); productInfo.name = "oVirt Engine"; Version version = new Version(); @@ -125,7 +127,7 @@ public class ApiService extends ManagerBase implements RouteHandler { api.specialObjects = specialObjects; /* ---------------- Summary ---------------- */ - Summary summary = new Summary(); + ApiSummary summary = new ApiSummary(); summary.hosts = new SummaryCount(1, 1); summary.storageDomains = new SummaryCount(1, 2); summary.users = new SummaryCount(1, 1); diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/ClustersRouteHandler.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/ClustersRouteHandler.java index bb14b614479..6459ad06f82 100644 --- a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/ClustersRouteHandler.java +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/ClustersRouteHandler.java @@ -32,10 +32,10 @@ import org.apache.cloudstack.veeam.api.dto.Clusters; import org.apache.cloudstack.veeam.utils.Negotiation; import org.apache.cloudstack.veeam.utils.PathUtil; +import com.cloud.api.query.dao.DataCenterJoinDao; +import com.cloud.api.query.vo.DataCenterJoinVO; import com.cloud.dc.ClusterVO; -import com.cloud.dc.DataCenterVO; import com.cloud.dc.dao.ClusterDao; -import com.cloud.dc.dao.DataCenterDao; import com.cloud.utils.Pair; import com.cloud.utils.component.ManagerBase; @@ -46,7 +46,7 @@ public class ClustersRouteHandler extends ManagerBase implements RouteHandler { ClusterDao clusterDao; @Inject - DataCenterDao dataCenterDao; + DataCenterJoinDao dataCenterJoinDao; @Override public boolean start() { @@ -78,7 +78,7 @@ public class ClustersRouteHandler extends ManagerBase implements RouteHandler { Pair idAndSubPath = PathUtil.extractIdAndSubPath(sanitizedPath, BASE_ROUTE); if (idAndSubPath != null) { - // /api/disks/{id} + // /api/clusters/{id} if (idAndSubPath.first() != null) { if (idAndSubPath.second() == null) { handleGetById(idAndSubPath.first(), resp, outFormat, io); @@ -114,10 +114,10 @@ public class ClustersRouteHandler extends ManagerBase implements RouteHandler { io.getWriter().write(resp, 200, response, outFormat); } - private DataCenterVO getZoneById(Long zoneId) { + private DataCenterJoinVO getZoneById(Long zoneId) { if (zoneId == null) { return null; } - return dataCenterDao.findById(zoneId); + return dataCenterJoinDao.findById(zoneId); } } diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/DataCentersRouteHandler.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/DataCentersRouteHandler.java index c49f078121a..459b076fefe 100644 --- a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/DataCentersRouteHandler.java +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/DataCentersRouteHandler.java @@ -26,21 +26,26 @@ import javax.servlet.http.HttpServletResponse; import org.apache.cloudstack.veeam.RouteHandler; import org.apache.cloudstack.veeam.VeeamControlServlet; -import org.apache.cloudstack.veeam.api.converter.DataCenterVOToDataCenterConverter; +import org.apache.cloudstack.veeam.api.converter.DataCenterJoinVOToDataCenterConverter; +import org.apache.cloudstack.veeam.api.converter.NetworkVOToNetworkConverter; import org.apache.cloudstack.veeam.api.converter.StoreVOToStorageDomainConverter; import org.apache.cloudstack.veeam.api.dto.DataCenter; import org.apache.cloudstack.veeam.api.dto.DataCenters; +import org.apache.cloudstack.veeam.api.dto.Network; +import org.apache.cloudstack.veeam.api.dto.Networks; import org.apache.cloudstack.veeam.api.dto.StorageDomain; import org.apache.cloudstack.veeam.api.dto.StorageDomains; import org.apache.cloudstack.veeam.utils.Negotiation; import org.apache.cloudstack.veeam.utils.PathUtil; +import com.cloud.api.query.dao.DataCenterJoinDao; import com.cloud.api.query.dao.ImageStoreJoinDao; import com.cloud.api.query.dao.StoragePoolJoinDao; +import com.cloud.api.query.vo.DataCenterJoinVO; import com.cloud.api.query.vo.ImageStoreJoinVO; import com.cloud.api.query.vo.StoragePoolJoinVO; -import com.cloud.dc.DataCenterVO; -import com.cloud.dc.dao.DataCenterDao; +import com.cloud.network.dao.NetworkDao; +import com.cloud.network.dao.NetworkVO; import com.cloud.utils.Pair; import com.cloud.utils.component.ManagerBase; @@ -51,7 +56,7 @@ public class DataCentersRouteHandler extends ManagerBase implements RouteHandler private static final int DEFAULT_PAGE = 1; @Inject - DataCenterDao dataCenterDao; + DataCenterJoinDao dataCenterJoinDao; @Inject StoragePoolJoinDao storagePoolJoinDao; @@ -59,6 +64,9 @@ public class DataCentersRouteHandler extends ManagerBase implements RouteHandler @Inject ImageStoreJoinDao imageStoreJoinDao; + @Inject + NetworkDao networkDao; + @Override public boolean start() { return true; @@ -99,6 +107,10 @@ public class DataCentersRouteHandler extends ManagerBase implements RouteHandler handleGetStorageDomainsByDcId(idAndSubPath.first(), resp, outFormat, io); return; } + if ("networks".equals(idAndSubPath.second())) { + handleGetNetworksByDcId(idAndSubPath.first(), resp, outFormat, io); + return; + } } } @@ -107,24 +119,24 @@ public class DataCentersRouteHandler extends ManagerBase implements RouteHandler public void handleGet(final HttpServletRequest req, final HttpServletResponse resp, Negotiation.OutFormat outFormat, VeeamControlServlet io) throws IOException { - final List result = DataCenterVOToDataCenterConverter.toDCList(listDCs()); + final List result = DataCenterJoinVOToDataCenterConverter.toDCList(listDCs()); final DataCenters response = new DataCenters(result); io.getWriter().write(resp, 200, response, outFormat); } - protected List listDCs() { - return dataCenterDao.listAll(); + protected List listDCs() { + return dataCenterJoinDao.listAll(); } public void handleGetById(final String id, final HttpServletResponse resp, final Negotiation.OutFormat outFormat, final VeeamControlServlet io) throws IOException { - final DataCenterVO dataCenterVO = dataCenterDao.findByUuid(id); + final DataCenterJoinVO dataCenterVO = dataCenterJoinDao.findByUuid(id); if (dataCenterVO == null) { io.notFound(resp, "DataCenter not found: " + id, outFormat); return; } - DataCenter response = DataCenterVOToDataCenterConverter.toDataCenter(dataCenterVO); + DataCenter response = DataCenterJoinVOToDataCenterConverter.toDataCenter(dataCenterVO); io.getWriter().write(resp, 200, response, outFormat); } @@ -137,9 +149,13 @@ public class DataCentersRouteHandler extends ManagerBase implements RouteHandler return imageStoreJoinDao.listAll(); } + protected List listNetworksByDcId(final long dcId) { + return networkDao.listAll(); + } + public void handleGetStorageDomainsByDcId(final String id, final HttpServletResponse resp, final Negotiation.OutFormat outFormat, - final VeeamControlServlet io) throws IOException { - final DataCenterVO dataCenterVO = dataCenterDao.findByUuid(id); + final VeeamControlServlet io) throws IOException { + final DataCenterJoinVO dataCenterVO = dataCenterJoinDao.findByUuid(id); if (dataCenterVO == null) { io.notFound(resp, "DataCenter not found: " + id, outFormat); return; @@ -151,4 +167,18 @@ public class DataCentersRouteHandler extends ManagerBase implements RouteHandler io.getWriter().write(resp, 200, response, outFormat); } + + public void handleGetNetworksByDcId(final String id, final HttpServletResponse resp, final Negotiation.OutFormat outFormat, + final VeeamControlServlet io) throws IOException { + final DataCenterJoinVO dataCenterVO = dataCenterJoinDao.findByUuid(id); + if (dataCenterVO == null) { + io.notFound(resp, "DataCenter not found: " + id, outFormat); + return; + } + List networks = NetworkVOToNetworkConverter.toNetworkList(listNetworksByDcId(dataCenterVO.getId()), (dcId) -> dataCenterVO); + + Networks response = new Networks(networks); + + io.getWriter().write(resp, 200, response, outFormat); + } } \ No newline at end of file diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/HostsRouteHandler.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/HostsRouteHandler.java new file mode 100644 index 00000000000..b33fa9bda9c --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/HostsRouteHandler.java @@ -0,0 +1,111 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api; + +import java.io.IOException; +import java.util.List; + +import javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.cloudstack.veeam.RouteHandler; +import org.apache.cloudstack.veeam.VeeamControlServlet; +import org.apache.cloudstack.veeam.api.converter.HostJoinVOToHostConverter; +import org.apache.cloudstack.veeam.api.dto.Host; +import org.apache.cloudstack.veeam.api.dto.Hosts; +import org.apache.cloudstack.veeam.utils.Negotiation; +import org.apache.cloudstack.veeam.utils.PathUtil; + +import com.cloud.api.query.dao.HostJoinDao; +import com.cloud.api.query.vo.HostJoinVO; +import com.cloud.utils.Pair; +import com.cloud.utils.component.ManagerBase; + +public class HostsRouteHandler extends ManagerBase implements RouteHandler { + public static final String BASE_ROUTE = "/api/hosts"; + + @Inject + HostJoinDao hostJoinDao; + + @Override + public boolean start() { + return true; + } + + @Override + public int priority() { + return 5; + } + + @Override + public boolean canHandle(String method, String path) { + return getSanitizedPath(path).startsWith(BASE_ROUTE); + } + + @Override + public void handle(HttpServletRequest req, HttpServletResponse resp, String path, Negotiation.OutFormat outFormat, VeeamControlServlet io) throws IOException { + final String method = req.getMethod(); + if (!"GET".equalsIgnoreCase(method)) { + io.methodNotAllowed(resp, "GET", outFormat); + return; + } + final String sanitizedPath = getSanitizedPath(path); + if (sanitizedPath.equals(BASE_ROUTE)) { + handleGet(req, resp, outFormat, io); + return; + } + + Pair idAndSubPath = PathUtil.extractIdAndSubPath(sanitizedPath, BASE_ROUTE); + if (idAndSubPath != null) { + // /api/hosts/{id} + if (idAndSubPath.first() != null) { + if (idAndSubPath.second() == null) { + handleGetById(idAndSubPath.first(), resp, outFormat, io); + return; + } + } + } + + resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Not found"); + } + + public void handleGet(final HttpServletRequest req, final HttpServletResponse resp, + Negotiation.OutFormat outFormat, VeeamControlServlet io) throws IOException { + final List result = HostJoinVOToHostConverter.toHostList(listHosts()); + final Hosts response = new Hosts(result); + + io.getWriter().write(resp, 200, response, outFormat); + } + + protected List listHosts() { + return hostJoinDao.listAll(); + } + + public void handleGetById(final String id, final HttpServletResponse resp, final Negotiation.OutFormat outFormat, + final VeeamControlServlet io) throws IOException { + final HostJoinVO vo = hostJoinDao.findByUuid(id); + if (vo == null) { + io.notFound(resp, "DataCenter not found: " + id, outFormat); + return; + } + Host response = HostJoinVOToHostConverter.toHost(vo); + + io.getWriter().write(resp, 200, response, outFormat); + } +} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/NetworksRouteHandler.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/NetworksRouteHandler.java new file mode 100644 index 00000000000..c3bab348f4e --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/NetworksRouteHandler.java @@ -0,0 +1,123 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api; + +import java.io.IOException; +import java.util.List; + +import javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.cloudstack.veeam.RouteHandler; +import org.apache.cloudstack.veeam.VeeamControlServlet; +import org.apache.cloudstack.veeam.api.converter.NetworkVOToNetworkConverter; +import org.apache.cloudstack.veeam.api.dto.Network; +import org.apache.cloudstack.veeam.api.dto.Networks; +import org.apache.cloudstack.veeam.utils.Negotiation; +import org.apache.cloudstack.veeam.utils.PathUtil; + +import com.cloud.api.query.dao.DataCenterJoinDao; +import com.cloud.api.query.vo.DataCenterJoinVO; +import com.cloud.network.dao.NetworkDao; +import com.cloud.network.dao.NetworkVO; +import com.cloud.utils.Pair; +import com.cloud.utils.component.ManagerBase; + +public class NetworksRouteHandler extends ManagerBase implements RouteHandler { + public static final String BASE_ROUTE = "/api/networks"; + + @Inject + NetworkDao networkDao; + + @Inject + DataCenterJoinDao dataCenterJoinDao; + + @Override + public boolean start() { + return true; + } + + @Override + public int priority() { + return 5; + } + + @Override + public boolean canHandle(String method, String path) { + return getSanitizedPath(path).startsWith(BASE_ROUTE); + } + + @Override + public void handle(HttpServletRequest req, HttpServletResponse resp, String path, Negotiation.OutFormat outFormat, VeeamControlServlet io) throws IOException { + final String method = req.getMethod(); + if (!"GET".equalsIgnoreCase(method)) { + io.methodNotAllowed(resp, "GET", outFormat); + return; + } + final String sanitizedPath = getSanitizedPath(path); + if (sanitizedPath.equals(BASE_ROUTE)) { + handleGet(req, resp, outFormat, io); + return; + } + + Pair idAndSubPath = PathUtil.extractIdAndSubPath(sanitizedPath, BASE_ROUTE); + if (idAndSubPath != null) { + // /api/networks/{id} + if (idAndSubPath.first() != null) { + if (idAndSubPath.second() == null) { + handleGetById(idAndSubPath.first(), resp, outFormat, io); + return; + } + } + } + + resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Not found"); + } + + public void handleGet(final HttpServletRequest req, final HttpServletResponse resp, + Negotiation.OutFormat outFormat, VeeamControlServlet io) throws IOException { + final List result = NetworkVOToNetworkConverter.toNetworkList(listNetworks(), this::getZoneById); + final Networks response = new Networks(result); + + io.getWriter().write(resp, 200, response, outFormat); + } + + protected List listNetworks() { + return networkDao.listAll(); + } + + public void handleGetById(final String id, final HttpServletResponse resp, final Negotiation.OutFormat outFormat, + final VeeamControlServlet io) throws IOException { + final NetworkVO vo = networkDao.findByUuid(id); + if (vo == null) { + io.notFound(resp, "DataCenter not found: " + id, outFormat); + return; + } + Network response = NetworkVOToNetworkConverter.toNetwork(vo, this::getZoneById); + + io.getWriter().write(resp, 200, response, outFormat); + } + + private DataCenterJoinVO getZoneById(Long zoneId) { + if (zoneId == null) { + return null; + } + return dataCenterJoinDao.findById(zoneId); + } +} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/VmsRouteHandler.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/VmsRouteHandler.java index dc92f58715f..02c314c08eb 100644 --- a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/VmsRouteHandler.java +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/VmsRouteHandler.java @@ -208,5 +208,4 @@ public class VmsRouteHandler extends ManagerBase implements RouteHandler { } return hostJoinDao.findById(hostId); } - } \ No newline at end of file diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/VnicProfilesRouteHandler.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/VnicProfilesRouteHandler.java new file mode 100644 index 00000000000..9c2ffcca912 --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/VnicProfilesRouteHandler.java @@ -0,0 +1,123 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api; + +import java.io.IOException; +import java.util.List; + +import javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.cloudstack.veeam.RouteHandler; +import org.apache.cloudstack.veeam.VeeamControlServlet; +import org.apache.cloudstack.veeam.api.converter.NetworkVOToVnicProfileConverter; +import org.apache.cloudstack.veeam.api.dto.VnicProfile; +import org.apache.cloudstack.veeam.api.dto.VnicProfiles; +import org.apache.cloudstack.veeam.utils.Negotiation; +import org.apache.cloudstack.veeam.utils.PathUtil; + +import com.cloud.api.query.dao.DataCenterJoinDao; +import com.cloud.api.query.vo.DataCenterJoinVO; +import com.cloud.network.dao.NetworkDao; +import com.cloud.network.dao.NetworkVO; +import com.cloud.utils.Pair; +import com.cloud.utils.component.ManagerBase; + +public class VnicProfilesRouteHandler extends ManagerBase implements RouteHandler { + public static final String BASE_ROUTE = "/api/vnicprofiles"; + + @Inject + NetworkDao networkDao; + + @Inject + DataCenterJoinDao dataCenterJoinDao; + + @Override + public boolean start() { + return true; + } + + @Override + public int priority() { + return 5; + } + + @Override + public boolean canHandle(String method, String path) { + return getSanitizedPath(path).startsWith(BASE_ROUTE); + } + + @Override + public void handle(HttpServletRequest req, HttpServletResponse resp, String path, Negotiation.OutFormat outFormat, VeeamControlServlet io) throws IOException { + final String method = req.getMethod(); + if (!"GET".equalsIgnoreCase(method)) { + io.methodNotAllowed(resp, "GET", outFormat); + return; + } + final String sanitizedPath = getSanitizedPath(path); + if (sanitizedPath.equals(BASE_ROUTE)) { + handleGet(req, resp, outFormat, io); + return; + } + + Pair idAndSubPath = PathUtil.extractIdAndSubPath(sanitizedPath, BASE_ROUTE); + if (idAndSubPath != null) { + // /api/vnicprofiles/{id} + if (idAndSubPath.first() != null) { + if (idAndSubPath.second() == null) { + handleGetById(idAndSubPath.first(), resp, outFormat, io); + return; + } + } + } + + resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Not found"); + } + + public void handleGet(final HttpServletRequest req, final HttpServletResponse resp, + Negotiation.OutFormat outFormat, VeeamControlServlet io) throws IOException { + final List result = NetworkVOToVnicProfileConverter.toVnicProfileList(listNetworks(), this::getZoneById); + final VnicProfiles response = new VnicProfiles(result); + + io.getWriter().write(resp, 200, response, outFormat); + } + + protected List listNetworks() { + return networkDao.listAll(); + } + + public void handleGetById(final String id, final HttpServletResponse resp, final Negotiation.OutFormat outFormat, + final VeeamControlServlet io) throws IOException { + final NetworkVO vo = networkDao.findByUuid(id); + if (vo == null) { + io.notFound(resp, "DataCenter not found: " + id, outFormat); + return; + } + VnicProfile response = NetworkVOToVnicProfileConverter.toVnicProfile(vo, this::getZoneById); + + io.getWriter().write(resp, 200, response, outFormat); + } + + private DataCenterJoinVO getZoneById(Long zoneId) { + if (zoneId == null) { + return null; + } + return dataCenterJoinDao.findById(zoneId); + } +} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/ClusterVOToClusterConverter.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/ClusterVOToClusterConverter.java index 54176d4004a..3a2c9be5b48 100644 --- a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/ClusterVOToClusterConverter.java +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/ClusterVOToClusterConverter.java @@ -19,7 +19,6 @@ package org.apache.cloudstack.veeam.api.converter; import java.util.Collections; import java.util.List; -import java.util.UUID; import java.util.function.Function; import java.util.stream.Collectors; @@ -31,11 +30,12 @@ import org.apache.cloudstack.veeam.api.dto.Cluster; import org.apache.cloudstack.veeam.api.dto.Link; import org.apache.cloudstack.veeam.api.dto.Ref; +import com.cloud.api.query.vo.DataCenterJoinVO; import com.cloud.dc.ClusterVO; -import com.cloud.dc.DataCenterVO; +import com.cloud.utils.UuidUtils; public class ClusterVOToClusterConverter { - public static Cluster toCluster(final ClusterVO vo, final Function dataCenterResolver) { + public static Cluster toCluster(final ClusterVO vo, final Function dataCenterResolver) { final Cluster c = new Cluster(); final String basePath = VeeamControlService.ContextPath.value(); @@ -131,7 +131,7 @@ public class ClusterVOToClusterConverter { // --- data_center ref mapping (CloudStack cluster -> pod -> zone) if (dataCenterResolver != null) { - final DataCenterVO zone = dataCenterResolver.apply(vo.getDataCenterId()); + final DataCenterJoinVO zone = dataCenterResolver.apply(vo.getDataCenterId()); if (zone != null) { c.dataCenter = Ref.of(basePath + DataCentersRouteHandler.BASE_ROUTE + "/" + zone.getUuid(), zone.getUuid()); } @@ -157,7 +157,7 @@ public class ClusterVOToClusterConverter { } public static List toClusterList(final List voList, - final Function dataCenterResolver) { + final Function dataCenterResolver) { return voList.stream() .map(vo -> toCluster(vo, dataCenterResolver)) .collect(Collectors.toList()); @@ -165,6 +165,6 @@ public class ClusterVOToClusterConverter { private static String stableUuid(final String key) { // deterministic UUID, so the same ClusterVO maps to same "ovirt id" every time - return UUID.nameUUIDFromBytes(key.getBytes()).toString(); + return UuidUtils.nameUUIDFromBytes(key.getBytes()).toString(); } } diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/DataCenterVOToDataCenterConverter.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/DataCenterJoinVOToDataCenterConverter.java similarity index 91% rename from plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/DataCenterVOToDataCenterConverter.java rename to plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/DataCenterJoinVOToDataCenterConverter.java index c39b91a9684..465420fc984 100644 --- a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/DataCenterVOToDataCenterConverter.java +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/DataCenterJoinVOToDataCenterConverter.java @@ -29,11 +29,11 @@ import org.apache.cloudstack.veeam.api.dto.Ref; import org.apache.cloudstack.veeam.api.dto.SupportedVersions; import org.apache.cloudstack.veeam.api.dto.Version; -import com.cloud.dc.DataCenterVO; +import com.cloud.api.query.vo.DataCenterJoinVO; import com.cloud.org.Grouping; -public class DataCenterVOToDataCenterConverter { - public static DataCenter toDataCenter(final DataCenterVO zone) { +public class DataCenterJoinVOToDataCenterConverter { + public static DataCenter toDataCenter(final DataCenterJoinVO zone) { final String id = zone.getUuid(); final String basePath = VeeamControlService.ContextPath.value(); final String href = basePath + DataCentersRouteHandler.BASE_ROUTE + DataCentersRouteHandler.BASE_ROUTE + "/" + id; @@ -72,9 +72,9 @@ public class DataCenterVOToDataCenterConverter { return dc; } - public static List toDCList(final List srcList) { + public static List toDCList(final List srcList) { return srcList.stream() - .map(DataCenterVOToDataCenterConverter::toDataCenter) + .map(DataCenterJoinVOToDataCenterConverter::toDataCenter) .collect(Collectors.toList()); } } diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/HostJoinVOToHostConverter.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/HostJoinVOToHostConverter.java new file mode 100644 index 00000000000..32c9c3040e9 --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/HostJoinVOToHostConverter.java @@ -0,0 +1,113 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.converter; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import org.apache.cloudstack.veeam.VeeamControlService; +import org.apache.cloudstack.veeam.api.ClustersRouteHandler; +import org.apache.cloudstack.veeam.api.HostsRouteHandler; +import org.apache.cloudstack.veeam.api.dto.Cpu; +import org.apache.cloudstack.veeam.api.dto.Host; +import org.apache.cloudstack.veeam.api.dto.Ref; +import org.apache.cloudstack.veeam.api.dto.Topology; + +import com.cloud.api.query.vo.HostJoinVO; +import com.cloud.host.Status; +import com.cloud.resource.ResourceState; + +public class HostJoinVOToHostConverter { + + /** + * Convert CloudStack HostJoinVO -> oVirt-like Host. + * + * @param vo HostJoinVO from listHosts (join query) + */ + public static Host toHost(final HostJoinVO vo) { + final Host h = new Host(); + + final String hostUuid = vo.getUuid(); + + h.setId(hostUuid); + final String basePath = VeeamControlService.ContextPath.value(); + h.setHref(basePath + HostsRouteHandler.BASE_ROUTE + "/" + hostUuid); + + // --- name / address --- + // Prefer DNS name if set; otherwise fall back to IP + final String name = vo.getName() != null ? vo.getName() : ("host-" + hostUuid); + h.setName(name); + + String addr = vo.getPrivateIpAddress(); + h.setAddress(addr); + + h.setStatus(mapStatus(vo)); + h.setExternalStatus("ok"); + + // --- cluster --- + final String clusterUuid = vo.getClusterUuid(); + h.setCluster(Ref.of(basePath + ClustersRouteHandler.BASE_ROUTE + "/" + clusterUuid, clusterUuid)); + + // --- CPU --- + final Cpu cpu = new Cpu(); + + + final Topology topo = new Topology(); + // oVirt topology: sockets/cores/threads. We approximate. + // If CloudStack has cpuNumber = total cores, treat as sockets count w/ 1 core, 1 thread. + topo.sockets = vo.getCpuSockets(); + topo.cores = vo.getCpus(); + topo.threads = 1; + + // --- Memory --- + h.setMemory(String.valueOf(vo.getTotalMemory())); + h.setMaxSchedulingMemory(String.valueOf(vo.getTotalMemory())); + + // --- OS / versions (optional placeholders) --- + // If you want, you can set conservative defaults to match oVirt shape. + h.setType("rhel"); + h.setAutoNumaStatus("unknown"); + h.setKdumpStatus("disabled"); + h.setNumaSupported("false"); + h.setReinstallationRequired("false"); + h.setUpdateAvailable("false"); + + // --- links/actions --- + // Start minimal (empty). Add actions only if Veeam tries to follow them. + h.setActions(null); + h.setLink(Collections.emptyList()); + + return h; + } + + public static List toHostList(final List vos) { + return vos.stream().map(HostJoinVOToHostConverter::toHost).collect(Collectors.toList()); + } + + private static String mapStatus(final HostJoinVO vo) { + // CloudStack examples: + // state: Up/Down/Maintenance/Error/Disconnected + // status: Up/Down/Connecting/etc + if (vo.isInMaintenanceStates()) return "maintenance"; + if (Status.Up.equals(vo.getStatus()) && ResourceState.Enabled.equals(vo.getResourceState())) return "up"; + + // Default + return "down"; + } +} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/NetworkVOToNetworkConverter.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/NetworkVOToNetworkConverter.java new file mode 100644 index 00000000000..85775b3d6cf --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/NetworkVOToNetworkConverter.java @@ -0,0 +1,80 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.converter; + +import java.util.Collections; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.apache.cloudstack.veeam.VeeamControlService; +import org.apache.cloudstack.veeam.api.DataCentersRouteHandler; +import org.apache.cloudstack.veeam.api.NetworksRouteHandler; +import org.apache.cloudstack.veeam.api.dto.Network; +import org.apache.cloudstack.veeam.api.dto.NetworkUsages; +import org.apache.cloudstack.veeam.api.dto.Ref; + +import com.cloud.api.query.vo.DataCenterJoinVO; +import com.cloud.network.dao.NetworkVO; + +public class NetworkVOToNetworkConverter { + public static Network toNetwork(final NetworkVO vo, final Function dcResolver) { + final Network dto = new Network(); + + final String networkUuid = vo.getUuid(); + dto.setId(networkUuid); + final String basePath = VeeamControlService.ContextPath.value(); + dto.setHref(basePath + NetworksRouteHandler.BASE_ROUTE + "/" + networkUuid); + + String name = vo.getName() != null ? vo.getName() : vo.getTrafficType().name() + "-" + networkUuid; + dto.setName(name); + dto.setDescription(vo.getDisplayText()); + dto.setComment(""); + + dto.setMtu(String.valueOf(vo.getPrivateMtu() != null ? vo.getPrivateMtu() : 0)); + dto.setPortIsolation("false"); + dto.setStp("false"); + + dto.setUsages(new NetworkUsages(List.of("vm"))); + + // Best-effort mapping for vdsm_name + dto.setVdsmName(dto.getName()); + + // zone -> oVirt datacenter ref + if (dcResolver != null) { + final DataCenterJoinVO dc = dcResolver.apply(vo.getDataCenterId()); + if (dc != null) { + final String dcUuid = dc.getUuid(); + if (dcUuid != null && !dcUuid.isEmpty()) { + dto.setDataCenter(Ref.of(basePath + DataCentersRouteHandler.BASE_ROUTE + "/" + dcUuid, dcUuid)); + } + } + } + + dto.setLink(Collections.emptyList()); + + return dto; + } + + public static List toNetworkList(final List vos, + final Function dcResolver) { + return vos.stream() + .map(vo -> toNetwork(vo, dcResolver)) + .collect(Collectors.toList()); + } +} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/NetworkVOToVnicProfileConverter.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/NetworkVOToVnicProfileConverter.java new file mode 100644 index 00000000000..1dfbb811dc6 --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/NetworkVOToVnicProfileConverter.java @@ -0,0 +1,65 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.converter; + +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.apache.cloudstack.veeam.VeeamControlService; +import org.apache.cloudstack.veeam.api.DataCentersRouteHandler; +import org.apache.cloudstack.veeam.api.NetworksRouteHandler; +import org.apache.cloudstack.veeam.api.dto.Ref; +import org.apache.cloudstack.veeam.api.dto.VnicProfile; + +import com.cloud.api.query.vo.DataCenterJoinVO; +import com.cloud.network.dao.NetworkVO; + +public class NetworkVOToVnicProfileConverter { + public static VnicProfile toVnicProfile(final NetworkVO vo, final Function dcResolver) { + final VnicProfile vnicProfile = new VnicProfile(); + + final String networkUuid = vo.getUuid(); + vnicProfile.setId(networkUuid); + final String basePath = VeeamControlService.ContextPath.value(); + vnicProfile.setHref(basePath + NetworksRouteHandler.BASE_ROUTE + "/" + networkUuid); + vnicProfile.setId(networkUuid); + String name = vo.getName() != null ? vo.getName() : vo.getTrafficType().name() + "-" + networkUuid; + vnicProfile.setName(name); + vnicProfile.setNetwork(Ref.of(basePath + NetworksRouteHandler.BASE_ROUTE + "/" + networkUuid, networkUuid)); + vnicProfile.setDescription(vo.getDisplayText()); + + // zone -> oVirt datacenter ref + if (dcResolver != null) { + final DataCenterJoinVO dc = dcResolver.apply(vo.getDataCenterId()); + if (dc != null) { + final String dcUuid = dc.getUuid(); + if (dcUuid != null && !dcUuid.isEmpty()) { + vnicProfile.setDataCenter(Ref.of(basePath + DataCentersRouteHandler.BASE_ROUTE + "/" + dcUuid, dcUuid)); + } + } + } + return vnicProfile; + } + + public static List toVnicProfileList(final List vos, final Function dcResolver) { + return vos.stream() + .map(vo -> toVnicProfile(vo, dcResolver)) + .collect(Collectors.toList()); + } +} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Api.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Api.java index 2571f32111f..7282cc6469b 100644 --- a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Api.java +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Api.java @@ -46,7 +46,7 @@ public final class Api { public SpecialObjects specialObjects; @JacksonXmlProperty(localName = "summary") - public Summary summary; + public ApiSummary summary; // Keep as String to avoid timezone/date parsing friction; you control formatting. @JacksonXmlProperty(localName = "time") diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Summary.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/ApiSummary.java similarity index 95% rename from plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Summary.java rename to plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/ApiSummary.java index 992590f5f97..ba0618f6a9d 100644 --- a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Summary.java +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/ApiSummary.java @@ -21,7 +21,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; @JsonInclude(JsonInclude.Include.NON_NULL) -public final class Summary { +public final class ApiSummary { @JacksonXmlProperty(localName = "hosts") public SummaryCount hosts; @@ -35,5 +35,5 @@ public final class Summary { @JacksonXmlProperty(localName = "vms") public SummaryCount vms; - public Summary() {} + public ApiSummary() {} } diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Certificate.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Certificate.java new file mode 100644 index 00000000000..c95cab88de3 --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Certificate.java @@ -0,0 +1,36 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Certificate { + @JsonProperty("organization") + private String organization; + + @JsonProperty("subject") + private String subject; + + public String getOrganization() { return organization; } + public void setOrganization(String organization) { this.organization = organization; } + public String getSubject() { return subject; } + public void setSubject(String subject) { this.subject = subject; } +} + diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Cpu.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Cpu.java index bc3859d8998..79c6504a926 100644 --- a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Cpu.java +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Cpu.java @@ -18,9 +18,15 @@ package org.apache.cloudstack.veeam.api.dto; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; @JsonInclude(JsonInclude.Include.NON_NULL) public final class Cpu { + @JsonProperty("name") + private String name; + + @JsonProperty("speed") + private Integer speed; public String architecture; public Topology topology; @@ -30,4 +36,9 @@ public final class Cpu { this.architecture = architecture; this.topology = topology; } + + public String getName() { return name; } + public void setName(String name) { this.name = name; } + public Integer getSpeed() { return speed; } + public void setSpeed(Integer speed) { this.speed = speed; } } diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/HardwareInformation.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/HardwareInformation.java new file mode 100644 index 00000000000..83fb6d8469d --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/HardwareInformation.java @@ -0,0 +1,51 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class HardwareInformation { + @JsonProperty("manufacturer") + private String manufacturer; + + @JsonProperty("product_name") + private String productName; + + @JsonProperty("serial_number") + private String serialNumber; + + @JsonProperty("uuid") + private String uuid; + + @JsonProperty("version") + private String version; + + public String getManufacturer() { return manufacturer; } + public void setManufacturer(String manufacturer) { this.manufacturer = manufacturer; } + public String getProductName() { return productName; } + public void setProductName(String productName) { this.productName = productName; } + public String getSerialNumber() { return serialNumber; } + public void setSerialNumber(String serialNumber) { this.serialNumber = serialNumber; } + public String getUuid() { return uuid; } + public void setUuid(String uuid) { this.uuid = uuid; } + public String getVersion() { return version; } + public void setVersion(String version) { this.version = version; } +} + diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Host.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Host.java new file mode 100644 index 00000000000..5a696d0152d --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Host.java @@ -0,0 +1,169 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Host { + + @JsonProperty("address") + private String address; + + @JsonProperty("auto_numa_status") + private String autoNumaStatus; + + @JsonProperty("certificate") + private Certificate certificate; + + @JsonProperty("cpu") + private Cpu cpu; + + @JsonProperty("external_status") + private String externalStatus; + + @JsonProperty("hardware_information") + private HardwareInformation hardwareInformation; + + @JsonProperty("kdump_status") + private String kdumpStatus; + + @JsonProperty("libvirt_version") + private Version libvirtVersion; + + @JsonProperty("max_scheduling_memory") + private String maxSchedulingMemory; + + @JsonProperty("memory") + private String memory; + + @JsonProperty("numa_supported") + private String numaSupported; + + @JsonProperty("os") + private Os os; + + @JsonProperty("port") + private String port; + + @JsonProperty("protocol") + private String protocol; + + @JsonProperty("reinstallation_required") + private String reinstallationRequired; + + @JsonProperty("status") + private String status; + + @JsonProperty("summary") + private ApiSummary summary; + + @JsonProperty("type") + private String type; + + @JsonProperty("update_available") + private String updateAvailable; + + @JsonProperty("version") + private Version version; + + @JsonProperty("vgpu_placement") + private String vgpuPlacement; + + @JsonProperty("cluster") + private Ref cluster; + + @JsonProperty("actions") + private Actions actions; + + @JsonProperty("name") + private String name; + + @JsonProperty("comment") + private String comment; + + @JsonProperty("link") + private List link; + + @JsonProperty("href") + private String href; + + @JsonProperty("id") + private String id; + + // getters/setters (generate via IDE) + public String getAddress() { return address; } + public void setAddress(String address) { this.address = address; } + public String getAutoNumaStatus() { return autoNumaStatus; } + public void setAutoNumaStatus(String autoNumaStatus) { this.autoNumaStatus = autoNumaStatus; } + public Certificate getCertificate() { return certificate; } + public void setCertificate(Certificate certificate) { this.certificate = certificate; } + public Cpu getCpu() { return cpu; } + public void setCpu(Cpu cpu) { this.cpu = cpu; } + public String getExternalStatus() { return externalStatus; } + public void setExternalStatus(String externalStatus) { this.externalStatus = externalStatus; } + public HardwareInformation getHardwareInformation() { return hardwareInformation; } + public void setHardwareInformation(HardwareInformation hardwareInformation) { this.hardwareInformation = hardwareInformation; } + public String getKdumpStatus() { return kdumpStatus; } + public void setKdumpStatus(String kdumpStatus) { this.kdumpStatus = kdumpStatus; } + public Version getLibvirtVersion() { return libvirtVersion; } + public void setLibvirtVersion(Version libvirtVersion) { this.libvirtVersion = libvirtVersion; } + public String getMaxSchedulingMemory() { return maxSchedulingMemory; } + public void setMaxSchedulingMemory(String maxSchedulingMemory) { this.maxSchedulingMemory = maxSchedulingMemory; } + public String getMemory() { return memory; } + public void setMemory(String memory) { this.memory = memory; } + public String getNumaSupported() { return numaSupported; } + public void setNumaSupported(String numaSupported) { this.numaSupported = numaSupported; } + public Os getOs() { return os; } + public void setOs(Os os) { this.os = os; } + public String getPort() { return port; } + public void setPort(String port) { this.port = port; } + public String getProtocol() { return protocol; } + public void setProtocol(String protocol) { this.protocol = protocol; } + public String getReinstallationRequired() { return reinstallationRequired; } + public void setReinstallationRequired(String reinstallationRequired) { this.reinstallationRequired = reinstallationRequired; } + public String getStatus() { return status; } + public void setStatus(String status) { this.status = status; } + public ApiSummary getSummary() { return summary; } + public void setSummary(ApiSummary summary) { this.summary = summary; } + public String getType() { return type; } + public void setType(String type) { this.type = type; } + public String getUpdateAvailable() { return updateAvailable; } + public void setUpdateAvailable(String updateAvailable) { this.updateAvailable = updateAvailable; } + public Version getVersion() { return version; } + public void setVersion(Version version) { this.version = version; } + public String getVgpuPlacement() { return vgpuPlacement; } + public void setVgpuPlacement(String vgpuPlacement) { this.vgpuPlacement = vgpuPlacement; } + public Ref getCluster() { return cluster; } + public void setCluster(Ref cluster) { this.cluster = cluster; } + public Actions getActions() { return actions; } + public void setActions(Actions actions) { this.actions = actions; } + public String getName() { return name; } + public void setName(String name) { this.name = name; } + public String getComment() { return comment; } + public void setComment(String comment) { this.comment = comment; } + public List getLink() { return link; } + public void setLink(List link) { this.link = link; } + public String getHref() { return href; } + public void setHref(String href) { this.href = href; } + public String getId() { return id; } + public void setId(String id) { this.id = id; } +} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/HostSummary.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/HostSummary.java new file mode 100644 index 00000000000..ada443f2788 --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/HostSummary.java @@ -0,0 +1,40 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class HostSummary { + @JsonProperty("active") + private String active; + + @JsonProperty("migrating") + private String migrating; + + @JsonProperty("total") + private String total; + + public String getActive() { return active; } + public void setActive(String active) { this.active = active; } + public String getMigrating() { return migrating; } + public void setMigrating(String migrating) { this.migrating = migrating; } + public String getTotal() { return total; } + public void setTotal(String total) { this.total = total; } +} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Hosts.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Hosts.java new file mode 100644 index 00000000000..17b3f77de3e --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Hosts.java @@ -0,0 +1,33 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.dto; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Hosts { + @JsonProperty("host") + private List host; + + public Hosts() {} + public Hosts(List host) { this.host = host; } + + public List getHost() { return host; } + public void setHost(List host) { this.host = host; } +} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Network.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Network.java new file mode 100644 index 00000000000..5c259cc8209 --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Network.java @@ -0,0 +1,85 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.dto; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Network { + private String mtu; // oVirt prints as string + private String portIsolation; // "false" + private String stp; // "false" + private NetworkUsages usages; // { usage: ["vm"] } + private String vdsmName; + + private Ref dataCenter; + + private String name; + private String description; + private String comment; + + @JsonProperty("link") + private List link; + + private String href; + private String id; + + public Network() {} + + // ---- getters / setters ---- + + public String getMtu() { return mtu; } + public void setMtu(final String mtu) { this.mtu = mtu; } + + public String getPortIsolation() { return portIsolation; } + public void setPortIsolation(final String portIsolation) { this.portIsolation = portIsolation; } + + public String getStp() { return stp; } + public void setStp(final String stp) { this.stp = stp; } + + public NetworkUsages getUsages() { return usages; } + public void setUsages(final NetworkUsages usages) { this.usages = usages; } + + public String getVdsmName() { return vdsmName; } + public void setVdsmName(final String vdsmName) { this.vdsmName = vdsmName; } + + public Ref getDataCenter() { return dataCenter; } + public void setDataCenter(final Ref dataCenter) { this.dataCenter = dataCenter; } + + public String getName() { return name; } + public void setName(final String name) { this.name = name; } + + public String getDescription() { return description; } + public void setDescription(final String description) { this.description = description; } + + public String getComment() { return comment; } + public void setComment(final String comment) { this.comment = comment; } + + public List getLink() { return link; } + public void setLink(final List link) { this.link = link; } + + public String getHref() { return href; } + public void setHref(final String href) { this.href = href; } + + public String getId() { return id; } + public void setId(final String id) { this.id = id; } +} + diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/NetworkUsages.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/NetworkUsages.java new file mode 100644 index 00000000000..da5e1c2aeec --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/NetworkUsages.java @@ -0,0 +1,42 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.dto; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NetworkUsages { + private List usage; + + public NetworkUsages() { + } + + public NetworkUsages(final List usage) { + this.usage = usage; + } + + public List getUsage() { + return usage; + } + + public void setUsage(final List usage) { + this.usage = usage; + } +} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Networks.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Networks.java new file mode 100644 index 00000000000..9b96b6e8c2d --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Networks.java @@ -0,0 +1,33 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.dto; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Networks { + @JsonProperty("network") + private List network; + + public Networks() {} + public Networks(List network) { this.network = network; } + + public List getNetwork() { return network; } + public void setNetwork(List network) { this.network = network; } +} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/OsVersion.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/OsVersion.java new file mode 100644 index 00000000000..47247f91af5 --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/OsVersion.java @@ -0,0 +1,41 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.dto; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class OsVersion { + @JsonProperty("full_version") + private String fullVersion; + + @JsonProperty("major") + private String major; + + @JsonProperty("minor") + private String minor; + + public String getFullVersion() { return fullVersion; } + public void setFullVersion(String fullVersion) { this.fullVersion = fullVersion; } + public String getMajor() { return major; } + public void setMajor(String major) { this.major = major; } + public String getMinor() { return minor; } + public void setMinor(String minor) { this.minor = minor; } +} + diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/VnicProfile.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/VnicProfile.java new file mode 100644 index 00000000000..a550b41090b --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/VnicProfile.java @@ -0,0 +1,99 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.dto; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; + +/** + * oVirt-like vNIC profile element. + * Every vNIC profile MUST reference exactly one network. + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class VnicProfile { + + private String href; + private String id; + private String name; + private String description; + + private Ref network; + private Ref dataCenter; + + private List link; + + public VnicProfile() { + } + + public String getHref() { + return href; + } + + public void setHref(final String href) { + this.href = href; + } + + public String getId() { + return id; + } + + public void setId(final String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(final String description) { + this.description = description; + } + + public Ref getNetwork() { + return network; + } + + public void setNetwork(final Ref network) { + this.network = network; + } + + public Ref getDataCenter() { + return dataCenter; + } + + public void setDataCenter(final Ref dataCenter) { + this.dataCenter = dataCenter; + } + + public List getLink() { + return link; + } + + public void setLink(final List link) { + this.link = link; + } +} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/VnicProfiles.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/VnicProfiles.java new file mode 100644 index 00000000000..d528e946bf6 --- /dev/null +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/VnicProfiles.java @@ -0,0 +1,49 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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.apache.cloudstack.veeam.api.dto; + + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Root container for /ovirt-engine/api/vnicprofiles + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class VnicProfiles { + + @JsonProperty("vnic_profile") + private List vnicProfile; + + public VnicProfiles() { + } + + public VnicProfiles(final List vnicProfile) { + this.vnicProfile = vnicProfile; + } + + public List getVnicProfile() { + return vnicProfile; + } + + public void setVnicProfile(final List vnicProfile) { + this.vnicProfile = vnicProfile; + } +} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/filter/BearerOrBasicAuthFilter.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/filter/BearerOrBasicAuthFilter.java index 5a83299207d..4e32ef577f3 100644 --- a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/filter/BearerOrBasicAuthFilter.java +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/filter/BearerOrBasicAuthFilter.java @@ -41,7 +41,7 @@ public class BearerOrBasicAuthFilter implements Filter { // Keep these aligned with SsoService (move to ConfigKeys later) public static final List REQUIRED_SCOPES = List.of("ovirt-app-admin", "ovirt-app-portal"); public static final String ISSUER = "veeam-control"; - private static final String HMAC_SECRET = "change-this-super-secret-key-change-this"; + public static final String HMAC_SECRET = "change-this-super-secret-key-change-this"; @Override public void init(FilterConfig filterConfig) {} @Override public void destroy() {} diff --git a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/sso/SsoService.java b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/sso/SsoService.java index fcd984ffce0..c8066823999 100644 --- a/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/sso/SsoService.java +++ b/plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/sso/SsoService.java @@ -37,7 +37,6 @@ import com.cloud.utils.component.ManagerBase; public class SsoService extends ManagerBase implements RouteHandler { private static final String BASE_ROUTE = "/sso"; - private static final String HMAC_SECRET = "change-this-super-secret-key-change-this"; // >= 32 chars recommended private static final long DEFAULT_TTL_SECONDS = 3600; // Replace with your real credential validation (CloudStack account, config, etc.) @@ -104,7 +103,8 @@ public class SsoService extends ManagerBase implements RouteHandler { final long ttl = DEFAULT_TTL_SECONDS; final String token; try { - token = JwtUtil.issueHs256Jwt(BearerOrBasicAuthFilter.ISSUER, username, effectiveScope, ttl, HMAC_SECRET); + token = JwtUtil.issueHs256Jwt(BearerOrBasicAuthFilter.ISSUER, username, effectiveScope, ttl, + BearerOrBasicAuthFilter.HMAC_SECRET); } catch (Exception e) { io.getWriter().write(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, Map.of("error", "server_error", "error_description", "Failed to issue token"), outFormat); diff --git a/plugins/integrations/veeam-control-service/src/main/resources/META-INF/cloudstack/veeam-control-service/spring-veeam-control-service-context.xml b/plugins/integrations/veeam-control-service/src/main/resources/META-INF/cloudstack/veeam-control-service/spring-veeam-control-service-context.xml index 1ed843cbb46..e56009aacd4 100644 --- a/plugins/integrations/veeam-control-service/src/main/resources/META-INF/cloudstack/veeam-control-service/spring-veeam-control-service-context.xml +++ b/plugins/integrations/veeam-control-service/src/main/resources/META-INF/cloudstack/veeam-control-service/spring-veeam-control-service-context.xml @@ -32,9 +32,12 @@ - + + + +