Example #1
0
 def get_max_ram(uuid=str_(of='abc123-', min_length=36, max_length=36),
                 x=int_(min=0)):
     with MockTransaction:
         connection = libvirt.virConnect()
         domain = mock('domain')
         expect(connection).lookupByUUIDString(uuid). \
             and_return(domain).once()
         expect(domain).maxMemory().and_return(x).once()
         assert manager.get_max_ram(connection, uuid) == int(x / 1024)
 def get_max_ram_none(
     uuid=str_(of='abc123-', min_length=36, max_length=36)
 ):
     with MockTransaction:
         def raise_libvirt_error():
             raise libvirt.libvirtError(None)
         connection = libvirt.virConnect()
         expect(connection).lookupByUUIDString(uuid). \
             and_call(lambda _: raise_libvirt_error())
         assert manager.get_max_ram(connection, uuid) is None
Example #3
0
    def get_max_ram_none(uuid=str_(of='abc123-', min_length=36,
                                   max_length=36)):
        with MockTransaction:

            def raise_libvirt_error():
                raise libvirt.libvirtError(None)

            connection = libvirt.virConnect()
            expect(connection).lookupByUUIDString(uuid). \
                and_call(lambda _: raise_libvirt_error())
            assert manager.get_max_ram(connection, uuid) is None
 def get_max_ram_long(
     uuid=str_(of='abc123-', min_length=36, max_length=36),
     x=int_(min=0)
 ):
     with MockTransaction:
         connection = libvirt.virConnect()
         domain = mock('domain')
         expect(connection).lookupByUUIDString(uuid). \
             and_return(domain).once()
         expect(domain).maxMemory().and_return(long(x)).once()
         assert manager.get_max_ram(connection, uuid) == long(x) / 1024