Exemplo n.º 1
0
Arquivo: vsh.py Projeto: WZQ1397/virty
def ImageDelete(DOM_NAME):
    NODE_NAME = vsql.SqlGetData("DOM_NAME", "NODE_NAME", DOM_NAME)
    NODE_IP = vsql.SqlGetData("NODE_NAME", "NODE_IP", NODE_NAME)

    LibvirtDomainDestroy(NODE_IP, DOM_NAME)

    vansible.AnsibleFiledeleteInnode(NODE_IP, "/kvm/dom/" + DOM_NAME + ".img")
Exemplo n.º 2
0
Arquivo: vsh.py Projeto: WZQ1397/virty
def DomainDevelop(DOM_NAME):
    NODE_NAME = vsql.SqlGetData("DOM_NAME", "NODE_NAME", DOM_NAME)
    NODE_IP = vsql.SqlGetData("NODE_NAME", "NODE_IP", NODE_NAME)
    conn = libvirt.open('qemu+ssh://' + NODE_IP + '/system')
    p = conn.lookupByName(DOM_NAME)
    clist = dir(p)
    for item in clist:
        print(item)
Exemplo n.º 3
0
Arquivo: vsh.py Projeto: WZQ1397/virty
def VirtyImgDeleteStatic(DOM_NAME):
    import xml.etree.ElementTree as ET
    NODE_NAME = vsql.SqlGetData("DOM_NAME", "NODE_NAME", DOM_NAME)
    NODE_IP = vsql.SqlGetData("NODE_NAME", "NODE_IP", NODE_NAME)
    conn = libvirt.open('qemu+ssh://' + NODE_IP + '/system')
    con = conn.lookupByName(DOM_NAME)
    root = ET.fromstring(con.XMLDesc())
    for disk in root.find('devices').findall('disk'):
        if disk.get("device") == "disk":
            IMG_PATH = disk.find("source").get("file", "none")
            LogInfo("INFO", IMG_PATH + "    @" + NODE_NAME)
            vansible.AnsibleFiledeleteInnode(NODE_IP, IMG_PATH)
    LogSuccess("OK", "All deletions are complete")
Exemplo n.º 4
0
Arquivo: vsh.py Projeto: WZQ1397/virty
def NetworkMake(L2l_NAME, NODE_NAME, DOM_NAME):
    NODE_IP = vsql.SqlGetData("NODE_NAME", "NODE_IP", NODE_NAME)
    datas = vsql.SqlHitL2less("NAMEtoDATA", L2l_NAME)
    for data in datas:
        vxml.XmlL2lessnetMake(data[0], data[2], data[1])
        vsql.SqlAddL2lesspool([(data[0], data[1], data[2], DOM_NAME, NODE_NAME)
                               ])
    VirtyNetDefine(NODE_IP)
    VirtyNetStart(L2l_NAME)
Exemplo n.º 5
0
Arquivo: vsh.py Projeto: WZQ1397/virty
def ArchiveInit(NAME):
    nodes = vsql.SqlGetAll("node")
    for node in nodes:
        ARCHIVE_DIR = vsql.SqlGetData("NODE_NAME", "ARCHIVE_DIR", node[0])
        if ARCHIVE_DIR == None:
            LogInfo("Skip", node[0] + " archive storage dose not exits")
            break
        LogInfo("Info", node[0] + "  on  " + ARCHIVE_DIR)
        vansible.AnsibleFilecpTonode(
            node[1], setting.script_path + '/img/' + NAME + '.img',
            ARCHIVE_DIR + NAME + '.img')
        vsql.SqlAddArchive([(NAME, ARCHIVE_DIR + NAME + '.img', node[0])])
Exemplo n.º 6
0
Arquivo: vsh.py Projeto: WZQ1397/virty
def Network2l(ARCHIVE_NAME, DOM_NAME, NIC, MEMORY, CORE, DOMAINPOOL_NAME):
    NODE_NAME = VirtyDomainpoolFree(DOMAINPOOL_NAME)
    NODE_IP = vsql.SqlGetData("NODE_NAME", "NODE_IP", NODE_NAME)
    ARCHIVE_PATH = vsql.SqlHitData("ARCHIVE_NAMEtoARCHIVE_PATH", ARCHIVE_NAME)
    VNC = str(VirtyVncFree(NODE_NAME))
    vsql.SqlAddDomain([(DOM_NAME, 0, NODE_NAME, CORE, MEMORY, DOMAINPOOL_NAME)
                       ])
    vansible.AnsibleFilecpInnode(NODE_IP, ARCHIVE_PATH,
                                 '/kvm/dom/' + DOM_NAME + '.img')
    vxml.XmlDomainMake(DOM_NAME, '/kvm/dom/' + DOM_NAME + '.img', VNC, NIC,
                       MEMORY, CORE)
    VirshDefine(NODE_IP)
    VirtyNetMake(NIC, NODE_NAME, DOM_NAME)
Exemplo n.º 7
0
Arquivo: vsh.py Projeto: WZQ1397/virty
def DomainCheckStatic(DOM_NAME, NODE_NAME):
    import xml.etree.ElementTree as ET

    NODE_IP = vsql.SqlGetData("NODE_NAME", "NODE_IP", NODE_NAME)
    if NODE_IP == None:
        LogError("NG", NODE_NAME + " is not found")
        exit(1)
    else:
        LogSuccess("OK", "Node is found")

    try:
        tree = ET.parse(setting.script_path + '/define/' + DOM_NAME + '.xml')
        root = tree.getroot()
    except:
        LogError("NG", "File dose not exit")
        exit(2)

    LogSuccess("OK", "File is exist")

    print("NAME  :" + root.find('name').text)
    print("RAM   :" + root.find('memory').text)
    print("UNIT  :" + root.find('memory').get("unit"))
    print("vCPU  :" + root.find('vcpu').text)

    storages = root.find('metadata').findall('storage')
    for storage in storages:
        if vsql.SqlGetData("ARCHIVE_DATA", "EXIST_STATUS",
                           (NODE_NAME, storage.get('archive'))) == 1:
            LogError("NG", "Archive dose not exits")
            exit(3)
        LogSuccess("OK", storage.get('archive') + " dose exits")

        STORAGE_PATH = vsql.SqlGetData("STORAGE_DATA", "STORAGE_PATH",
                                       (NODE_NAME, storage.get('storage')))
        if STORAGE_PATH == 1:
            LogError("NG", "Storage dose not found in node")
            exit(4)
        LogSuccess("OK", str(storage.get('storage')) + " is exist")
Exemplo n.º 8
0
Arquivo: vsh.py Projeto: WZQ1397/virty
def StorageInfo(STORAGE_NAME):
    datas = vsql.SqlPush("select * from storage where name='" + STORAGE_NAME +
                         "'")
    print('{0:12} {1:8} {2:8} {3:8} {4:8}'.format("NAME", "NODE", "DEVICE",
                                                  "TYPE", "PATH"))
    for data in datas:
        NODE_IP = vsql.SqlGetData("NODE_NAME", "NODE_IP", data[1])
        if NODE_IP == None: break
        DF = virty.SshInfoDir(NODE_IP, data[4])
        print(
            '{0:12} {1:8} {2:8} {3:8} {4:8} {5:12} {6:4.0f} {7:4.0f} {8:4.0f} {9:4} {10:4}'
            .format(data[0], data[1], data[2], data[3], data[4], DF[0],
                    int(DF[1]) / 1000000,
                    int(DF[2]) / 1000000,
                    int(DF[3]) / 1000000, DF[4], DF[5]))
Exemplo n.º 9
0
Arquivo: vsh.py Projeto: WZQ1397/virty
def DomainInfo(DOM_NAME):
    import xml.etree.ElementTree as ET
    NODE_NAME = vsql.SqlGetData("DOM_NAME", "NODE_NAME", DOM_NAME)
    NODE_IP = vsql.SqlGetData("NODE_NAME", "NODE_IP", NODE_NAME)
    conn = libvirt.open('qemu+ssh://' + NODE_IP + '/system')
    con = conn.lookupByName(DOM_NAME)
    root = ET.fromstring(con.XMLDesc())
    print("NAME  :" + root.find('name').text)
    print("RAM   :" + root.find('memory').text)
    print("UNIT  :" + root.find('memory').get("unit"))
    print("vCPU  :" + root.find('vcpu').text)
    vnc = root.find('devices').find('graphics')
    print("VNC   :" +
        "  PORT:" + vnc.get("port") +\
        "  AUTO:" + vnc.get("autoport") +\
        "  LISTEN:" + vnc.get("listen") +\
        "  PASSWD:" + vnc.get("passwd", "none"))
    for disk in root.find('devices').findall('disk'):
        if disk.find("source") is not None:
            print(\
                "DEVICE:" + disk.get("device") +\
                "   TYPE:" + disk.get("type") +\
                "   FILE:" + disk.find("source").get("file","none")+\
                "   TARGET:" + disk.find("target").get("dev"))
        else:
            print("DEVICE:" + \
                disk.get("device") + "  TYPE:" + \
                disk.get("type") + "  " + \
                "Not Connected"+ "  " + \
                disk.find("target").get("dev"))
    for nic in root.find('devices').findall('interface'):
        print("DEVICE:NIC  TYPE:" + \
            nic.get("type") + "   MAC:" + \
            nic.find("mac").get("address")+ "   Target:" + \
            nic.find("target").get("dev")+ "   " + \
            nic.find("source").get("bridge"))
Exemplo n.º 10
0
Arquivo: vsh.py Projeto: WZQ1397/virty
def Netwrok2lnetMake(L2L_NAME, NODE_NAME, GW_IP):
    NODE_IP = vsql.SqlGetData("NODE_NAME", "NODE_IP", NODE_NAME)
    vxml.XmlL2lessnetMake(L2L_NAME, GW_IP, "None")
    VirtyNetDefine(NODE_IP)
    VirtyNetStart(L2l_NAME)