示例#1
0
   def setUp(self):
      """
      The fixture consists of a Host (stub) and a few instances ov Vm
      (Stub).
      """

      self.vmNoQuestion = Vm(name='noQuestion',
                             runtime=Struct(question=None))
      self.vmQuestion = Vm(name='Question',
                           runtime=Struct(
                              question=Struct(
                                 id='someQuestionId',
                                 text="What's up, doc?",
                                 choice=Struct(
                                    choiceInfo=[
                                       Struct(key='0', label='The sky'),
                                    ],
                                    defaultIndex=0,
                                 )
                              )
                           )
                        )
      self.host = Host('Fake host', [self.vmNoQuestion, self.vmQuestion])

      ## Replace `raw_input` with a version that we can automate.
      self.rawInputStub = RawInputStub()
示例#2
0
 def setUp(self):
     self.guest_net = [
         Struct(connected=True,
                deviceConfigId=4001,
                ipAddress='169.254.145.89',
                macAddress='00:0c:29:d9:60:4c',
                network='vctportgroup'),
         Struct(connected=True,
                deviceConfigId=4000,
                ipAddress='10.20.153.42',
                macAddress='00:0c:29:d9:60:42',
                network='VMPublic'),
     ]
     self.expected2Nics = map(Nic, self.guest_net)
     self.expected1Nic = map(Nic, self.guest_net[1:])
     self.vmWith2Nics = Vm(name='vmWith2Nics')
     self.vmWith2Nics.guest.net = self.guest_net
     self.vmWith1Nic = Vm(name='vmWith1Nic')
     self.vmWith1Nic.guest.net = self.guest_net[1:]
     self.vmWith0Nics = Vm(name='vmWith0Nics')
     self.vmWith0Nics.guest.net = []
     self.vmWithNoGuestInfo = Vm(name='vmWithNoGuestInfo')
     self.vmWithNoGuestInfo.guest.net = None
     self.host = Host('Fake host', [
         self.vmWith2Nics, self.vmWith1Nic, self.vmWith0Nics,
         self.vmWithNoGuestInfo
     ])
示例#3
0
文件: VmTests.py 项目: free-Zen/pvc
    def test_ShutdownGuest_on_ok(self):
        vm = Vm(name='OnToOff', powerState='on')

        task = vm.ShutdownGuest()

        self.failIfNotTask(task, 'ShutdownGuest return value was not a Task')
        self.failIf(task.WaitForCompletion() != 'success')
        self.failIf(vm.powerState != 'off')
示例#4
0
文件: VmTests.py 项目: free-Zen/pvc
    def test_RebootGuest_on_ok(self):
        vm = Vm(name='OnRebootGuest', powerState='on')

        task = vm.RebootGuest()

        self.failIfNotTask(task, 'RebootGuest return value was not a Task')
        self.failIf(task.WaitForCompletion() != 'success')
        self.failIf(vm.powerState != 'on')
示例#5
0
文件: VmTests.py 项目: free-Zen/pvc
    def test_PowerOn_off_ok(self):
        vm = Vm(name='OffToOn', powerState='off')

        task = vm.PowerOn()

        self.failIfNotTask(task, 'PowerOn return value was not a Task')
        self.failIf(task.WaitForCompletion() != 'success')
        self.failIf(vm.powerState != 'on')
示例#6
0
文件: VmTests.py 项目: free-Zen/pvc
    def test_Suspend_on_ok(self):
        vm = Vm(name='OnSuspend', powerState='on')

        task = vm.Suspend()

        self.failIfNotTask(task, 'Suspend return value was not a Task')
        self.failIf(task.WaitForCompletion() != 'success')
        self.failIf(vm.powerState != 'suspended')
示例#7
0
    def setUp(self):
        self.vm = Vm(name='some_vm')
        self.vm.config.guestId = 'winNetStandardGuest'
        self.vm.config.hardware = Struct(
            memoryMB='256',
            numCPU=2,
        )
        self.vm.config.version = 'vmx-04'
        self.vm.config.name = 'some_vm'
        self.vm.config.locationId = 'locationId'
        self.vm.config.uuid = 'uuid'
        self.vm.config.annotation = 'annotation'
        self.vm.config.files = Struct(
            snapshotDirectory='snapshotDir',
            suspendDirectory='suspendDir',
        )
        self.vm.config.flags = Struct(
            disableAcceleration=False,
            runWithDebugInfo=False,
            enableLogging=False,
            useToe=False,
        )
        self.vm.config.tools = Struct(
            afterPowerOn=False,
            afterResume=False,
            beforeGuestShutdown=False,
            beforeGuestStandby=False,
        )
        self.vm.config.defaultPowerOps = Struct(
            powerOffType='?',
            suspendType='?',
            resetType='?',
        )

        self.host = Host('Fake host', [self.vm])
示例#8
0
        def getVmAndHost():
            vm = Vm(name='fake_vm',
                    powerState=startState,
                    toolsInstalled=toolsInstalled)
            host = Host('Fake host', [vm])

            return vm, host
示例#9
0
   def setUp(self):
      self.host = Host('fakehost',
                       vmList=[Vm(name='FakeVm',
                                  powerState='poweredOn')])

      ## Capture what the SUT is writing to stdout and stderr so that
      ## we can verify it later.
      if self.redirect_stdout:
         sys.stdout = FileWriteCapture(sys.stdout).StartCapture()
      if self.redirect_stderr:
         sys.stderr = FileWriteCapture(sys.stderr).StartCapture()
示例#10
0
   def testNormal(self):
      host = Host('Fake host', [
         Vm('Marc'),
         Vm('Nicole'),
         Vm('Linux'),
         ])

      result = ListVms().DoIt(host)

      expectedResult = [
         Vm("Marc", host=host),
         Vm("Nicole", host=host),
         Vm("Linux", host=host),
         ]

      self.failIf(result != expectedResult, 'ListVms returns correct vms')
示例#11
0
文件: HostTests.py 项目: free-Zen/pvc
 def setUp(self):
     self.hostName = 'Fake host'
     self.vmName = 'Marc'
     self.host = Host(self.hostName,
                      [Vm(self.vmName, powerState='poweredOff')])
示例#12
0
文件: VmTests.py 项目: free-Zen/pvc
    def test_RebootGuest_off_fails(self):
        vm = Vm(name='OffRebootGuest', powerState='off')

        self.failUnlessRaises(vim.fault.InvalidPowerState, vm.RebootGuest)
示例#13
0
文件: VmTests.py 项目: free-Zen/pvc
    def test_ShutdownGuest_off_fails(self):
        vm = Vm(name='OffToOff', powerState='off')

        self.failUnlessRaises(vim.fault.InvalidPowerState, vm.ShutdownGuest)
示例#14
0
文件: pivot02.py 项目: free-Zen/pvc
def GetHost():
    return Host('stub_host_1', [
        Vm('fake_vm_1', powerState='poweredOff'),
        Vm('fake_vm_2', powerState='poweredOn'),
    ])
示例#15
0
文件: VmTests.py 项目: free-Zen/pvc
    def test_PowerOn_on_fails(self):
        vm = Vm(name='OnToOn', powerState='on')

        self.failUnlessRaises(vim.fault.InvalidPowerState, vm.PowerOn)
示例#16
0
 def setUp(self):
     self.vm = Vm(name='some_vm')
     self.vm.localPath = '/fake/vmfs/volumes/fake_datastore/%s.vmx' \
                         % self.vm.name
     self.host = Host('Fake host', [self.vm])
示例#17
0
文件: VmTests.py 项目: free-Zen/pvc
    def test_Suspend_off_fails(self):
        vm = Vm(name='OffSuspend', powerState='off')

        self.failUnlessRaises(vim.fault.InvalidPowerState, vm.Suspend)