Register solution-revisions with license manager 59/5359/3
authorAndrew Gauld <agauld@att.com>
Wed, 25 Sep 2019 18:49:40 +0000 (18:49 +0000)
committerAndrew Gauld <agauld@att.com>
Thu, 26 Sep 2019 18:19:52 +0000 (18:19 +0000)
Change-Id: I6d44cebc5677e449a357f8978f0e4e95d68b2a9c
Issue-ID: ACUMOS-3484
Signed-off-by: Andrew Gauld <agauld@att.com>
acumos-fgw-client/pom.xml
docs/config.rst
docs/release-notes.rst
gateway/pom.xml
gateway/src/main/java/org/acumos/federation/gateway/Application.java
gateway/src/main/java/org/acumos/federation/gateway/Clients.java
gateway/src/main/java/org/acumos/federation/gateway/SubscriptionPoller.java

index d4fb7c5..ba7d053 100644 (file)
@@ -27,7 +27,7 @@ limitations under the License.
        </parent>
        <groupId>org.acumos.federation</groupId>
        <artifactId>acumos-fgw-client</artifactId>
-       <version>3.0.0-SNAPSHOT</version>
+       <version>3.0.1-SNAPSHOT</version>
        <name>Federation Gateway Client</name>
        <properties>
                <!-- dependency versions -->
index c565778..ac1a863 100644 (file)
@@ -62,6 +62,7 @@ Example (with syntactically valid but completely made up values)::
       "password": "nexuspass",
       "nexus.group-id": "myorg"
     },
+    "license-manager.url": "http://licenseserver:8888",
     "verification.url": "http://securityserver:9999"
   }'
 
@@ -262,6 +263,11 @@ docker.registry-email
   The email address associated with the username and password for
   authenticating to the Docker Registry.
 
+license-manager.url
+  Required.
+
+  The URL for the license manager used to register solution revisions.
+
 nexus.url
   Required.
 
index 9deb528..87937e7 100644 (file)
@@ -23,6 +23,12 @@ Federation Gateway Release Notes
 This server is available as a Docker image in a Docker registry at the Linux Foundation.
 The image name is "federation-gateway" and the tag is a version string as shown below.
 
+Version 3.0.1, 2019-09-26
+-------------------------
+* When a model has been federated, register it with the license manager (`ACUMOS-3484 <https://jira.acumos.org/browse/ACUMOS-3484>`_)
+  * This adds a new required configuration value, "license-manager.url" for the
+    license management service.
+
 Version 3.0.0, 2019-09-13
 -------------------------
 * Upgrade server to Java 11.  Compile client for Java 8 (`ACUMOS-3334 <https://jira.acumos.org/browse/ACUMOS-3334>`_)
index 4ee1d1a..10fe5e9 100644 (file)
@@ -27,7 +27,7 @@
        </parent>
        <groupId>org.acumos.federation</groupId>
        <artifactId>gateway</artifactId>
-       <version>3.0.0-SNAPSHOT</version>
+       <version>3.0.1-SNAPSHOT</version>
        <name>Federation Gateway</name>
        <description>Federated Acumos Interface for inter-acumos communication</description>
        <properties>
                        <artifactId>security-verification-client</artifactId>
                        <version>0.0.24</version>
                </dependency>
+               <dependency>
+                       <groupId>org.acumos.license-manager</groupId>
+                       <artifactId>license-manager-client-library</artifactId>
+                       <version>1.0.0</version>
+               </dependency>
                <!-- Compile time only dependencies -->
                <dependency>
                        <groupId>org.projectlombok</groupId>
index 61d9499..dc63c41 100644 (file)
@@ -161,6 +161,12 @@ public class Application {
                return new ServiceConfig();
        }
 
+       @Bean
+       @ConfigurationProperties(prefix="license-manager")
+       ServiceConfig lmConfig() {
+               return new ServiceConfig();
+       }
+
        @Bean
        Clients clients() {
                return new Clients();
index aa0a6f6..a3a2b98 100644 (file)
@@ -34,6 +34,7 @@ import org.acumos.federation.client.FederationClient;
 
 import org.acumos.securityverification.service.ISecurityVerificationClientService;
 import org.acumos.securityverification.service.SecurityVerificationClientServiceImpl;
+import org.acumos.licensemanager.client.rtu.LicenseAsset;
 
 /**
  * Defines all beans used to access outside services.
@@ -72,9 +73,13 @@ public class Clients {
        @Autowired
        private ServiceConfig verificationConfig;
 
+       @Autowired
+       private ServiceConfig lmConfig;
+
        private ICommonDataServiceRestClient cdsClient;
        private NexusClient nexusClient;
        private ISecurityVerificationClientService svClient;
+       private LicenseAsset lmClient;
 
        public FederationClient getFederationClient(String url) {
                /*
@@ -140,10 +145,17 @@ public class Clients {
                            cdmsConfig.getUrl(),
                            cdmsConfig.getUsername(),
                            cdmsConfig.getPassword(),
-                           nexusConfig.getUrl(),
+                           nexusConfig.getUrl().replaceAll("/*$", "") + "/",
                            nexusConfig.getUsername(),
                            nexusConfig.getPassword());
                }
                return svClient;
        }
+
+       public synchronized LicenseAsset getLMClient() {
+               if (lmClient == null) {
+                       lmClient = new LicenseAsset(getCDSClient(), lmConfig.getUrl(), nexusConfig.getUrl().replaceAll("/*$", "") + "/");
+               }
+               return lmClient;
+       }
 }
index e7ed638..a79ccc2 100644 (file)
@@ -54,6 +54,9 @@ import org.acumos.cds.domain.MLPRevCatDescription;
 import org.acumos.cds.domain.MLPSolution;
 import org.acumos.cds.domain.MLPSolutionRevision;
 
+import org.acumos.licensemanager.client.model.RegisterAssetRequest;
+import org.acumos.licensemanager.client.model.RegisterAssetResponse;
+
 import org.acumos.federation.client.FederationClient;
 import org.acumos.federation.client.data.Solution;
 import org.acumos.federation.client.data.SolutionRevision;
@@ -398,7 +401,27 @@ public class SubscriptionPoller {
                                catalogService.updateRevision(pRev);
                        }
                        if (changed) {
-                               new Thread(() -> { try {clients.getSVClient().securityVerificationScan(solutionId, revisionId, "created", userId); } catch (Exception e) { log.error("SV scan failure on revision " + revisionId, e); }}).start();
+                               new Thread(() -> {
+                                       try {
+                                               clients.getSVClient().securityVerificationScan(solutionId, revisionId, "created", userId);
+                                       } catch (Exception e) {
+                                               log.error("SV scan failure on revision " + revisionId, e);
+                                       }
+                               }).start();
+                               new Thread(() -> {
+                                       try {
+                                               RegisterAssetRequest rar = new RegisterAssetRequest();
+                                               rar.setSolutionId(solutionId);
+                                               rar.setRevisionId(revisionId);
+                                               rar.setLoggedIdUser(userId);
+                                               RegisterAssetResponse rax = clients.getLMClient().register(rar).get();
+                                               if (!rax.isSuccess()) {
+                                                       log.error("License asset registration failure on revision " + revisionId + ": " + rax.getMessage());
+                                               }
+                                       } catch (Exception e) {
+                                               log.error("License asset registration failure on revision " + revisionId, e);
+                                       }
+                               }).start();
                        }
                        events.end(act);
                        return(changed);