Revision 9599e997 snf-cyclades-app/synnefo/logic/tests/servers.py

b/snf-cyclades-app/synnefo/logic/tests/servers.py
86 86
                                      state="ACTIVE",
87 87
                                      dhcp=True,
88 88
                                      flavor="CUSTOM")
89
        vm = mfactory.VirtualMachineFactory(operstate="ACTIVE")
89
        vm = mfactory.VirtualMachineFactory(operstate="STARTED")
90 90
        mfactory.BackendNetworkFactory(network=net, backend=vm.backend)
91 91
        mrapi().ModifyInstance.return_value = 42
92 92
        servers.connect(vm, net)
......
100 100
        self.assertEqual(nics[1]["network"], net.backend_id)
101 101

  
102 102
        # No dhcp
103
        vm = mfactory.VirtualMachineFactory(operstate="ACTIVE")
103
        vm = mfactory.VirtualMachineFactory(operstate="STARTED")
104 104
        net = mfactory.NetworkFactory(subnet="192.168.2.0/24",
105 105
                                      gateway="192.168.2.1",
106 106
                                      state="ACTIVE",
......
117 117
        self.assertEqual(nics[1]["network"], net.backend_id)
118 118

  
119 119
        # Test connect to IPv6 only network
120
        vm = mfactory.VirtualMachineFactory(operstate="ACTIVE")
120
        vm = mfactory.VirtualMachineFactory(operstate="STARTED")
121 121
        net = mfactory.NetworkFactory(subnet6="2000::/64",
122 122
                                      state="ACTIVE",
123 123
                                      gateway="2000::1")
......
158 158
        self.assertRaises(faults.BadRequest, servers.stop, vm)
159 159
        vm = mfactory.VirtualMachineFactory(operstate="STARTED")
160 160
        self.assertRaises(faults.BadRequest, servers.resize, vm)
161
        vm = mfactory.VirtualMachineFactory(operstate="STOPPED")
162
        self.assertRaises(faults.BadRequest, servers.stop, vm)
161
        # Check that connect/disconnect is allowed only in STOPPED vms
162
        # if hotplug is disabled.
163
        vm = mfactory.VirtualMachineFactory(operstate="STARTED")
164
        network = mfactory.NetworkFactory(state="ACTIVE")
165
        with override_settings(settings, GANETI_USE_HOTPLUG=False):
166
            self.assertRaises(faults.BadRequest, servers.connect, vm, network)
167
            self.assertRaises(faults.BadRequest, servers.disconnect, vm,
168
                              network)
163 169
        #test valid
170
        vm = mfactory.VirtualMachineFactory(operstate="STOPPED")
164 171
        mrapi().StartupInstance.return_value = 1
165 172
        with mocked_quotaholder():
166 173
            servers.start(vm)

Also available in: Unified diff