Пример #1
0
 def f(self, request):
     try:
         agent_config = common.services.get(ServiceName.AGENT_CONFIG)
         if (agent_config.reboot_required):
             response = response_class()
             response.result = result_code_class.SYSTEM_ERROR
             response.error = "Agent rebooting"
             return response
     except:
         # Just ignore
         pass
     try:
         deep_validate(request)
         response = func(self, request)
         deep_validate(response)
         return response
     except ConcurrentVmOperation:
         self._logger.info("Concurrent Vm operation on %s" %
                           request.vm_id)
         response = response_class()
         response.result = result_code_class.CONCURRENT_VM_OPERATION
         response.error = str(sys.exc_info())
         return response
     except:
         exception = sys.exc_info()
         self._logger.warning("Error calling %s" % str(request),
                              exc_info=exception)
         response = response_class()
         response.result = result_code_class.SYSTEM_ERROR
         response.error = str(exception[1])
         if not response.error:
             response.error = exception[0].__name__
         return response
Пример #2
0
 def f(self, request):
     try:
         agent_config = common.services.get(ServiceName.AGENT_CONFIG)
         if (agent_config.reboot_required):
             response = response_class()
             response.result = result_code_class.SYSTEM_ERROR
             response.error = "Agent rebooting"
             return response
     except:
         # Just ignore
         pass
     try:
         deep_validate(request)
         response = func(self, request)
         deep_validate(response)
         return response
     except ConcurrentVmOperation:
         self._logger.info("Concurrent Vm operation on %s" %
                           request.vm_id)
         response = response_class()
         response.result = result_code_class.CONCURRENT_VM_OPERATION
         response.error = str(sys.exc_info())
         return response
     except:
         exception = sys.exc_info()
         self._logger.warning("Error calling %s" % str(request),
                              exc_info=exception)
         response = response_class()
         response.result = result_code_class.SYSTEM_ERROR
         response.error = str(exception[1])
         if not response.error:
             response.error = exception[0].__name__
         return response
    def test_configure_request(self):
        msg = ConfigureRequest()
        self.assert_invalid(msg)
        msg.scheduler = "string"
        self.assert_invalid(msg)

        msg.roles = Roles()
        deep_validate(msg)

        sr = SchedulerRole()
        msg.roles.schedulers = [sr]
        self.assert_invalid(msg)
        sr.id = "string"
        deep_validate(msg)
Пример #4
0
    def test_configure_request(self):
        msg = ConfigureRequest()
        self.assert_invalid(msg)
        msg.scheduler = "string"
        msg.availability_zone = "string"
        self.assert_invalid(msg)

        msg.roles = Roles()
        deep_validate(msg)

        sr = SchedulerRole()
        msg.roles.schedulers = [sr]
        self.assert_invalid(msg)
        sr.id = "string"
        deep_validate(msg)
    def test_get_resource_response(self):
        msg = GetResourcesResponse(0)
        deep_validate(msg)

        vm = Vm()
        vm.id = "agent_id"
        vm.disks = []
        vm.state = State()

        resource = Resource()
        resource.vm = vm

        msg.resources = [resource]
        self.assert_invalid(msg)
        item = QuotaLineItem("test", "test", 1)
        msg.resources[0].vm.flavor = Flavor(name="flavor", cost=[item])

        deep_validate(msg)
Пример #6
0
    def test_get_resource_response(self):
        msg = GetResourcesResponse(0)
        deep_validate(msg)

        vm = Vm()
        vm.id = "agent_id"
        vm.disks = []
        vm.state = State()

        resource = Resource()
        resource.vm = vm

        msg.resources = [resource]
        self.assert_invalid(msg)
        item = QuotaLineItem("test", "test", 1)
        msg.resources[0].vm.flavor = Flavor(name="flavor", cost=[item])

        deep_validate(msg)
 def test_create_vm_request(self):
     msg = CreateVmRequest()
     self.assert_invalid(msg)
     msg.reservation = "string"
     deep_validate(msg)
Пример #8
0
 def test_create_vm_request(self):
     msg = CreateVmRequest()
     self.assert_invalid(msg)
     msg.reservation = "string"
     deep_validate(msg)