Use Kubernetes format everywhere for consistency.
This commit is contained in:
parent
7141d381be
commit
8461adbe7c
6 changed files with 13 additions and 13 deletions
|
|
@ -62,7 +62,7 @@ spec:
|
|||
anyOf:
|
||||
- type: integer
|
||||
- type: string
|
||||
pattern: ^\s*(\d+(\.\d+)?)\s*(B|kB|MB|GB|TB|PB|EB|KiB|MiB|GiB|TiB|PiB|EiB|Ki|Mi|Gi|Ti|Pi|Ei)?$
|
||||
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
|
||||
x-kubernetes-int-or-string: true
|
||||
description: >-
|
||||
Limits describes the maximum amount of compute
|
||||
|
|
@ -73,7 +73,7 @@ spec:
|
|||
anyOf:
|
||||
- type: integer
|
||||
- type: string
|
||||
pattern: ^\s*(\d+(\.\d+)?)\s*(B|kB|MB|GB|TB|PB|EB|KiB|MiB|GiB|TiB|PiB|EiB|Ki|Mi|Gi|Ti|Pi|Ei)?$
|
||||
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
|
||||
x-kubernetes-int-or-string: true
|
||||
description: >-
|
||||
Requests describes the minimum amount of compute
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ spec:
|
|||
vm:
|
||||
# state: Running
|
||||
bootMenu: yes
|
||||
maximumRam: "8 GiB"
|
||||
currentRam: "4 GiB"
|
||||
maximumRam: 8Gi
|
||||
currentRam: 4Gi
|
||||
maximumCpus: 4
|
||||
currentCpus: 4
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ spec:
|
|||
vm:
|
||||
maximumCpus: 4
|
||||
currentCpus: 2
|
||||
maximumRam: "8 GiB"
|
||||
currentRam: "4 GiB"
|
||||
maximumRam: 8Gi
|
||||
currentRam: 4Gi
|
||||
|
||||
networks:
|
||||
- user: {}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ spec:
|
|||
vm:
|
||||
maximumCpus: 4
|
||||
currentCpus: 2
|
||||
maximumRam: "8 GiB"
|
||||
currentRam: "4 GiB"
|
||||
maximumRam: 8Gi
|
||||
currentRam: 4Gi
|
||||
|
||||
networks:
|
||||
- user: {}
|
||||
|
|
|
|||
|
|
@ -99,14 +99,14 @@ spec:
|
|||
<#if reconciler.cpuOvercommit??>
|
||||
<#assign factor = reconciler.cpuOvercommit * 1.0 />
|
||||
</#if>
|
||||
cpu: ${ (cr.spec.vm.currentCpus.asInt / factor)?floor?c }
|
||||
cpu: ${ (parseQuantity(cr.spec.vm.currentCpus.asString) / factor)?floor?c }
|
||||
</#if>
|
||||
<#if cr.spec.vm.currentRam?? >
|
||||
<#assign factor = 1.25 />
|
||||
<#if reconciler.ramOvercommit??>
|
||||
<#assign factor = reconciler.ramOvercommit * 1.0 />
|
||||
</#if>
|
||||
memory: ${ (parseMemory(cr.spec.vm.currentRam.asString) / factor)?floor?c }
|
||||
memory: ${ (parseQuantity(cr.spec.vm.currentRam.asString) / factor)?floor?c }
|
||||
</#if>
|
||||
</#if>
|
||||
</#if>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import freemarker.template.TemplateHashModel;
|
|||
import freemarker.template.TemplateMethodModelEx;
|
||||
import freemarker.template.TemplateModelException;
|
||||
import freemarker.template.TemplateNotFoundException;
|
||||
import io.kubernetes.client.custom.Quantity;
|
||||
import io.kubernetes.client.openapi.ApiException;
|
||||
import io.kubernetes.client.util.generic.dynamic.DynamicKubernetesApi;
|
||||
import java.io.IOException;
|
||||
|
|
@ -42,7 +43,6 @@ import java.util.Optional;
|
|||
import static org.jdrupes.vmoperator.manager.Constants.VM_OP_GROUP;
|
||||
import org.jdrupes.vmoperator.manager.VmDefChanged.Type;
|
||||
import org.jdrupes.vmoperator.util.ExtendedObjectWrapper;
|
||||
import org.jdrupes.vmoperator.util.ParseUtils;
|
||||
import org.jgrapes.core.Channel;
|
||||
import org.jgrapes.core.Component;
|
||||
import org.jgrapes.core.annotation.Handler;
|
||||
|
|
@ -219,7 +219,7 @@ public class Reconciler extends Component {
|
|||
model.put("reconciler", config);
|
||||
|
||||
// Methods
|
||||
model.put("parseMemory", new TemplateMethodModelEx() {
|
||||
model.put("parseQuantity", new TemplateMethodModelEx() {
|
||||
@Override
|
||||
@SuppressWarnings("PMD.PreserveStackTrace")
|
||||
public Object exec(@SuppressWarnings("rawtypes") List arguments)
|
||||
|
|
@ -229,7 +229,7 @@ public class Reconciler extends Component {
|
|||
return number;
|
||||
}
|
||||
try {
|
||||
return ParseUtils.parseMemory(arg.toString());
|
||||
return Quantity.fromString(arg.toString()).getNumber();
|
||||
} catch (NumberFormatException e) {
|
||||
throw new TemplateModelException("Cannot parse memory "
|
||||
+ "specified as \"" + arg + "\": " + e.getMessage());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue