Exemple #1
0
def predict_vm(ecs_infor_array, input_file_array):

    #Get the CPU information
    CPU_kernel, CPU_memory, N_Pvm, condition, Pvm, Predict_time, Predict_Start = utils.splitEscData(
        ecs_infor_array)
    #Get the History Data information
    length, Hvm, History_Start = utils.splitInputData(input_file_array)
    #History Data

    #Statistic and Split
    #lenD,S_Data=utils.Statistic_Split(length,Hvm,N_Pvm,Pvm)
    lenD, S_Data = utils.Denoise_Split(length, Hvm, N_Pvm, Pvm)
    #print S_Data

    result = []
    if ecs_infor_array is None:
        print 'ecs information is none'
        return result
    if input_file_array is None:
        print 'input file information is none'
        return result

    #-----------------------Mirror-------------------------
    #NEPvm=mirror.Mirror(lenD,N_Pvm,S_Data,Predict_time)
    #-----------------------Smirror-------------------------
    #NEPvm=mirror.Smirror(lenD,N_Pvm,S_Data,Predict_time)
    #-----------------------Smirror-------------------------
    NEPvm = mirror.Commirror(lenD, N_Pvm, S_Data, Predict_time)

    # allocation
    CPU, N_PCPU = Box.Boxing(NEPvm, Pvm, N_Pvm, CPU_kernel, CPU_memory,
                             condition)
    print N_PCPU
    result = utils.results_expression(CPU, N_PCPU, N_Pvm, Pvm)
    return result
Exemple #2
0
def predict_vm(ecs_infor_array, input_file_array):

    #Get the CPU information
    CPU_kernel, CPU_memory, N_Pvm, condition, Pvm, Predict_time, Predict_Start = utils.splitEscData(
        ecs_infor_array)
    #Get the History Data information
    length, Hvm, History_Start = utils.splitInputData(input_file_array)
    #History Data

    lenD, S_Data = utils.Denoise_Split(length, Hvm, N_Pvm, Pvm)
    #print S_Data

    result = []
    if ecs_infor_array is None:
        print 'ecs information is none'
        return result
    if input_file_array is None:
        print 'input file information is none'
        return result

    #--------------------method one estimate--------------
    NEPvm = TDEstimation.EstTD(History_Start, Predict_Start, lenD, N_Pvm,
                               S_Data, Predict_time)
    print NEPvm

    # allocation
    CPU, N_PCPU = Box.Boxing(NEPvm, Pvm, N_Pvm, CPU_kernel, CPU_memory,
                             condition)
    print N_PCPU

    result = utils.results_expression(CPU, N_PCPU, N_Pvm, Pvm)
    return result
Exemple #3
0
def predict_vm(ecs_infor_array, input_file_array):

    #Get the CPU information
    CPU_kernal, CPU_memory, N_Pvm, condition, Pvm, Predict_time = utils.splitEscData(
        ecs_infor_array)
    '''
    CPU_kernal: The number of CPU kernal
    CPU_memory: The size of memory
    N_Pvm: The number of Vms which need to predict
    condition
    Pvm: The Vms which need to predict
    Predict_time: The period of prediction 
    '''

    #Get the History Data information
    length, Hvm = utils.splitInputData(input_file_array)
    #History Data

    #Statistic and Split
    lenD, S_Data = utils.Statistic_Split(length, Hvm, N_Pvm, Pvm)

    result = []
    if ecs_infor_array is None:
        print 'ecs information is none'
        return result
    if input_file_array is None:
        print 'input file information is none'
        return result
    #---------------------method one----------------------
    #NEPvm=lwlr.Prob_predict(N_Pvm,lenD,S_Data,Predict_time)

    #---------------------method two----------------------
    NEPvm = lwlr.lwlr_predict(N_Pvm, lenD, S_Data, Predict_time)
    print NEPvm

    #write result
    result.append(int(sum(NEPvm)))
    for i in range(N_Pvm):
        result.append((str(Pvm[i][0]) + " " + str(int(NEPvm[i]))))
    result.append("")

    # the numbor of predicted vms
    total_kernal = 0
    total_memory = 0
    for i in range(N_Pvm):
        total_kernal = total_kernal + NEPvm[i] * Pvm[i][1]
        total_memory = total_memory + NEPvm[i] * Pvm[i][2]
    if (math.ceil(total_kernal / CPU_kernal) >= math.ceil(
            total_memory / CPU_memory)):
        N_PCPU = int(math.ceil(total_kernal / CPU_kernal))
    else:
        N_PCPU = int(math.ceil(total_momery / CPU_kernal))

    # allocation
    CPU, N_PCPU = Boxing(N_PCPU, NEPvm, Pvm, N_Pvm, CPU_kernal, CPU_memory)
    result = utils.results_expression(result, CPU, N_PCPU)
    return result
Exemple #4
0
def predict_vm(ecs_infor_array,input_file_array):

    #Get the CPU information
    N_Stype,Servers,N_Pvm,Pvm,Predict_time,Predict_Start=utils.splitEscData(ecs_infor_array)

    #Get the History Data information
    length,Hvm,History_End=utils.splitInputData(input_file_array)
    #History Data
    Hdate=datetime.datetime.strptime(History_End,"%Y-%m-%d %H:%M:%S").date()

    #Statistic and Split
    #lenD,S_Data=utils.Statistic_Split(length,Hvm,N_Pvm,Pvm)
    lenD,S_Data=utils.Denoise_Split(length,Hvm,N_Pvm,Pvm)

    # deal with gaps
    gaps=int(round((utils.getTimeDiff(Predict_Start,History_End))/86400))
    for i in range(N_Pvm):
        for j in range(gaps):
            S_Data[i].append(S_Data[i][(-7)])
    
    result = []
    if ecs_infor_array is None:
        print 'ecs information is none'
        return result
    if input_file_array is None:
        print 'input file information is none'
        return result
    
    if(N_Pvm>5):
        return
        V=3.3
        NEPvm=mirror.Commirror(lenD,N_Pvm,S_Data,Predict_time,V)
        for i in range(N_Pvm):
            if((Pvm[i][0]=="flavor3")and(Hdate.month>6)):
                NEPvm[i]=int(NEPvm[i]*19)
    else:
        #add value
        #V=4
        V=0
        NEPvm=mirror.Smirror(lenD,N_Pvm,S_Data,Predict_time,V)
    for i in range(N_Pvm):
        if(Pvm[i][0]=="flavor8"):
            NEPvm[i]=int(NEPvm[i]*1.2)
    
    # allocation
    Servers_N,P_Servers=Allocation.Allocate(NEPvm,Pvm,N_Stype,Servers)

    
    result=utils.results_expression(P_Servers,Servers_N,Servers,Pvm)
    return result
Exemple #5
0
def predict_vm(ecs_infor_array,input_file_array):

    #Get the CPU information
    N_Stype,Servers,N_Pvm,Pvm,Predict_time,Predict_Start=utils.splitEscData(ecs_infor_array)

    #Get the History Data information
    length,Hvm,History_End=utils.splitInputData(input_file_array)
    Hdate=datetime.datetime.strptime(History_End,"%Y-%m-%d %H:%M:%S").date()

    #Statistic and Split
    lenD,S_Data=utils.Statistic_Split(length,Hvm,N_Pvm,Pvm)

    # deal with gaps
    gaps=int(round((utils.getTimeDiff(Predict_Start,History_End))/86400))
    for i in range(N_Pvm):
        for j in range(gaps):
            S_Data[i].append((S_Data[i][-7]))

    
    result = []
    if ecs_infor_array is None:
        print 'ecs information is none'
        return result
    if input_file_array is None:
        print 'input file information is none'
        return result

    if(N_Pvm>5):
        T=2
        V=0
        #return
        NEPvm=ES.ES(lenD,N_Pvm,S_Data,Predict_time,T,V)
        for i in range(N_Pvm):
            if(Pvm[i][0]=="flavor3")and(Hdate.month>6):
                NEPvm[i]=int(NEPvm[i]*34)
    else:
        #return
        T=0.85
        V=6
        NEPvm=ES.ES(lenD,N_Pvm,S_Data,Predict_time,T,V)
    for i in range(N_Pvm):
        if(Pvm[i][0]=="flavor8"):
            NEPvm[i]=int(NEPvm[i]*1.7)
    # allocation
    Servers_N,P_Servers=Allocation.Allocate(NEPvm,Pvm,N_Stype,Servers)
    
    result=utils.results_expression(P_Servers,Servers_N,Servers,Pvm)
    return result
def predict_vm(ecs_infor_array,input_file_array):

    #Get the CPU information
    N_Stype,Servers,N_Pvm,Pvm,Predict_time,Predict_Start=utils.splitEscData(ecs_infor_array)

    #Get the History Data information
    length,Hvm,History_End=utils.splitInputData(input_file_array)
    #History Data


    #Statistic and Split
    #lenD,S_Data=utils.Statistic_Split(length,Hvm,N_Pvm,Pvm)
    lenD,S_Data=utils.Denoise_Split(length,Hvm,N_Pvm,Pvm)

    # deal with gaps
    gaps=int(round((utils.getTimeDiff(Predict_Start,History_End))/86400))
    for i in range(N_Pvm):
        for j in range(gaps):
            S_Data[i].append(S_Data[i][-7])
    print S_Data

    
    result = []
    if ecs_infor_array is None:
        print 'ecs information is none'
        return result
    if input_file_array is None:
        print 'input file information is none'
        return result

    #-----------------------Smirror-------------------------
    #NEPvm=mirror.Smirror(lenD,N_Pvm,S_Data,Predict_time)
    #-----------------------Smirror-------------------------
    #NEPvm=mirror.Commirror(lenD,N_Pvm,S_Data,Predict_time)
    #------------------------ES-----------------------------
    NEPvm=ES.CES(lenD,N_Pvm,S_Data,Predict_time)
    print NEPvm
    
    # allocation
    Servers_N,P_Servers=Allocation.Allocate(NEPvm,Pvm,N_Stype,Servers)

    S=Score.Score(NEPvm,Pvm,Servers_N,P_Servers,Servers)
    print S
    
    result=utils.results_expression(P_Servers,Servers_N,Servers,Pvm)
    return result
def predict_vm(ecs_infor_array, input_file_array):

    #Get the CPU information
    N_Stype, Servers, N_Pvm, Pvm, Predict_time, Predict_Start = utils.splitEscData(
        ecs_infor_array)

    #Get the History Data information
    length, Hvm, History_End = utils.splitInputData(input_file_array)
    #History Data
    #Statistic and Split
    lenD, S_Data = utils.Statistic_Split(length, Hvm, N_Pvm, Pvm)

    # deal with gaps
    gaps = int(round((utils.getTimeDiff(Predict_Start, History_End)) / 86400))
    for i in range(N_Pvm):
        for j in range(gaps):
            S_Data[i].append((S_Data[i][-7]))

    result = []
    if ecs_infor_array is None:
        print 'ecs information is none'
        return result
    if input_file_array is None:
        print 'input file information is none'
        return result

    if (N_Pvm > 5):
        T = 2.6
        V = 0
        #return
        NEPvm = ES.ES(lenD, N_Pvm, S_Data, Predict_time, T, V)
    else:
        T = 0.85
        V = 5
        NEPvm = ES.ES(lenD, N_Pvm, S_Data, Predict_time, T, V)
    # allocation
    Servers_N, P_Servers = Allocation.Allocate(NEPvm, Pvm, N_Stype, Servers)

    result = utils.results_expression(P_Servers, Servers_N, Servers, Pvm)
    return result
def predict_vm(ecs_infor_array,input_file_array):

    #Get the CPU information
    CPU_kernal,CPU_memory,N_Pvm,condition,Pvm,Predict_time,Predict_Start=utils.splitEscData(ecs_infor_array)
    
    #Get the History Data information
    length,Hvm,History_Start=utils.splitInputData(input_file_array)
    #History Data

    #Statistic and Split
    lenD,S_Data=utils.Statistic_Split(length,Hvm,N_Pvm,Pvm)
    #print S_Data
    
    result = []
    if ecs_infor_array is None:
        print 'ecs information is none'
        return result
    if input_file_array is None:
        print 'input file information is none'
        return result

    #--------------------method five estimate--------------
    #NEPvm=TDEstimation.EstTD(History_Start,Predict_Start,lenD,N_Pvm,S_Data,Predict_time)

    #-----------------------Mirror-------------------------
    NEPvm=mirror.Mirror(lenD,N_Pvm,S_Data,Predict_time)
    print NEPvm

    #---------------------method Three--------------------
    #NEPvm=lwlr.lwlr_predict(N_Pvm,lenD,S_Data,Predict_time)
    #print NEPvm

    # allocation
    CPU,N_PCPU=Boxing(NEPvm,Pvm,N_Pvm,CPU_kernal,CPU_memory)
    print N_PCPU
    result=utils.results_expression(CPU,N_PCPU,N_Pvm,Pvm)
    return result