def add_data_into_affinity(params,vm_details):
    current_host = vm_details['current_host']
    current_host = current_host.split("(")
    current_host = current_host[0]
    #if params['affinity_host'] != 0 :
    if isinstance(params['affinity_host'], str):
       host_details = params['affinity_host'].split()
    else :
       host_details = params['affinity_host']
    for item in host_details:
        db(db.vm_data.id == vm_details['vm_id']).update(affinity_flag=1)
        if db.host_affinity(affinity_host=item):
           db(db.host_affinity.affinity_host == item).update(affinity_host=item)
        else :
           db.host_affinity.insert(vm_id=vm_details['vm_id'],vm_name=vm_details['vm_name'], current_host=current_host, affinity_host=item)
def add_data_into_affinity(params, vm_id):
#     current_host = vm_details['current_host']
#     current_host = current_host.split("(")
#     current_host = current_host[0]
    if isinstance(params['affinity_host'], str):
        host_details = params['affinity_host'].split()
    else :
        host_details = params['affinity_host'] 
    if host_details != None:
        for host_name in host_details:
            db(db.vm_data.id == vm_id).update(affinity_flag=1)
            if db.host_affinity(affinity_host=host_name):
                db(db.host_affinity.affinity_host == host_name).update(affinity_host=host_name)
            else :
                db.host_affinity.insert(vm_id=vm_id, affinity_host=host_name)
    return host_details
Exemple #3
0
def add_data_into_affinity(params, vm_id):
#     current_host = vm_details['current_host']
#     current_host = current_host.split("(")
#     current_host = current_host[0]
    if isinstance(params['affinity_host'], str):
        host_details = params['affinity_host'].split()
    else :
        host_details = params['affinity_host'] 
    if host_details != None:
        for host_name in host_details:
            db(db.vm_data.id == vm_id).update(affinity_flag=1)
            if db.host_affinity(affinity_host=host_name):
                db(db.host_affinity.affinity_host == host_name).update(affinity_host=host_name)
            else :
                db.host_affinity.insert(vm_id=vm_id, affinity_host=host_name)
    return host_details