Example #1
0
File: views.py Project: spawn3/uss
def vm_stop(request):
    vm_uuid = request.GET['vm_uuid']
    customer_uuid = request.GET['customer_uuid']

    erl_call_command, info = toolbox_json.vm_stop(vm_uuid)
    if is_ok(info):
        if not updateGlobalInfo():
            return HttpResponse(u'获取更新信息失败!')
        return HttpResponse(action_succ_resp_msg % (u'关机', info))
    else:
        return HttpResponse(action_fail_resp_msg % (u'关机', info, erl_call_command))
Example #2
0
File: views.py Project: spawn3/uss
def customer_lock(request):
    customer_uuid = request.GET['customer_uuid']
    customer = Customer.objects.get(uuid = customer_uuid)
    vm_set = VM.objects.filter(customer=customer_uuid)
    for vm in vm_set:
        if vm.status == 'running':
            erl_call_command, info = toolbox_json.vm_stop(vm.uuid)
            if not is_ok(info):
                return HttpResponse(u"""
                            <html>
                            <body><p>虚拟机停止失败,请确保该用户的虚拟机都处于停止状态。</p>
                            <p>%s</p>
                            </html>
                            """%(info,
                                )
                        )

    erl_call_command, info = toolbox_json.customer_lock(customer_uuid)
    if is_ok(info):
        customer.locked = True
        customer.save()

        if not updateGlobalInfo():
            return HttpResponse(u'获取更新信息失败')

        return HttpResponse(u"""
                            <html>
                            <p>用户:%s抛弃成功!</p>
                            </html>
                            """
                            % (customer.alias,
                                )
                        )
    else:
        return HttpResponse(u"""
                            <html>
                            <p>用户:%s抛弃失败!</p>
                            <br /><p>%s</p>
                            </html>
                            """
                            % (customer.alias,
                                info,
                                )
                        )