Search in sources :

Example 1 with ElementBuilderException

use of org.btrplace.btrpsl.template.ElementBuilderException in project scheduler by btrplace.

the class TemplateAssignment method addNode.

private void addNode(String tplName, String id, Map<String, String> opts) {
    try {
        Element el = namingServiceNodes.resolve(id);
        if (el == null) {
            Node n = mo.newNode();
            mo.getMapping().addOfflineNode(n);
            if (n == null) {
                ignoreError("No UUID to create node '" + id + "'");
            } else {
                namingServiceNodes.register(n, id);
                el = n;
            }
        }
        tpls.check(script, tplName, el, opts);
        if (!script.add(new BtrpElement(BtrpOperand.Type.NODE, id, el))) {
            ignoreError("Node '" + id + "' already created");
        }
    } catch (ElementBuilderException ex) {
        ignoreError(ex);
    }
}
Also used : ElementBuilderException(org.btrplace.btrpsl.template.ElementBuilderException) Element(org.btrplace.model.Element) BtrpElement(org.btrplace.btrpsl.element.BtrpElement) Node(org.btrplace.model.Node) BtrpElement(org.btrplace.btrpsl.element.BtrpElement)

Example 2 with ElementBuilderException

use of org.btrplace.btrpsl.template.ElementBuilderException in project scheduler by btrplace.

the class TemplateAssignment method addVM.

private void addVM(String tplName, String id, Map<String, String> opts) {
    try {
        Element el = namingServiceVMs.resolve(id);
        if (el == null) {
            VM vm = mo.newVM();
            mo.getMapping().addReadyVM(vm);
            // We add the VM to the $me variable
            if (vm == null) {
                ignoreError("No UUID to create node '" + id + "'");
            } else {
                namingServiceVMs.register(vm, id);
                el = vm;
                ((BtrpSet) syms.getSymbol(SymbolsTable.ME)).getValues().add(new BtrpElement(BtrpOperand.Type.VM, id, el));
            }
        }
        tpls.check(script, tplName, el, opts);
        if (!script.add(new BtrpElement(BtrpOperand.Type.VM, id, el))) {
            ignoreError("VM '" + id + "' already created");
        }
    } catch (ElementBuilderException ex) {
        ignoreError(ex);
    }
}
Also used : ElementBuilderException(org.btrplace.btrpsl.template.ElementBuilderException) Element(org.btrplace.model.Element) BtrpElement(org.btrplace.btrpsl.element.BtrpElement) VM(org.btrplace.model.VM) BtrpElement(org.btrplace.btrpsl.element.BtrpElement)

Aggregations

BtrpElement (org.btrplace.btrpsl.element.BtrpElement)2 ElementBuilderException (org.btrplace.btrpsl.template.ElementBuilderException)2 Element (org.btrplace.model.Element)2 Node (org.btrplace.model.Node)1 VM (org.btrplace.model.VM)1