Search in sources :

Example 6 with Element

use of org.btrplace.model.Element 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

Element (org.btrplace.model.Element)6 BtrpElement (org.btrplace.btrpsl.element.BtrpElement)3 JSONObject (net.minidev.json.JSONObject)2 ElementBuilderException (org.btrplace.btrpsl.template.ElementBuilderException)2 Map (java.util.Map)1 Token (org.antlr.runtime.Token)1 JSONConverterException (org.btrplace.json.JSONConverterException)1 JSONs.requiredString (org.btrplace.json.JSONs.requiredString)1 Node (org.btrplace.model.Node)1 VM (org.btrplace.model.VM)1 NamingService (org.btrplace.model.view.NamingService)1