BPGen externalize resources limit defaults config 39/118239/1
authorRemigiusz Janeczek <remigiusz.janeczek@nokia.com>
Tue, 23 Feb 2021 13:43:09 +0000 (14:43 +0100)
committerRemigiusz Janeczek <remigiusz.janeczek@nokia.com>
Tue, 23 Feb 2021 13:46:42 +0000 (14:46 +0100)
Issue-ID: DCAEGEN2-2636
Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com>
Change-Id: Id73b44a5b0286473ff4c2a05c7fa9586cac26c8a

mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/constants/Constants.java
mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/ResourceConfigService.java
mod/bpgenerator/onap/src/main/resources/bpgen.properties

index fbd0527..e08b28d 100644 (file)
@@ -4,8 +4,7 @@
  *  *  org.onap.dcae
  *  *  ================================================================================
  *  *  Copyright (c) 2020  AT&T Intellectual Property. All rights reserved.
- *  *  ================================================================================
- *  *  Modifications Copyright (c) 2021 Nokia
+ *  *  Copyright (c) 2021 Nokia. All rights reserved.
  *  *  ================================================================================
  *  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  *  you may not use this file except in compliance with the License.
@@ -51,8 +50,6 @@ public class Constants {
     public static final String EMPTY_VALUE = "";
     public static final String DCAE_NODES_CONTAINERIZED_SERVICE_COMPONENT_USING_DMAAP =
         "dcae.nodes.ContainerizedServiceComponentUsingDmaap";
-    public static final String MEMORY_LIMIT_128Mi = "128Mi";
-    public static final String CPU_LIMIT_250m = "250m";
     public static final String CPU_LIMIT = "cpu_limit";
     public static final String MEMORY_LIMIT = "memory_limit";
     public static final String CPU_REQUEST = "cpu_request";
index a3a9c97..ab33bfa 100644 (file)
@@ -4,6 +4,7 @@
  *  *  org.onap.dcae
  *  *  ================================================================================
  *  *  Copyright (c) 2020  AT&T Intellectual Property. All rights reserved.
+ *  *  Copyright (c) 2021 Nokia. All rights reserved.
  *  *  ================================================================================
  *  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  *  you may not use this file except in compliance with the License.
@@ -28,6 +29,7 @@ import org.onap.blueprintgenerator.model.common.GetInput;
 import org.onap.blueprintgenerator.model.common.ResourceConfig;
 import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
@@ -46,6 +48,12 @@ public class ResourceConfigService {
     @Autowired
     private BlueprintHelperService blueprintHelperService;
 
+    @Value("${resources.cpuLimit}")
+    private String defaultCpuLimit;
+
+    @Value("${resources.memoryLimit}")
+    private String defaultMemoryLimit;
+
     /**
      * Creates Resouce Config for properties
      *
@@ -59,10 +67,10 @@ public class ResourceConfigService {
         ResourceConfig resourceConfig = new ResourceConfig();
 
         LinkedHashMap<String, Object> memoryLimit =
-            blueprintHelperService.createStringInput(Constants.MEMORY_LIMIT_128Mi);
+            blueprintHelperService.createStringInput(defaultMemoryLimit);
 
         LinkedHashMap<String, Object> cpuLimit =
-            blueprintHelperService.createStringInput(Constants.CPU_LIMIT_250m);
+            blueprintHelperService.createStringInput(defaultCpuLimit);
 
         name = blueprintHelperService.getNamePrefix(name);
 
index e166452..5bc0ab0 100644 (file)
@@ -29,4 +29,5 @@ imports.dmaap.dmaapplugin=plugin:dmaap?version=1.5.0
 import.Postgres=plugin:pgaas?version=1.3.0
 import.Clamp=plugin:clamppolicyplugin?version=1.1.0
 
-
+resources.cpuLimit=${BP_RESOURCES_CPU_LIMIT:250m}
+resources.memoryLimit=${BP_RESOURCES_MEMORY_LIMIT:128Mi}