Example #1
0
def Main(tc):
    # Check if tc.skip is set
    tc_skip = getattr(tc, 'skip', False)
    if tc_skip:
        return api.types.status.SUCCESS

    api.Logger.info("Vmotion Callback Invoked. TC: %s" % tc.Name())
    vmotion_enabled = getattr(tc.args, 'vmotion_enable', False)
    if not vmotion_enabled:
        api.Logger.debug("Vmotion is not enabled for TC: %s" % tc.Name())
        return api.types.status.SUCCESS

    tc.vmotion_resp = api.types.status.FAILURE
    if getattr(tc, 'vmotion_cntxt', None):

        timer = timeprofiler.TimeProfiler()
        timer.Start()

        # Update the Naples endpoint information - mimicking Venice (run a thread)
        cfg_thread = threading.Thread(target=__create_endpoint_info,
                                      args=(tc, ))

        req = api.Trigger_WorkloadMoveRequest()
        for dest_host, workloads in tc.vmotion_cntxt.MoveRequest.items():
            api.Trigger_WorkloadMoveAddRequest(req, workloads, dest_host)
        cfg_thread.start()
        tc.vmotion_resp = api.TriggerMove(req)

        if tc.vmotion_resp != api.types.status.SUCCESS:
            api.Logger.error("Vmotion failed for TC: %s" % tc.Name())

        cfg_thread.join()
        __update_endpoint_info(tc)

        if tc.vmotion_resp == api.types.status.SUCCESS:
            __delete_endpoint_info(tc)
            vmotion_utils.UpdateCurrentHome(tc)
        timer.Stop()
        tc.vmotion_cntxt.TimeProfile.append(timer.TotalTime())

    return tc.vmotion_resp
Example #2
0
def Verify(tc):
    if tc.skip: return api.types.status.SUCCESS
    if tc.resp is None:
        return api.types.status.FAILURE

    pair1 = tc.workload_pairs[0]
    pair2 = tc.workload_pairs[2]

    # Pair1 move aborted
    w1 = pair1[0]
    w2 = pair1[1]
    w3 = pair2[0]
    if tc.w1_orig_node != w1.node_name:
        return api.types.status.FAILURE

    if tc.w2_orig_node != w2.node_name:
        return api.types.status.FAILURE

    # w3 moved
    if tc.w3_orig_node == w3.node_name:
        return api.types.status.FAILURE

    store_wloads = api.GetWorkloads()
    for s_wl in store_wloads:
        if w1.workload_name == s_wl.workload_name:
            if tc.w1_orig_node != s_wl.node_name:
                return api.types.status.FAILURE
            break

    for s_wl in store_wloads:
        if w2.workload_name == s_wl.workload_name:
            if tc.w2_orig_node != s_wl.node_name:
                return api.types.status.FAILURE
            break

    req = api.Trigger_WorkloadMoveRequest()
    api.Trigger_WorkloadMoveAddRequest(req, [w3], tc.w3_orig_node)
    tc.resp = api.TriggerMove(req)

    return tc.resp
Example #3
0
def Trigger(tc):
    if tc.skip: return api.types.status.SUCCESS

    pair1 = tc.workload_pairs[0]
    pair2 = tc.workload_pairs[2]

    # Move pair1 in as-is
    w1 = pair1[0]
    w2 = pair1[1]
    w3 = pair2[0]
    w4 = pair2[1]
    tc.w1_orig_node = w1.node_name
    tc.w2_orig_node = w2.node_name
    tc.w3_orig_node = w3.node_name

    req = api.Trigger_WorkloadMoveRequest()

    api.Trigger_WorkloadMoveAddRequest(req, [w1], w2.node_name, abort_time=20)
    api.Trigger_WorkloadMoveAddRequest(req, [w2], w1.node_name, abort_time=10)
    api.Trigger_WorkloadMoveAddRequest(req, [w3], w4.node_name)

    tc.resp = api.TriggerMove(req)

    return tc.resp
Example #4
0
def triggerVmotion(tc, wl, node):
    api.Logger.info("triggering vmotion for workload %s to node %s" %
                    (wl.workload_name, node))
    req = api.Trigger_WorkloadMoveRequest()
    api.Trigger_WorkloadMoveAddRequest(req, [wl], node)
    tc.resp = api.TriggerMove(req)