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:
|
anyOf:
|
||||||
- type: integer
|
- type: integer
|
||||||
- type: string
|
- 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
|
x-kubernetes-int-or-string: true
|
||||||
description: >-
|
description: >-
|
||||||
Limits describes the maximum amount of compute
|
Limits describes the maximum amount of compute
|
||||||
|
|
@ -73,7 +73,7 @@ spec:
|
||||||
anyOf:
|
anyOf:
|
||||||
- type: integer
|
- type: integer
|
||||||
- type: string
|
- 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
|
x-kubernetes-int-or-string: true
|
||||||
description: >-
|
description: >-
|
||||||
Requests describes the minimum amount of compute
|
Requests describes the minimum amount of compute
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ spec:
|
||||||
vm:
|
vm:
|
||||||
# state: Running
|
# state: Running
|
||||||
bootMenu: yes
|
bootMenu: yes
|
||||||
maximumRam: "8 GiB"
|
maximumRam: 8Gi
|
||||||
currentRam: "4 GiB"
|
currentRam: 4Gi
|
||||||
maximumCpus: 4
|
maximumCpus: 4
|
||||||
currentCpus: 4
|
currentCpus: 4
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ spec:
|
||||||
vm:
|
vm:
|
||||||
maximumCpus: 4
|
maximumCpus: 4
|
||||||
currentCpus: 2
|
currentCpus: 2
|
||||||
maximumRam: "8 GiB"
|
maximumRam: 8Gi
|
||||||
currentRam: "4 GiB"
|
currentRam: 4Gi
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
- user: {}
|
- user: {}
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ spec:
|
||||||
vm:
|
vm:
|
||||||
maximumCpus: 4
|
maximumCpus: 4
|
||||||
currentCpus: 2
|
currentCpus: 2
|
||||||
maximumRam: "8 GiB"
|
maximumRam: 8Gi
|
||||||
currentRam: "4 GiB"
|
currentRam: 4Gi
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
- user: {}
|
- user: {}
|
||||||
|
|
|
||||||
|
|
@ -99,14 +99,14 @@ spec:
|
||||||
<#if reconciler.cpuOvercommit??>
|
<#if reconciler.cpuOvercommit??>
|
||||||
<#assign factor = reconciler.cpuOvercommit * 1.0 />
|
<#assign factor = reconciler.cpuOvercommit * 1.0 />
|
||||||
</#if>
|
</#if>
|
||||||
cpu: ${ (cr.spec.vm.currentCpus.asInt / factor)?floor?c }
|
cpu: ${ (parseQuantity(cr.spec.vm.currentCpus.asString) / factor)?floor?c }
|
||||||
</#if>
|
</#if>
|
||||||
<#if cr.spec.vm.currentRam?? >
|
<#if cr.spec.vm.currentRam?? >
|
||||||
<#assign factor = 1.25 />
|
<#assign factor = 1.25 />
|
||||||
<#if reconciler.ramOvercommit??>
|
<#if reconciler.ramOvercommit??>
|
||||||
<#assign factor = reconciler.ramOvercommit * 1.0 />
|
<#assign factor = reconciler.ramOvercommit * 1.0 />
|
||||||
</#if>
|
</#if>
|
||||||
memory: ${ (parseMemory(cr.spec.vm.currentRam.asString) / factor)?floor?c }
|
memory: ${ (parseQuantity(cr.spec.vm.currentRam.asString) / factor)?floor?c }
|
||||||
</#if>
|
</#if>
|
||||||
</#if>
|
</#if>
|
||||||
</#if>
|
</#if>
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import freemarker.template.TemplateHashModel;
|
||||||
import freemarker.template.TemplateMethodModelEx;
|
import freemarker.template.TemplateMethodModelEx;
|
||||||
import freemarker.template.TemplateModelException;
|
import freemarker.template.TemplateModelException;
|
||||||
import freemarker.template.TemplateNotFoundException;
|
import freemarker.template.TemplateNotFoundException;
|
||||||
|
import io.kubernetes.client.custom.Quantity;
|
||||||
import io.kubernetes.client.openapi.ApiException;
|
import io.kubernetes.client.openapi.ApiException;
|
||||||
import io.kubernetes.client.util.generic.dynamic.DynamicKubernetesApi;
|
import io.kubernetes.client.util.generic.dynamic.DynamicKubernetesApi;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
@ -42,7 +43,6 @@ import java.util.Optional;
|
||||||
import static org.jdrupes.vmoperator.manager.Constants.VM_OP_GROUP;
|
import static org.jdrupes.vmoperator.manager.Constants.VM_OP_GROUP;
|
||||||
import org.jdrupes.vmoperator.manager.VmDefChanged.Type;
|
import org.jdrupes.vmoperator.manager.VmDefChanged.Type;
|
||||||
import org.jdrupes.vmoperator.util.ExtendedObjectWrapper;
|
import org.jdrupes.vmoperator.util.ExtendedObjectWrapper;
|
||||||
import org.jdrupes.vmoperator.util.ParseUtils;
|
|
||||||
import org.jgrapes.core.Channel;
|
import org.jgrapes.core.Channel;
|
||||||
import org.jgrapes.core.Component;
|
import org.jgrapes.core.Component;
|
||||||
import org.jgrapes.core.annotation.Handler;
|
import org.jgrapes.core.annotation.Handler;
|
||||||
|
|
@ -219,7 +219,7 @@ public class Reconciler extends Component {
|
||||||
model.put("reconciler", config);
|
model.put("reconciler", config);
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
model.put("parseMemory", new TemplateMethodModelEx() {
|
model.put("parseQuantity", new TemplateMethodModelEx() {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("PMD.PreserveStackTrace")
|
@SuppressWarnings("PMD.PreserveStackTrace")
|
||||||
public Object exec(@SuppressWarnings("rawtypes") List arguments)
|
public Object exec(@SuppressWarnings("rawtypes") List arguments)
|
||||||
|
|
@ -229,7 +229,7 @@ public class Reconciler extends Component {
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return ParseUtils.parseMemory(arg.toString());
|
return Quantity.fromString(arg.toString()).getNumber();
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new TemplateModelException("Cannot parse memory "
|
throw new TemplateModelException("Cannot parse memory "
|
||||||
+ "specified as \"" + arg + "\": " + e.getMessage());
|
+ "specified as \"" + arg + "\": " + e.getMessage());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue