Search in sources :

Example 6 with BtrpElement

use of org.btrplace.btrpsl.element.BtrpElement 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)6 DefaultModel (org.btrplace.model.DefaultModel)3 Element (org.btrplace.model.Element)3 Model (org.btrplace.model.Model)3 ElementBuilderException (org.btrplace.btrpsl.template.ElementBuilderException)2 HashSet (java.util.HashSet)1 BtrpOperand (org.btrplace.btrpsl.element.BtrpOperand)1 Node (org.btrplace.model.Node)1 VM (org.btrplace.model.VM)1