Exemplo n.º 1
0
 def __init__(self, vm_uuid, task_uuid, hardware_uuid, package_uuid):
     Thread.__init__(self)
     self.vm_uuid = vm_uuid
     self.task_uuid = task_uuid
     self.hardware_uuid = hardware_uuid
     self.package_uuid = package_uuid
     self.nova_connection = get_nova_connection()
Exemplo n.º 2
0
 def __init__(self, vm_uuid, task_uuid, hardware_uuid, package_uuid):
     Thread.__init__(self)
     self.vm_uuid = vm_uuid
     self.task_uuid = task_uuid
     self.hardware_uuid = hardware_uuid
     self.package_uuid = package_uuid
     self.nova_connection = get_nova_connection()
Exemplo n.º 3
0
def vm_uuid(vm_uuid):
    """Return dict on GET, delete on DELETE and
    delete on POST with action=delete

    """

    vm = VM.query.get(vm_uuid)
    if not vm:
        abort(404)

    if request.method == 'GET':
        return json.dumps(
            dict(
                errno=0,
                message='Success',
                vm=vm.to_dict()))

    action_delete = request.method == 'POST' and request.form.get(
        'action') == 'delete'

    if request.method == 'DELETE' or action_delete:
        conn = get_nova_connection()
        conn.terminate_instances([vm.nova_id])
        db.session.delete(vm)
        db.session.commit()
        msg = "VM %s was deleted" % vm_uuid
        logger.debug(msg)
        return json.dumps(
            dict(
                errno=0,
                message=msg))
    
    return json.dumps(
        dict(
            errno=1,
            message="This action is not supported"))