Skip to content

Commit 65d7ae3

Browse files
author
Sowmya
committed
Made the code Pyflakes compliant
1 parent 1446ecd commit 65d7ae3

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed

test/integration/plugins/nuagevsp/nuageTestCase.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@
4848
listHypervisors,
4949
stopRouter,
5050
startRouter)
51-
# Import nosetests Modules
52-
from nose.plugins.attrib import attr
53-
5451
# Import System Modules
5552
import socket
5653
import importlib
@@ -318,30 +315,6 @@ def create_VM_in_Network(self, network, vm_key="virtual_machine", host_id=None,
318315
self.cleanup.append(vm)
319316
return vm
320317

321-
# starts the given vm
322-
def start(self, apiclient):
323-
"""Start the instance"""
324-
cmd = startVirtualMachine.startVirtualMachineCmd()
325-
cmd.id = self.id
326-
apiclient.startVirtualMachine(cmd)
327-
response = self.getState(apiclient, VirtualMachine.RUNNING)
328-
if response[0] == FAIL:
329-
raise Exception(response[1])
330-
return
331-
332-
# stops the given vm
333-
def stop(self, apiclient, forced=None):
334-
"""Stop the instance"""
335-
cmd = stopVirtualMachine.stopVirtualMachineCmd()
336-
cmd.id = self.id
337-
if forced:
338-
cmd.forced = forced
339-
apiclient.stopVirtualMachine(cmd)
340-
response = self.getState(apiclient, VirtualMachine.STOPPED)
341-
if response[0] == FAIL:
342-
raise Exception(response[1])
343-
return
344-
345318
# delete_VM - Deletes the given VM
346319
def delete_VM(self, vm):
347320
self.debug('Deleting VM - %s' % vm.name)

test/integration/plugins/nuagevsp/test_nuage_password_reset.py

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
""" Component tests for - userdata
1919
"""
2020
# Import Local Modules
21-
from marvin.lib.base import (VirtualMachine,
22-
Account,
23-
PublicIPAddress)
21+
from marvin.lib.base import (Account,
22+
VirtualMachine,
23+
Volume,
24+
Template)
2425
from nose.plugins.attrib import attr
2526
from nuageTestCase import nuageTestCase
26-
from marvin.cloudstackAPI import (createTemplate,
27-
listVolumes)
27+
from marvin.lib.utils import cleanup_resources
28+
from marvin.cloudstackAPI import startVirtualMachine
2829
import base64
2930

3031

@@ -69,12 +70,10 @@ def tearDown(self):
6970
# create_template - Takes the VM object as the argument to create the template
7071
def create_template(self, vm):
7172
self.debug("CREATE TEMPLATE")
72-
list_volume = list_volumes(
73-
self.apiclient,
74-
virtualmachineid=vm.id,
75-
type='ROOT',
76-
listall=True
77-
)
73+
list_volume = Volume.list(self.apiclient,
74+
virtualmachineid=vm.id,
75+
type='ROOT',
76+
listall=True)
7877
if isinstance(list_volume, list):
7978
self.volume = list_volume[0]
8079
else:
@@ -115,7 +114,6 @@ def create_and_verify_fw(self, vm, public_ip, network):
115114

116115
# VSD verification
117116
self.verify_vsp_floating_ip(network, vm, public_ip.ipaddress)
118-
vm_public_ip = public_ip.ipaddress.ipaddress
119117

120118
fw_rule = self.create_firewall_rule(public_ip, self.test_data["ingress_rule"])
121119
self.verify_vsp_firewall_rule(fw_rule)
@@ -131,6 +129,35 @@ def create_and_verify_fw(self, vm, public_ip, network):
131129
if not gotFirewallPolicy:
132130
raise ValueError('No firewall policy decision in vm interface')
133131

132+
def stop_vm(self, vm):
133+
self.debug("STOP VM")
134+
vm.stop(self.apiclient)
135+
list_vm_response = VirtualMachine.list(self.apiclient,
136+
id=vm.id)
137+
if isinstance(list_vm_response, list):
138+
vm = list_vm_response[0]
139+
if vm.state != 'Stopped':
140+
raise Exception("Failed to stop VM (ID: %s) " %
141+
self.vm.id)
142+
else:
143+
raise Exception("Invalid response from list_virtual_machines VM (ID: %s) " %
144+
self.vm.id)
145+
146+
def install_cloud_set_guest_password_script(self, ssh_client):
147+
self.debug("GET CLOUD-SET-GUEST-PASSWORD")
148+
cmd = "cd /etc/init.d;wget http://people.apache.org/~tsp/cloud-set-guest-password"
149+
result = self.execute_cmd(ssh_client, cmd)
150+
self.debug("WGET CLOUD-SET-GUEST-PASSWORD: " + result)
151+
if "200 OK" not in result:
152+
self.fail("failed to get file cloud-set-guest-password")
153+
cmds = ["chmod +x /etc/init.d/cloud-set-guest-password",
154+
"chkconfig --add cloud-set-guest-password"
155+
]
156+
for c in cmds:
157+
result = self.execute_cmd(ssh_client, c)
158+
self.debug("get_set_password_file cmd " + c)
159+
self.debug("get_set_password_file result " + result)
160+
134161
@attr(tags=["advanced", "nuagevsp"], required_hardware="true")
135162
def test_01_UserDataPasswordReset(self):
136163
self.debug("START USER DATA PASSWORD RESET ON VM")
@@ -211,7 +238,7 @@ def test_01_UserDataPasswordReset(self):
211238
self.stop_vm(self.vm_1)
212239
self.create_template(self.vm_1)
213240
self.debug("DEPLOY VM 2 IN TEST NETWORK WITH NEW TEMPLATE")
214-
self.vm_1 = self.create_VM_in_Network(self.network_1, "virtual_machine_pr")
241+
self.vm_2 = self.create_VM_in_Network(self.network_1, "virtual_machine_pr")
215242
self.remove_vm2 = True
216243
self.debug("STARTING VM_2 ")
217244
startCmd = startVirtualMachine.startVirtualMachineCmd()
@@ -225,7 +252,7 @@ def test_01_UserDataPasswordReset(self):
225252
"Password enabled not working. Password same as virtual_machine password "
226253
)
227254
self.verify_vsp_vm(vm_2a)
228-
self.debug("GET PUBLIC IP, CREATE AND VERIFY FIREWALL RULES")
255+
self.debug("GET PUBLIC IP. CREATE AND VERIFIED FIREWALL RULES")
229256
public_ip_2 = self.acquire_Public_IP(self.network_1)
230257
self.create_and_verify_fw(self.vm_2, public_ip_2, self.network_1)
231258

0 commit comments

Comments
 (0)