def test_keypair_add_and_remove_tag(openstack_provider, keypairs): """ This will test whether it will add and remove tag for newly created Keypair or not and then deletes it. Steps: * Provide Keypair name. * Select Cloud Provider. * Add tag to Keypair. * Remove tag from Keypair * Also delete it. """ tag = ('Department', 'Accounting') try: keypair = keypairs.create(fauxfactory.gen_alphanumeric(), openstack_provider) except TimedOutError: if BZ(1444520, forced_streams=['5.6', '5.7', 'upstream']).blocks: pytest.skip('Timed out creating keypair, BZ1444520') else: pytest.fail('Timed out creating keypair') assert keypair.exists keypair.add_tag(tag) tagged_value = mixins.get_tags(tag="My Company Tags") assert tuple(tagged_value[0].split(": ", 1)) == tag, "Add tag failed." keypair.remove_tag(tag) tagged_value1 = mixins.get_tags(tag="My Company Tags") assert tagged_value1 != tagged_value, "Remove tag failed." # Above small conversion in assert statement convert 'tagged_value' in tuple("a","b") and then # compare with tag which is tuple. As get_tags will return assigned tag in list format["a: b"]. keypair.delete(wait=True) assert not keypair.exists
def test_remove_tag(request, provider, provisioning): """Tests object store edit tag Steps: * Click on quadicon. * On the details page, select ``Policy/Edit Tags`` and assign the tag to it. * Select ``Policy/Edit Tags`` and remove the tag. * Verify the tag is not present. """ obj_name = provisioning['cloud_object_store'] cloud_obj = object_store.ObjectStore(name=obj_name) tag = ('Department', 'Accounting') cloud_obj.add_tag(tag, single_value=False) tagged_value1 = mixins.get_tags(tag="My Company Tags") cloud_obj.untag(tag) tagged_value2 = mixins.get_tags(tag="My Company Tags") assert tagged_value1 != tagged_value2, "Remove tag failed"
def test_keypair_add_and_remove_tag(openstack_provider): """ This will test whether it will add and remove tag for newly created Keypair or not and then deletes it. Steps: * Provide Keypair name. * Select Cloud Provider. * Add tag to Keypair. * Remove tag from Keypair * Also delete it. """ tag = ('Department', 'Accounting') keypair = KeyPair(name=fauxfactory.gen_alphanumeric(), provider=openstack_provider) try: keypair.create() except TimedOutError: if BZ(1444520, forced_streams=['5.6', '5.7', 'upstream']).blocks: pytest.skip('Timed out creating keypair, BZ1444520') else: pytest.fail('Timed out creating keypair') assert keypair.exists keypair.add_tag(tag) tagged_value = mixins.get_tags(tag="My Company Tags") assert tuple(tagged_value[0].split(": ", 1)) == tag, "Add tag failed." keypair.remove_tag(tag) tagged_value1 = mixins.get_tags(tag="My Company Tags") assert tagged_value1 != tagged_value, "Remove tag failed." # Above small conversion in assert statement convert 'tagged_value' in tuple("a","b") and then # compare with tag which is tuple. As get_tags will return assigned tag in list format["a: b"]. try: keypair.delete(wait=True) except TimedOutError: openstack_provider.mgmt.api.keypairs.delete(keypair.name) pytest.fail('Timed out deleting keypair') with pytest.raises(KeyPairNotFound): navigate_to(keypair, 'Details')
def get_tags(self, tag="My Company Tags"): self.load_details(refresh=True) tags = [] # Sample out put from UI, [u'Department: Accounting | Engineering', u'Location: London'] for _tag in mixins.get_tags(tag=tag): if _tag == 'No {} have been assigned'.format(tag): return tags _tag = _tag.split(':', 1) if len(_tag) != 2: raise RuntimeError('Unknown format of tagging in UI [{}]'.format(_tag)) if ' | ' in _tag[1]: for _sub_tag in _tag[1].split(' | '): tags.append(Tag(category=Category(display_name=tag[0], single_value=None), display_name=_sub_tag.strip())) else: tags.append(Tag(category=Category(display_name=_tag[0], single_value=None), display_name=_tag[1].strip())) return tags
def tags(self): """Returns a list of this system's active tags""" navigate_to(self, 'EditTags') return mixins.get_tags()
def tags(self): """Returns a list of this system's active tags""" self.navigate() return mixins.get_tags()
def get_tags(self, tag="My Company Tags"): self.load_details(refresh=True) return mixins.get_tags(tag=tag)
def get_tags(self, tag="My Company Tags"): """Returns all tags that are associated with this VM""" self.load_details(refresh=True) return mixins.get_tags(tag)