function addIcon() {
    var ip = nextIp();

    if (ip == null) {
        return;
    }

    var user = jQuery('#topoIconUser').val();
    var pw = jQuery('#topoIconPass').val();
    var name = jQuery('#topoIconName').val();
    var type = jQuery('#topoIconType').val();
    var image = jQuery('#topoIconImage').val();
    var cpu = jQuery('#topoIconCpu').val();
    var ram = jQuery('#topoIconRam').val();
    //var iconData = jQuery('#topoIconIcon').val();

    if (image == 0) {
        alert('Please select a valid image');
        return false;
    }
    var scriptId = jQuery('#topoIconScriptSelect').val();
    var scriptParam = jQuery('#topoIconScriptParam').val();

    var resize = jQuery('#topoIconResize').val();

    var vpfe_image = jQuery('#topoIconImageVFPCSelect').val();

    // enforce names always end with a digit
    var last = name.substr(-1);
    var lastInt = parseInt(last);
    if (isNaN(lastInt)) {
        alert('Name must end in a digit');
        jQuery('#topoIconName').val(name + "1");
        jQuery('#topoIconName').focus();
        return false;
    }

    if (name == "") {
        alert("Please add a valid instance name");
        return false;
    }

    var icon;

    vm_type_data = {};
    for (v=0;v<vm_types.length;v++) {
        vm_type = vm_types[v];
        if (vm_type.name == type) {
            vm_type_data = vm_type;
            break;
        }
    }
    console.log(vm_type_data);

    icon = eval("new " + vm_type_data.js + "()" );

    // Should the user have selected a companion image?
    if (icon.getCompanionType() != "") {
        // yes, did they?
        if (vpfe_image == 0) {
            // uh-oh!
            alert('Please select a Companion Image before continuing!');
            return false;
        }
    }

    // simple algorithm to add icons to the screen without overlapping
    lastX += 100;
    lastY += 0;
    vmxCount += 1;
    iconCount += 1;

    if (iconCount > iconWrapLimit) {
        lastX = 50;
        lastY = iconOffset;
        iconCount = 1;
        iconOffset += 110;
    }

    icon.setup(type, name, ip, user, pw, image);

    icon.setCpu(cpu);
    icon.setRam(ram);

    // set the resize value in userData dict
    icon.setUserDataKey('resize', resize);

    // set the scriptId in the
    if (scriptId != 0) {
        icon.setUserDataKey('configScriptId', scriptId);
        icon.setUserDataKey('configScriptParam', scriptParam);
    }

    if (icon.getSecondaryDiskParams() != "") {
        var params = icon.getSecondaryDiskParams();
        var type = params["type"];
        if (type == "image") {
            params["image_id"] = jQuery('#topoIconSecondaryDisk').val();
            icon.setSecondaryDiskParams(params);
        }
    }

    if (icon.getCompanionType() != "") {

        var vpfe_cpu = jQuery('#topoIconVFPCCpu').val();
        var vpfe_ram = jQuery('#topoIconVFPCRam').val();
        var vpfe_js = jQuery('#topoIconVFPCJs').val();
        var vpfe_type = jQuery('#topoIconVFPCType').val();

        // attempt to load vpfe as the selected image_id type
        // otherwise, use the default companion_type
        if (vpfe_js == '') {
            vpfe_js = icon.COMPANION_TYPE;
        }

        var vpfe = eval("new " + vpfe_js + "()" );

        vpfe_ip = nextIp();

        vpfe.setup(vpfe_type, name, vpfe_ip, user, pw, vpfe_image);

        vpfe.setCpu(vpfe_cpu);
        vpfe.setRam(vpfe_ram);
        // bind them together here!

        if (typeof vpfe.setParentId != 'undefined') {
            console.log("vpfe is actually a child!");
            console.log(vpfe.NAME);
            vpfe.setParentId(icon.getId());
            icon.setChildId(vpfe.getId());

            canvas.add(vpfe, lastX, lastY + 15);
        } else {
            alert("Companion Doesn't appear to be a valid companion image type!");
            return false;
        }

        canvas.add(icon, lastX, lastY);

        figures = new draw2d.util.ArrayList([icon, vpfe]);
        var cg = new draw2d.command.CommandGroup(canvas, figures);
        cg.execute();

        // work around, ports are being drawn as hidden until they are clicked!
        vpfe.getPorts().first().toFront();

    } else {
        canvas.add(icon, lastX, lastY);
    }

    // let's try to increment everything nicely
    jQuery('#topoIconName').val(incrementIconName(name));

    return true;
}
// add icon to the topology with the indicated values
add icon to the topology with the indicated values
add icon to the topology with the indicated values
function addIcon() {
    var ip = nextIp();
    if (ip == null) {
        return;
    }
    var user = jQuery('#topoIconUser').val();
    var pw = jQuery('#topoIconPass').val();
    var name = jQuery('#topoIconName').val();
    var type = jQuery('#topoIconType').val();
    var image = jQuery('#topoIconImage').val();
    var cpu = jQuery('#topoIconCpu').val();
    var ram = jQuery('#topoIconRam').val();
    if (image == 0) {
        alert('Please select a valid image');
        return false;
    }
    var scriptId = jQuery('#topoIconScriptSelect').val();
    var scriptParam = jQuery('#topoIconScriptParam').val();
    var resize = jQuery('#topoIconResize').val();
    var vpfe_image = jQuery('#topoIconImageVFPCSelect').val();
    var last = name.substr(-1);
    var lastInt = parseInt(last);
    if (isNaN(lastInt)) {
        alert('Name must end in a digit');
        jQuery('#topoIconName').val(name + "1");
        jQuery('#topoIconName').focus();
        return false;
    }
    if (name == "") {
        alert("Please add a valid instance name");
        return false;
    }
    var icon;
    vm_type_data = {};
    for (v=0;v<vm_types.length;v++) {
        vm_type = vm_types[v];
        if (vm_type.name == type) {
            vm_type_data = vm_type;
            break;
        }
    }
    console.log(vm_type_data);
    icon = eval("new " + vm_type_data.js + "()" );
    if (icon.getCompanionType() != "") {
        if (vpfe_image == 0) {
            alert('Please select a Companion Image before continuing!');
            return false;
        }
    }
    lastX += 100;
    lastY += 0;
    vmxCount += 1;
    iconCount += 1;
    if (iconCount > iconWrapLimit) {
        lastX = 50;
        lastY = iconOffset;
        iconCount = 1;
        iconOffset += 110;
    }
    icon.setup(type, name, ip, user, pw, image);
    icon.setCpu(cpu);
    icon.setRam(ram);
    icon.setUserDataKey('resize', resize);
    if (scriptId != 0) {
        icon.setUserDataKey('configScriptId', scriptId);
        icon.setUserDataKey('configScriptParam', scriptParam);
    }
    if (icon.getSecondaryDiskParams() != "") {
        var params = icon.getSecondaryDiskParams();
        var type = params["type"];
        if (type == "image") {
            params["image_id"] = jQuery('#topoIconSecondaryDisk').val();
            icon.setSecondaryDiskParams(params);
        }
    }
    if (icon.getCompanionType() != "") {
        var vpfe_cpu = jQuery('#topoIconVFPCCpu').val();
        var vpfe_ram = jQuery('#topoIconVFPCRam').val();
        var vpfe_js = jQuery('#topoIconVFPCJs').val();
        var vpfe_type = jQuery('#topoIconVFPCType').val();
        if (vpfe_js == '') {
            vpfe_js = icon.COMPANION_TYPE;
        }
        var vpfe = eval("new " + vpfe_js + "()" );
        vpfe_ip = nextIp();
        vpfe.setup(vpfe_type, name, vpfe_ip, user, pw, vpfe_image);
        vpfe.setCpu(vpfe_cpu);
        vpfe.setRam(vpfe_ram);
        if (typeof vpfe.setParentId != 'undefined') {
            console.log("vpfe is actually a child!");
            console.log(vpfe.NAME);
            vpfe.setParentId(icon.getId());
            icon.setChildId(vpfe.getId());
            canvas.add(vpfe, lastX, lastY + 15);
        } else {
            alert("Companion Doesn't appear to be a valid companion image type!");
            return false;
        }
        canvas.add(icon, lastX, lastY);
        figures = new draw2d.util.ArrayList([icon, vpfe]);
        var cg = new draw2d.command.CommandGroup(canvas, figures);
        cg.execute();
        vpfe.getPorts().first().toFront();
    } else {
        canvas.add(icon, lastX, lastY);
    }
    jQuery('#topoIconName').val(incrementIconName(name));
    return true;
}
function addIcon ( ) { var ip = nextIp ( ) ; if ( ip == null ) { return ; } var user = jQuery ( '#topoIconUser' ) . val ( ) ; var pw = jQuery ( '#topoIconPass' ) . val ( ) ; var name = jQuery ( '#topoIconName' ) . val ( ) ; var type = jQuery ( '#topoIconType' ) . val ( ) ; var image = jQuery ( '#topoIconImage' ) . val ( ) ; var cpu = jQuery ( '#topoIconCpu' ) . val ( ) ; var ram = jQuery ( '#topoIconRam' ) . val ( ) ; if ( image == 0 ) { alert ( 'Please select a valid image' ) ; return false ; } var scriptId = jQuery ( '#topoIconScriptSelect' ) . val ( ) ; var scriptParam = jQuery ( '#topoIconScriptParam' ) . val ( ) ; var resize = jQuery ( '#topoIconResize' ) . val ( ) ; var vpfe_image = jQuery ( '#topoIconImageVFPCSelect' ) . val ( ) ; var last = name . substr ( - 1 ) ; var lastInt = parseInt ( last ) ; if ( isNaN ( lastInt ) ) { alert ( 'Name must end in a digit' ) ; jQuery ( '#topoIconName' ) . val ( name + "1" ) ; jQuery ( '#topoIconName' ) . focus ( ) ; return false ; } if ( name == "" ) { alert ( "Please add a valid instance name" ) ; return false ; } var icon ; vm_type_data = { } ; for ( v = 0 ; v < vm_types . length ; v ++ ) { vm_type = vm_types [ v ] ; if ( vm_type . name == type ) { vm_type_data = vm_type ; break ; } } console . log ( vm_type_data ) ; icon = eval ( "new " + vm_type_data . js + "()" ) ; if ( icon . getCompanionType ( ) != "" ) { if ( vpfe_image == 0 ) { alert ( 'Please select a Companion Image before continuing!' ) ; return false ; } } lastX += 100 ; lastY += 0 ; vmxCount += 1 ; iconCount += 1 ; if ( iconCount > iconWrapLimit ) { lastX = 50 ; lastY = iconOffset ; iconCount = 1 ; iconOffset += 110 ; } icon . setup ( type , name , ip , user , pw , image ) ; icon . setCpu ( cpu ) ; icon . setRam ( ram ) ; icon . setUserDataKey ( 'resize' , resize ) ; if ( scriptId != 0 ) { icon . setUserDataKey ( 'configScriptId' , scriptId ) ; icon . setUserDataKey ( 'configScriptParam' , scriptParam ) ; } if ( icon . getSecondaryDiskParams ( ) != "" ) { var params = icon . getSecondaryDiskParams ( ) ; var type = params [ "type" ] ; if ( type == "image" ) { params [ "image_id" ] = jQuery ( '#topoIconSecondaryDisk' ) . val ( ) ; icon . setSecondaryDiskParams ( params ) ; } } if ( icon . getCompanionType ( ) != "" ) { var vpfe_cpu = jQuery ( '#topoIconVFPCCpu' ) . val ( ) ; var vpfe_ram = jQuery ( '#topoIconVFPCRam' ) . val ( ) ; var vpfe_js = jQuery ( '#topoIconVFPCJs' ) . val ( ) ; var vpfe_type = jQuery ( '#topoIconVFPCType' ) . val ( ) ; if ( vpfe_js == '' ) { vpfe_js = icon . COMPANION_TYPE ; } var vpfe = eval ( "new " + vpfe_js + "()" ) ; vpfe_ip = nextIp ( ) ; vpfe . setup ( vpfe_type , name , vpfe_ip , user , pw , vpfe_image ) ; vpfe . setCpu ( vpfe_cpu ) ; vpfe . setRam ( vpfe_ram ) ; if ( typeof vpfe . setParentId != 'undefined' ) { console . log ( "vpfe is actually a child!" ) ; console . log ( vpfe . NAME ) ; vpfe . setParentId ( icon . getId ( ) ) ; icon . setChildId ( vpfe . getId ( ) ) ; canvas . add ( vpfe , lastX , lastY + 15 ) ; } else { alert ( "Companion Doesn't appear to be a valid companion image type!" ) ; return false ; } canvas . add ( icon , lastX , lastY ) ; figures = new draw2d . util . ArrayList ( [ icon , vpfe ] ) ; var cg = new draw2d . command . CommandGroup ( canvas , figures ) ; cg . execute ( ) ; vpfe . getPorts ( ) . first ( ) . toFront ( ) ; } else { canvas . add ( icon , lastX , lastY ) ; } jQuery ( '#topoIconName' ) . val ( incrementIconName ( name ) ) ; return true ; }
add icon to the topology with the indicated values
add icon to the topology with the indicated values
//var iconData = jQuery('#topoIconIcon').val(); // enforce names always end with a digit // Should the user have selected a companion image? // yes, did they? // uh-oh! // simple algorithm to add icons to the screen without overlapping // set the resize value in userData dict // set the scriptId in the // attempt to load vpfe as the selected image_id type // otherwise, use the default companion_type // bind them together here! // work around, ports are being drawn as hidden until they are clicked! // let's try to increment everything nicely