Esempio n. 1
0
def edit_duplicate_domain(hostname):
    vgname = None
    vglist = volume.list_vgs()
    if len(vglist) == 0:
        if dialogbox.messagebox.execute(gui.res.string_create_region, dialogbox.DialogBox.OKCANCEL(), gui.res.caution_sign) == "ok":
            vgname = volume.create_vg()
        if vgname == None: return None
    else:
        vgname = vglist[0]["name"]

    fields = [{"id":"hostname","label":gui.res.string_machine_name,"value":hostname},{"id":"vgname","label":gui.res.string_domain_area,"value":vgname}]
    while True:
        values = gui.propertybox.execute(gui.res.string_duplicate,fields)
        if values == None: break
        #else
        hostname = values["hostname"]
        vgname = values["vgname"]

        fields[0]["value"] = hostname
        fields[1]["value"] = vgname

        if domain.exists(hostname):
            dialogbox.messagebox.execute(gui.res.string_vm_already_exists % (hostname), None, gui.res.caution_sign)
            continue

        if not volume.vg_exists(vgname):
            dialogbox.messagebox.execute(gui.res.string_domain_desc % (vgname), None, gui.res.caution_sign)
            continue

        return {"hostname":hostname, "vgname":vgname}

    return None
Esempio n. 2
0
def edit_new_domain(title, hostname, default_memory, min_disk, min_memory = None):
    vgname = None
    vglist = volume.list_vgs()
    if len(vglist) == 0:
        if dialogbox.messagebox.execute(gui.res.string_create_region, dialogbox.DialogBox.OKCANCEL(), gui.res.caution_sign) == "ok":
            vgname = volume.create_vg()
        if vgname == None: return None
    else:
        vgname = vglist[0]["name"]

    fields = [{"id":"hostname","label":gui.res.string_machine_name,"value":hostname},{"id":"memory","label":gui.res.string_allocated_memory,"value":default_memory,"type":"int"},{"id":"vgname","label":gui.res.string_domain_area,"value":vgname},{"id":"disk","label":gui.res.string_allocation_hd,"value":min_disk,"type":"int"}]
    while True:
        values = gui.propertybox.execute(title,fields)
        if values == None: break
        #else
        hostname = values["hostname"]
        memory = values["memory"]
        vgname = values["vgname"]
        disk = values["disk"]

        fields[0]["value"] = hostname
        fields[1]["value"] = memory
        fields[2]["value"] = vgname
        fields[3]["value"] = disk

        if domain.exists(hostname):
            dialogbox.messagebox.execute(gui.res.string_vm_already_exists % (hostname), None, gui.res.caution_sign)
            continue

        if min_memory != None and memory < min_memory:
            dialogbox.messagebox.execute(gui.res.string_vm_creation_description % (min_memory), None, gui.res.caution_sign)
            continue
        if memory < 32:
            dialogbox.messagebox.execute(gui.res.string_vm_allocation_desc, None, gui.res.caution_sign)
            continue

        if disk < min_disk:
            dialogbox.messagebox.execute(gui.res.string_vm_space_desc % (min_disk), None, gui.res.caution_sign)
            continue

        if not volume.vg_exists(vgname):
            dialogbox.messagebox.execute(gui.res.string_domain_desc % (vgname), None, gui.res.caution_sign)
            continue

        return {"hostname":hostname, "vgname":vgname, "memory":memory, "disk":disk}

    return None
Esempio n. 3
0
def edit_duplicate_domain(hostname):
    vgname = None
    vglist = volume.list_vgs()
    if len(vglist) == 0:
        if dialogbox.messagebox.execute(gui.res.string_create_region,
                                        dialogbox.DialogBox.OKCANCEL(),
                                        gui.res.caution_sign) == "ok":
            vgname = volume.create_vg()
        if vgname == None: return None
    else:
        vgname = vglist[0]["name"]

    fields = [{
        "id": "hostname",
        "label": gui.res.string_machine_name,
        "value": hostname
    }, {
        "id": "vgname",
        "label": gui.res.string_domain_area,
        "value": vgname
    }]
    while True:
        values = gui.propertybox.execute(gui.res.string_duplicate, fields)
        if values == None: break
        #else
        hostname = values["hostname"]
        vgname = values["vgname"]

        fields[0]["value"] = hostname
        fields[1]["value"] = vgname

        if domain.exists(hostname):
            dialogbox.messagebox.execute(
                gui.res.string_vm_already_exists % (hostname), None,
                gui.res.caution_sign)
            continue

        if not volume.vg_exists(vgname):
            dialogbox.messagebox.execute(gui.res.string_domain_desc % (vgname),
                                         None, gui.res.caution_sign)
            continue

        return {"hostname": hostname, "vgname": vgname}

    return None
Esempio n. 4
0
def edit_new_domain(title,
                    hostname,
                    default_memory,
                    min_disk,
                    min_memory=None):
    vgname = None
    vglist = volume.list_vgs()
    if len(vglist) == 0:
        if dialogbox.messagebox.execute(gui.res.string_create_region,
                                        dialogbox.DialogBox.OKCANCEL(),
                                        gui.res.caution_sign) == "ok":
            vgname = volume.create_vg()
        if vgname == None: return None
    else:
        vgname = vglist[0]["name"]

    fields = [{
        "id": "hostname",
        "label": gui.res.string_machine_name,
        "value": hostname
    }, {
        "id": "memory",
        "label": gui.res.string_allocated_memory,
        "value": default_memory,
        "type": "int"
    }, {
        "id": "vgname",
        "label": gui.res.string_domain_area,
        "value": vgname
    }, {
        "id": "disk",
        "label": gui.res.string_allocation_hd,
        "value": min_disk,
        "type": "int"
    }]
    while True:
        values = gui.propertybox.execute(title, fields)
        if values == None: break
        #else
        hostname = values["hostname"]
        memory = values["memory"]
        vgname = values["vgname"]
        disk = values["disk"]

        fields[0]["value"] = hostname
        fields[1]["value"] = memory
        fields[2]["value"] = vgname
        fields[3]["value"] = disk

        if domain.exists(hostname):
            dialogbox.messagebox.execute(
                gui.res.string_vm_already_exists % (hostname), None,
                gui.res.caution_sign)
            continue

        if min_memory != None and memory < min_memory:
            dialogbox.messagebox.execute(
                gui.res.string_vm_creation_description % (min_memory), None,
                gui.res.caution_sign)
            continue
        if memory < 32:
            dialogbox.messagebox.execute(gui.res.string_vm_allocation_desc,
                                         None, gui.res.caution_sign)
            continue

        if disk < min_disk:
            dialogbox.messagebox.execute(
                gui.res.string_vm_space_desc % (min_disk), None,
                gui.res.caution_sign)
            continue

        if not volume.vg_exists(vgname):
            dialogbox.messagebox.execute(gui.res.string_domain_desc % (vgname),
                                         None, gui.res.caution_sign)
            continue

        return {
            "hostname": hostname,
            "vgname": vgname,
            "memory": memory,
            "disk": disk
        }

    return None