Skip to content

Commit 9b2addf

Browse files
Ashutosh KGirish Shilamkar
authored andcommitted
CLOUDSTACK-5381: Corrected code related custom host name (vm.instancename)
1 parent c17cf25 commit 9b2addf

1 file changed

Lines changed: 7 additions & 120 deletions

File tree

test/integration/component/test_custom_hostname.py

Lines changed: 7 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,8 @@ def test_01_custom_hostname_instancename_false(self):
631631
# Validate the following
632632
# 1. Set the vm.instancename.flog to false. Hostname and displayname
633633
# should be UUID
634-
# 2. Give the user provided user name. Internal name should be
635-
# i-<userid>-<vmid>-display name
634+
# 2. Give the user provided display name. Internal name should be
635+
# i-<userid>-<vmid>-instance name (It should not contain display name)
636636

637637
if not is_config_suitable(apiclient=self.apiclient, name='vm.instancename.flag', value='false'):
638638
self.skipTest('vm.instancename.flag should be false. skipping')
@@ -665,10 +665,12 @@ def test_01_custom_hostname_instancename_false(self):
665665
"Running",
666666
"Vm state should be running after deployment"
667667
)
668-
self.debug("VM diaplyname: %s" % (vm))
668+
self.debug("vm.displayname: %s, original: %s" %
669+
(vm.displayname,
670+
self.services["virtual_machine"]["displayname"]))
669671
self.assertEqual(
670-
vm.name,
671-
vm.id,
672+
vm.displayname,
673+
self.services["virtual_machine"]["displayname"],
672674
"Vm display name should match the given name"
673675
)
674676

@@ -738,118 +740,3 @@ def test_01_custom_hostname_instancename_false(self):
738740
"VM internal name should match with that of the format"
739741
)
740742
return
741-
742-
@attr(configuration='vm.instancename.flag')
743-
@attr(tags=["advanced", "basic", "sg", "eip", "advancedns", "simulator"])
744-
def test_02_custom_hostname_instancename_false(self):
745-
""" Verify custom hostname for the instance when
746-
vm.instancename.flag=false
747-
"""
748-
749-
# Validate the following
750-
# 1. Set the vm.instancename.flag to false. Hostname and displayname
751-
# should be UUID
752-
# 2. Dont give the user provided user name. Internal name should be
753-
# i-<userid>-<vmid>-instance name
754-
755-
if not is_config_suitable(apiclient=self.apiclient, name='vm.instancename.flag', value='false'):
756-
self.skipTest('vm.instancename.flag should be false. skipping')
757-
758-
self.debug("Deploying VM in account: %s" % self.account.name)
759-
# Spawn an instance in that network
760-
virtual_machine = VirtualMachine.create(
761-
self.apiclient,
762-
self.services["virtual_machine"],
763-
accountid=self.account.name,
764-
domainid=self.account.domainid,
765-
serviceofferingid=self.service_offering.id,
766-
)
767-
self.debug(
768-
"Checking if the virtual machine is created properly or not?")
769-
vms = VirtualMachine.list(
770-
self.apiclient,
771-
id=virtual_machine.id,
772-
listall=True
773-
)
774-
775-
self.assertEqual(
776-
isinstance(vms, list),
777-
True,
778-
"List vms should retuen a valid name"
779-
)
780-
vm = vms[0]
781-
self.assertEqual(
782-
vm.state,
783-
"Running",
784-
"Vm state should be running after deployment"
785-
)
786-
self.assertEqual(
787-
vm.name,
788-
vm.id,
789-
"Vm display name should not match the given name"
790-
)
791-
792-
# Fetch account ID and VMID from database to check internal name
793-
self.debug("select id from account where uuid = '%s';" \
794-
% self.account.id)
795-
796-
qresultset = self.dbclient.execute(
797-
"select id from account where uuid = '%s';" \
798-
% self.account.id
799-
)
800-
self.assertEqual(
801-
isinstance(qresultset, list),
802-
True,
803-
"Check DB query result set for valid data"
804-
)
805-
806-
self.assertNotEqual(
807-
len(qresultset),
808-
0,
809-
"Check DB Query result set"
810-
)
811-
qresult = qresultset[0]
812-
account_id = qresult[0]
813-
814-
self.debug("select id from vm_instance where uuid = '%s';" % vm.id)
815-
816-
qresultset = self.dbclient.execute(
817-
"select id from vm_instance where uuid = '%s';" %
818-
vm.id)
819-
820-
self.assertEqual(
821-
isinstance(qresultset, list),
822-
True,
823-
"Check DB query result set for valid data"
824-
)
825-
826-
self.assertNotEqual(
827-
len(qresultset),
828-
0,
829-
"Check DB Query result set"
830-
)
831-
qresult = qresultset[0]
832-
self.debug("Query result: %s" % qresult)
833-
vmid = qresult[0]
834-
835-
self.debug("Fetching the global config value for instance.name")
836-
configs = Configurations.list(
837-
self.apiclient,
838-
name="instance.name",
839-
listall=True
840-
)
841-
842-
config = configs[0]
843-
instance_name = config.value
844-
self.debug("Instance.name: %s" % instance_name)
845-
846-
#internal Name = i-<user ID>-<VM ID>- Instance_name
847-
#internal_name = "i-" + str(account_id) + "-" + str(vmid) + "-" + instance_name
848-
internal_name = "i-%s-%s-%s" %(str(account_id), str(vmid), instance_name)
849-
self.debug("Internal_name : %s" % internal_name )
850-
self.assertEqual(
851-
vm.instancename,
852-
internal_name,
853-
"VM internal name should match with that of the format"
854-
)
855-
return

0 commit comments

Comments
 (0)