Exemplo n.º 1
0
def delete(caller_id, node_id):
    """
    Method deletes specified Node (provided it's state isn't  @val{closed}).
    To bring deleted Node back available for CC1 system, one has to add it once
    again.
    @decoratedby{src.cm.utils.decorators.admin_cm_log}

    @parameter{caller_id,int}
    @parameter{node_id,int} id of the node to delete

    @response{None}

    @raises{node_has_vms,CMException}
    @raises{node_delete,CMException}
    """
    node = Node.get(caller_id, node_id)

    # check if the node has vms
    if node.vm_set.exists():
        raise CMException('node_has_vms')

    try:
        node.delete()
    except:
        raise CMException('node_delete')
Exemplo n.º 2
0
def edit(caller_id, node_id, **node_info):
    """
    Method edits node, according to data provided in request,data.
    @decoratedby{src.cm.utils.decorators.admin_cm_log}. All Node's attributes
    need to be present in data dictionary (even if only some of
    them are changed, e.g. driver). Former Node's attributes may be accessed via
    clm.views.admin_cm.node.get_by_id() method.

    @parameter{caller_id,int}
    @parameter{driver,string} xen, kvm or other hypervisior name
    @parameter{transport,string} unix, ssh, tls or other available transport name for kvm
    @parameter{address,string} node ip adress or domain name
    @parameter{username,string} optional username for transport
    @parameter{suffix,string} optional suffix for transport (i.e. /system for KVM)
    @parameter{cpu_total,int}
    @parameter{memory_total,int}
    @parameter{hdd_total,int}
    @parameter{node_id} id of the Node to edit

    @response{None}

    @raises{node_edit,CMException}
    """
    node = Node.get(caller_id, node_id)

    for k, v in node_info.iteritems():
        setattr(node, k, v)

    try:
        node.save()
    except:
        raise CMException('node_edit')
Exemplo n.º 3
0
def get_by_id_details(caller_id, node_id):
    """
    Returns more details of the requested Node.

    @cmview_admin_cm
    @param_post{node_id,int} id of the requested Node
    @response{dict} Node.long_long_dict property of the requested Node
    """
    node = Node.get(caller_id, node_id)
    return node.long_long_dict
Exemplo n.º 4
0
def get_by_id_details(caller_id, node_id):
    """
    Returns more details of the requested Node.

    @cmview_admin_cm
    @param_post{node_id,int} id of the requested Node
    @response{dict} Node.long_long_dict property of the requested Node
    """
    node = Node.get(caller_id, node_id)
    return node.long_long_dict
Exemplo n.º 5
0
def get_by_id_details(caller_id, node_id):
    """
    Method returns detailed of requested Node.
    @decoratedby{src.cm.utils.decorators.admin_cm_log}

    @parameter{node_id,int} id of the requested Node

    @response{dict} further extended information about Node
    """
    node = Node.get(caller_id, node_id)
    return node.long_long_dict
Exemplo n.º 6
0
def lock(caller_id, node_id_list):
    """
    Sets specified Node's state as @val{locked}. No VMs can be run on locked Node.

    @cmview_admin_cm
    @param_post{node_id_list,int} list of the specified Nodes ids

    @response{None}

    @raises{node_lock,CMException}
    """
    for node_id in node_id_list:
        node = Node.get(caller_id, node_id)
        node.state = node_states['locked']

        try:
            node.save()
        except:
            raise CMException('node_lock')
Exemplo n.º 7
0
def lock(caller_id, node_id_list):
    """
    Sets specified Node's state as @val{locked}. No VMs can be run on locked Node.

    @cmview_admin_cm
    @param_post{node_id_list,int} list of the specified Nodes ids

    @response{None}

    @raises{node_lock,CMException}
    """
    for node_id in node_id_list:
        node = Node.get(caller_id, node_id)
        node.state = node_states['locked']

        try:
            node.save()
        except:
            raise CMException('node_lock')
Exemplo n.º 8
0
def lock(caller_id, node_id_list):
    """
    Method locks specified Node. No VMs can be run on locked node.
    @decoratedby{src.cm.utils.decorators.admin_cm_log}

    @parameter{caller_id,int}
    @parameter{node_id,int} id of the Node to lock

    @response{None}

    @raises{node_lock,CMException}
    """
    for node_id in node_id_list:
        node = Node.get(caller_id, node_id)
        node.state = node_states['locked']

        try:
            node.save()
        except:
            raise CMException('node_lock')
Exemplo n.º 9
0
def edit(caller_id, node_id, **node_info):
    """
    Updates Node attributes according to data provided in node_info.

    @cmview_admin_cm
    @param_post{node_id,int} id of the Node to edit
    @param_post{node_info,string} dictionary where cm.models.Node model's
    fields are the keys and values are values to set

    @raises{node_edit,CMException}
    """
    node = Node.get(caller_id, node_id)

    for k, v in node_info.iteritems():
        setattr(node, k, v)

    try:
        node.save()
    except:
        raise CMException('node_edit')
Exemplo n.º 10
0
def edit(caller_id, node_id, **node_info):
    """
    Updates Node attributes according to data provided in node_info.

    @cmview_admin_cm
    @param_post{node_id,int} id of the Node to edit
    @param_post{node_info,string} dictionary where cm.models.Node model's
    fields are the keys and values are values to set

    @raises{node_edit,CMException}
    """
    node = Node.get(caller_id, node_id)

    for k, v in node_info.iteritems():
        setattr(node, k, v)

    try:
        node.save()
    except:
        raise CMException('node_edit')
Exemplo n.º 11
0
def unlock(caller_id, node_id_list):
    """
    Unlocks specified Node. After unlock Node's state is @val{ok} and Users
    are able to run VMs on that Node.

    @cmview_admin_cm
    @param_post{node_id_list,int} list of the specified Nodes ids

    @response{None}

    @raises{node_unlock,CMException}
    """

    for node_id in node_id_list:
        node = Node.get(caller_id, node_id)
        node.state = node_states['ok']

        try:
            node.save()
        except:
            raise CMException('node_unlock')
Exemplo n.º 12
0
def unlock(caller_id, node_id_list):
    """
    Unlocks specified Node. After unlock Node's state is @val{ok} and Users
    are able to run VMs on that Node.

    @cmview_admin_cm
    @param_post{node_id_list,int} list of the specified Nodes ids

    @response{None}

    @raises{node_unlock,CMException}
    """

    for node_id in node_id_list:
        node = Node.get(caller_id, node_id)
        node.state = node_states['ok']

        try:
            node.save()
        except:
            raise CMException('node_unlock')
Exemplo n.º 13
0
def unlock(caller_id, node_id_list):
    """
    Method unlocks specified Node. After unlock Node's state is @val{ok} and
    one is be able to run VMs on that Node.
    @decoratedby{src.cm.utils.decorators.admin_cm_log}

    @parameter{caller_id,int}
    @parameter{node_id,int} id of the Node to unlock

    @response{None}

    @raises{node_unlock,CMException}
    """

    for node_id in node_id_list:
        node = Node.get(caller_id, node_id)
        node.state = node_states['ok']

        try:
            node.save()
        except:
            raise CMException('node_unlock')
Exemplo n.º 14
0
def delete(caller_id, node_id):
    """
    Deletes specified Node from database provided the Node does not host any
    VM's. Node's operating system setup isn't affected. To bring deleted Node
    back available for CC1 Cluster, one has to add it once again via Web
    Interface.

    @cmview_admin_cm
    @param_post{node_id,int} id of the Node to delete

    @raises{node_has_vms,CMException}
    @raises{node_delete,CMException}
    """
    node = Node.get(caller_id, node_id)

    # check if the node has vms
    if node.vm_set.exists():
        raise CMException('node_has_vms')

    try:
        node.delete()
    except:
        raise CMException('node_delete')
Exemplo n.º 15
0
def delete(caller_id, node_id):
    """
    Deletes specified Node from database provided the Node does not host any
    VM's. Node's operating system setup isn't affected. To bring deleted Node
    back available for CC1 Cluster, one has to add it once again via Web
    Interface.

    @cmview_admin_cm
    @param_post{node_id,int} id of the Node to delete

    @raises{node_has_vms,CMException}
    @raises{node_delete,CMException}
    """
    node = Node.get(caller_id, node_id)

    # check if the node has vms
    if node.vm_set.exists():
        raise CMException('node_has_vms')

    try:
        node.delete()
    except:
        raise CMException('node_delete')