def startStopSlice(action,uuid):

    "Manages the actions executed over VMs at url manage resources."
    try: 
        vmsToStart = VM.objects.filter(sliceId = uuid)
    
        #if action_type == 'stop' : action_type = 'hardStop'
        globalRspec = XmlHelper.getSimpleActionSpecificQuery(action, "dummy")
    	globalRspec.query.provisioning.action.pop()
        for vm in vmsToStart:
            rspec = XmlHelper.getSimpleActionSpecificQuery(action, vm.serverID)
            Translator.PopulateNewAction(rspec.query.provisioning.action[0], vm)
            globalRspec.query.provisioning.action.append(copy.deepcopy(rspec.query.provisioning.action[0]))
    
        ServiceThread.startMethodInNewThread(ProvisioningDispatcher.processProvisioning,globalRspec.query.provisioning, None)
    
        for vm in vmsToStart:
            if action == 'start':
            	vm.state = 'starting...'
            elif action == 'stop':
                vm.state = 'stopping'
            vm.save()
    except Exception as e:
        print e
        raise e
Пример #2
0
def startStopSlice(action, uuid):

    "Manages the actions executed over VMs at url manage resources."
    try:
        vmsToStart = VM.objects.filter(sliceId=uuid)

        #if action_type == 'stop' : action_type = 'hardStop'
        globalRspec = XmlHelper.getSimpleActionSpecificQuery(action, "dummy")
        globalRspec.query.provisioning.action.pop()
        for vm in vmsToStart:
            rspec = XmlHelper.getSimpleActionSpecificQuery(action, vm.serverID)
            Translator.PopulateNewAction(rspec.query.provisioning.action[0],
                                         vm)
            globalRspec.query.provisioning.action.append(
                copy.deepcopy(rspec.query.provisioning.action[0]))

        ServiceThread.startMethodInNewThread(
            ProvisioningDispatcher.processProvisioning,
            globalRspec.query.provisioning, None)

        for vm in vmsToStart:
            if action == 'start':
                vm.state = 'starting...'
            elif action == 'stop':
                vm.state = 'stopping'
            vm.save()
    except Exception as e:
        print e
        raise e
def manage_vm(request, slice_id, vm_id, action_type):
    "Manages the actions executed over VMs at url manage resources."
    if not (action_type.startswith("force")):
        vm = VM.objects.get(id = vm_id)
        rspec = XmlHelper.getSimpleActionSpecificQuery(action_type, vm.serverID)
        Translator.PopulateNewAction(rspec.query.provisioning.action[0], vm)
        ServiceThread.startMethodInNewThread(ProvisioningDispatcher.processProvisioning,rspec.query.provisioning, request.user)
        if action_type == 'start':
            vm.state = 'starting...'
        elif action_type == 'stop':
            vm.state = 'stopping...'
        elif action_type == 'reboot':
            vm.state = 'rebooting...'
        elif action_type == 'delete':
            vm.state = 'deleting...'
            # Delete the associated entry in the database
            Action.objects.all().filter(vm = vm).delete()
            # Keep actions table up-to-date after each deletion
            #Action.objects.all().exclude(vm__in = VM.objects.all()).delete()
        elif action_type == 'create':
            vm.state = 'creating...'
        vm.save()

    elif action_type == "force_update_vm":
        InformationDispatcher.force_update_vms(vm_id=vm_id)
    elif action_type == "force_update_server":
        InformationDispatcher.force_update_vms(client_id=vm_id)
    elif action_type == "force_update_all":
        for server in VTServer.objects.all():
             InformationDispatcher.force_update_vms(client_id=server.id) 
    #go to manage resources again
    response = HttpResponse("")
    return response
Пример #4
0
	def PropagateActionToProvisioningDispatcher(vm_id, serverUUID, action):
		from vt_manager.communication.utils.XmlHelper import XmlHelper
		from vt_manager.controller.dispatchers.xmlrpc.DispatcherLauncher import DispatcherLauncher
		vm = VirtualMachine.objects.get(id=vm_id).getChildObject()
		rspec = XmlHelper.getSimpleActionSpecificQuery(action, serverUUID)
		ActionController.PopulateNewActionWithVM(rspec.query.provisioning.action[0], vm)
		ServiceThread.startMethodInNewThread(DispatcherLauncher.processXmlQuery, rspec)
Пример #5
0
def manage_vm(request, slice_id, vm_id, action_type):

    "Manages the actions executed over VMs at url manage resources."

    vm = VM.objects.get(id = vm_id)
    #if action_type == 'stop' : action_type = 'hardStop'
    rspec = XmlHelper.getSimpleActionSpecificQuery(action_type, vm.serverID)
    Translator.PopulateNewAction(rspec.query.provisioning.action[0], vm)

    ServiceThread.startMethodInNewThread(ProvisioningDispatcher.processProvisioning,rspec.query.provisioning, request.user)

    #set temporally status
    #vm.state = "on queue"
    if action_type == 'start':
        vm.state = 'starting...'
    elif action_type == 'stop':
        vm.state = 'stopping...'
    elif action_type == 'reboot':
        vm.state = 'rebooting...'
    elif action_type == 'delete':
        vm.state = 'deleting...'
    elif action_type == 'create':
        vm.state = 'creating...'
    vm.save()
    #go to manage resources again
    #return HttpResponseRedirect(reverse("html_plugin_home",args=[slice_id]))
    response = HttpResponse("")
    return response
Пример #6
0
def manage_vm(request, slice_id, vm_id, action_type):
    "Manages the actions executed over VMs at url manage resources."
    if not (action_type.startswith("force")):
        vm = VM.objects.get(id=vm_id)
        rspec = XmlHelper.getSimpleActionSpecificQuery(action_type,
                                                       vm.serverID)
        Translator.PopulateNewAction(rspec.query.provisioning.action[0], vm)
        ServiceThread.startMethodInNewThread(
            ProvisioningDispatcher.processProvisioning,
            rspec.query.provisioning, request.user)
        if action_type == 'start':
            vm.state = 'starting...'
        elif action_type == 'stop':
            vm.state = 'stopping...'
        elif action_type == 'reboot':
            vm.state = 'rebooting...'
        elif action_type == 'delete':
            vm.state = 'deleting...'
            # Delete the associated entry in the database
            Action.objects.all().filter(vm=vm).delete()
            # Keep actions table up-to-date after each deletion
            #Action.objects.all().exclude(vm__in = VM.objects.all()).delete()
        elif action_type == 'create':
            vm.state = 'creating...'
        vm.save()

    elif action_type == "force_update_vm":
        InformationDispatcher.force_update_vms(vm_id=vm_id)
    elif action_type == "force_update_server":
        InformationDispatcher.force_update_vms(client_id=vm_id)
    elif action_type == "force_update_all":
        for server in VTServer.objects.all():
            InformationDispatcher.force_update_vms(client_id=server.id)
    #go to manage resources again
    response = HttpResponse("")
    return response