mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
CLOUDSTACK-8152: Adding delay before creating snapshot/template from root disk after writing data to disk - test_vm_passwordenabled.py
Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org> (cherry picked from commit d79837b67a481e618c8291152a9ecec299ff02dd) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> Conflicts: test/integration/component/test_vm_passwdenabled.py
This commit is contained in:
parent
f702097b3e
commit
fc502a97c2
@ -14,24 +14,33 @@
|
|||||||
# KIND, either express or implied. See the License for the
|
# KIND, either express or implied. See the License for the
|
||||||
# specific language governing permissions and limitations
|
# specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import marvin
|
from marvin.cloudstackTestCase import cloudstackTestCase
|
||||||
from marvin.cloudstackTestCase import *
|
from marvin.lib.utils import cleanup_resources
|
||||||
from marvin.cloudstackAPI import *
|
from marvin.lib.base import (Account,
|
||||||
from marvin.sshClient import SshClient
|
ServiceOffering,
|
||||||
from marvin.lib.utils import *
|
VirtualMachine,
|
||||||
from marvin.lib.base import *
|
EgressFireWallRule,
|
||||||
from marvin.lib.common import *
|
Template)
|
||||||
|
from marvin.lib.common import (get_domain,
|
||||||
|
get_zone,
|
||||||
|
get_template,
|
||||||
|
list_virtual_machines,
|
||||||
|
list_volumes)
|
||||||
from nose.plugins.attrib import attr
|
from nose.plugins.attrib import attr
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
_multiprocess_shared_ = True
|
_multiprocess_shared_ = True
|
||||||
|
|
||||||
|
|
||||||
class Services:
|
class Services:
|
||||||
|
|
||||||
"""Test VM Life Cycle Services
|
"""Test VM Life Cycle Services
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.services = {
|
self.services = {
|
||||||
"disk_offering":{
|
"disk_offering": {
|
||||||
"displaytext": "Small",
|
"displaytext": "Small",
|
||||||
"name": "Small",
|
"name": "Small",
|
||||||
"disksize": 1
|
"disksize": 1
|
||||||
@ -44,26 +53,26 @@ class Services:
|
|||||||
# Random characters are appended in create account to
|
# Random characters are appended in create account to
|
||||||
# ensure unique username generated each time
|
# ensure unique username generated each time
|
||||||
"password": "password",
|
"password": "password",
|
||||||
},
|
},
|
||||||
"small":
|
"small":
|
||||||
# Create a small virtual machine instance with disk offering
|
# Create a small virtual machine instance with disk offering
|
||||||
{
|
{
|
||||||
"displayname": "testserver",
|
"displayname": "testserver",
|
||||||
"username": "root", # VM creds for SSH
|
"username": "root", # VM creds for SSH
|
||||||
"password": "password",
|
"password": "password",
|
||||||
"ssh_port": 22,
|
"ssh_port": 22,
|
||||||
"hypervisor": 'XenServer',
|
"hypervisor": 'XenServer',
|
||||||
"privateport": 22,
|
"privateport": 22,
|
||||||
"publicport": 22,
|
"publicport": 22,
|
||||||
"protocol": 'TCP',
|
"protocol": 'TCP',
|
||||||
},
|
},
|
||||||
"egress": {
|
"egress": {
|
||||||
"name": 'web',
|
"name": 'web',
|
||||||
"protocol": 'TCP',
|
"protocol": 'TCP',
|
||||||
"startport": 80,
|
"startport": 80,
|
||||||
"endport": 80,
|
"endport": 80,
|
||||||
"cidrlist": '0.0.0.0/0',
|
"cidrlist": '0.0.0.0/0',
|
||||||
},
|
},
|
||||||
"service_offerings":
|
"service_offerings":
|
||||||
{
|
{
|
||||||
"small":
|
"small":
|
||||||
@ -75,19 +84,20 @@ class Services:
|
|||||||
"cpunumber": 1,
|
"cpunumber": 1,
|
||||||
"cpuspeed": 100,
|
"cpuspeed": 100,
|
||||||
"memory": 256,
|
"memory": 256,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"template": {
|
"template": {
|
||||||
"displaytext": "Cent OS Template",
|
"displaytext": "Cent OS Template",
|
||||||
"name": "Cent OS Template",
|
"name": "Cent OS Template",
|
||||||
"passwordenabled": True,
|
"passwordenabled": True,
|
||||||
},
|
},
|
||||||
"sleep": 60,
|
"sleep": 60,
|
||||||
"timeout": 10,
|
"timeout": 10,
|
||||||
"ostype": 'CentOS 5.3 (64-bit)',
|
"ostype": 'CentOS 5.3 (64-bit)',
|
||||||
# CentOS 5.3 (64-bit)
|
# CentOS 5.3 (64-bit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class TestVMPasswordEnabled(cloudstackTestCase):
|
class TestVMPasswordEnabled(cloudstackTestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -132,33 +142,39 @@ class TestVMPasswordEnabled(cloudstackTestCase):
|
|||||||
|
|
||||||
networkid = cls.virtual_machine.nic[0].networkid
|
networkid = cls.virtual_machine.nic[0].networkid
|
||||||
|
|
||||||
# create egress rule to allow wget of my cloud-set-guest-password script
|
# create egress rule to allow wget of my cloud-set-guest-password
|
||||||
|
# script
|
||||||
if zone.networktype.lower() == 'advanced':
|
if zone.networktype.lower() == 'advanced':
|
||||||
EgressFireWallRule.create(cls.api_client,
|
EgressFireWallRule.create(
|
||||||
networkid=networkid,
|
cls.api_client,
|
||||||
protocol=cls.services["egress"]["protocol"],
|
networkid=networkid,
|
||||||
startport=cls.services["egress"]["startport"],
|
protocol=cls.services["egress"]["protocol"],
|
||||||
endport=cls.services["egress"]["endport"],
|
startport=cls.services["egress"]["startport"],
|
||||||
cidrlist=cls.services["egress"]["cidrlist"])
|
endport=cls.services["egress"]["endport"],
|
||||||
|
cidrlist=cls.services["egress"]["cidrlist"])
|
||||||
|
|
||||||
cls.virtual_machine.password = cls.services["small"]["password"]
|
cls.virtual_machine.password = cls.services["small"]["password"]
|
||||||
ssh = cls.virtual_machine.get_ssh_client()
|
ssh = cls.virtual_machine.get_ssh_client()
|
||||||
|
|
||||||
#below steps are required to get the new password from VR(reset password)
|
# below steps are required to get the new password from VR
|
||||||
#http://cloudstack.org/dl/cloud-set-guest-password
|
# (reset password)
|
||||||
#Copy this file to /etc/init.d
|
# http://cloudstack.org/dl/cloud-set-guest-password
|
||||||
#chmod +x /etc/init.d/cloud-set-guest-password
|
# Copy this file to /etc/init.d
|
||||||
#chkconfig --add cloud-set-guest-password
|
# chmod +x /etc/init.d/cloud-set-guest-password
|
||||||
|
# chkconfig --add cloud-set-guest-password
|
||||||
|
|
||||||
cmds = [
|
cmds = [
|
||||||
"cd /etc/init.d;wget http://people.apache.org/~tsp/cloud-set-guest-password",
|
"cd /etc/init.d;wget http://people.apache.org/~tsp/cloud-set-guest-password",
|
||||||
"chmod +x /etc/init.d/cloud-set-guest-password",
|
"chmod +x /etc/init.d/cloud-set-guest-password",
|
||||||
"chkconfig --add cloud-set-guest-password",
|
"chkconfig --add cloud-set-guest-password",
|
||||||
]
|
]
|
||||||
for c in cmds:
|
for c in cmds:
|
||||||
result = ssh.execute(c)
|
ssh.execute(c)
|
||||||
|
|
||||||
#Stop virtual machine
|
# Adding delay of 120 sec to avoid data loss due to timing issue
|
||||||
|
time.sleep(120)
|
||||||
|
|
||||||
|
# Stop virtual machine
|
||||||
cls.virtual_machine.stop(cls.api_client)
|
cls.virtual_machine.stop(cls.api_client)
|
||||||
|
|
||||||
# Poll listVM to ensure VM is stopped properly
|
# Poll listVM to ensure VM is stopped properly
|
||||||
@ -199,7 +215,8 @@ class TestVMPasswordEnabled(cloudstackTestCase):
|
|||||||
cls.virtual_machine.id)
|
cls.virtual_machine.id)
|
||||||
|
|
||||||
cls.services["template"]["ostype"] = cls.services["ostype"]
|
cls.services["template"]["ostype"] = cls.services["ostype"]
|
||||||
#Create templates for Edit, Delete & update permissions testcases
|
cls.services["template"]["ispublic"] = True
|
||||||
|
# Create templates for Edit, Delete & update permissions testcases
|
||||||
cls.pw_enabled_template = Template.create(
|
cls.pw_enabled_template = Template.create(
|
||||||
cls.api_client,
|
cls.api_client,
|
||||||
cls.services["template"],
|
cls.services["template"],
|
||||||
@ -237,11 +254,18 @@ class TestVMPasswordEnabled(cloudstackTestCase):
|
|||||||
self.cleanup = []
|
self.cleanup = []
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
#Clean up, terminate the created instances
|
# Clean up, terminate the created instances
|
||||||
cleanup_resources(self.apiclient, self.cleanup)
|
cleanup_resources(self.apiclient, self.cleanup)
|
||||||
return
|
return
|
||||||
|
|
||||||
@attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg"], required_hardware="true")
|
@attr(
|
||||||
|
tags=[
|
||||||
|
"advanced",
|
||||||
|
"advancedns",
|
||||||
|
"smoke",
|
||||||
|
"basic",
|
||||||
|
"sg"],
|
||||||
|
required_hardware="true")
|
||||||
def test_11_get_vm_password(self):
|
def test_11_get_vm_password(self):
|
||||||
"""Test get VM password for password enabled template"""
|
"""Test get VM password for password enabled template"""
|
||||||
|
|
||||||
@ -255,9 +279,6 @@ class TestVMPasswordEnabled(cloudstackTestCase):
|
|||||||
self.debug("Stopping VM: %s" % self.vm.name)
|
self.debug("Stopping VM: %s" % self.vm.name)
|
||||||
self.vm.stop(self.apiclient)
|
self.vm.stop(self.apiclient)
|
||||||
|
|
||||||
# Sleep to ensure VM is stopped properly
|
|
||||||
time.sleep(self.services["sleep"])
|
|
||||||
|
|
||||||
self.debug("Resetting VM password for VM: %s" % self.vm.name)
|
self.debug("Resetting VM password for VM: %s" % self.vm.name)
|
||||||
password = self.vm.resetPassword(self.apiclient)
|
password = self.vm.resetPassword(self.apiclient)
|
||||||
self.debug("Password reset to: %s" % password)
|
self.debug("Password reset to: %s" % password)
|
||||||
@ -282,7 +303,8 @@ class TestVMPasswordEnabled(cloudstackTestCase):
|
|||||||
try:
|
try:
|
||||||
self.debug("SSHing into VM: %s" % self.vm.ssh_ip)
|
self.debug("SSHing into VM: %s" % self.vm.ssh_ip)
|
||||||
self.vm.password = password
|
self.vm.password = password
|
||||||
ssh = self.vm.get_ssh_client()
|
self.vm.get_ssh_client()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.fail("SSH into VM: %s failed" % self.vm.ssh_ip)
|
self.fail("SSH into VM: %s failed: %s" %
|
||||||
|
(self.vm.ssh_ip, e))
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user