Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions robottelo.properties.sample
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,66 @@ rhel7_repo=http://example.com/yum/repo_files/rhel7-updates.repo
# in other words, the daemon is initialized with `--host tcp://0.0.0.0:<port>`.
external_url=http://localhost:2375

[rhev]
# External RHEV to be added as a compute resource.
# name: Name of the RHEV compute resource
# hostname: RHEV API URL, for example: https://ovirt.example.com/api
# username: Login for RHEVM
# password: Password for RHEVM
# datacenter: RHEVM datacenter, for example: Default
name=
hostname=
username=
password=
datacenter=

# vm_name: Name of VM to power On/Off & delete
vm_name=

# Compute resource image data
# img_name: Chosen name of the image
# img_os: Operating system of the image
# img_arch: Architecture of the image
# img_username: Login to the image
# img_password: Password to the image
# img_image: Image on the external provider
img_name=
img_os=
img_arch=
img_username=
img_password=
img_image=

[vmware]
# External Vmware to be added as a compute resource
# name: Name of the vmware compute resource
# vcenter: vmware vcenter URL
# username: Login for vmware
# password: Password for vmware
# datacenter: vmware datacenter
name=
vcenter=
username=
password=
datacenter=

# vm_name: Name of VM to power On/Off & delete
vm_name=

# Compute resource image data
# img_name: Chosen name of the image
# img_os: Operating system of the image
# img_arch: Architecture of the image
# img_username: Login to the image
# img_password: Password to the image
# img_image: Image on the external provider
img_name=
img_os=
img_arch=
img_username=
img_password=
img_image=

[foreman]
admin.username=admin
admin.password=changeme
Expand Down
127 changes: 123 additions & 4 deletions robottelo/ui/computeresource.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
from robottelo.common.constants import FILTER
from robottelo.ui.base import Base, UINoSuchElementError
from robottelo.ui.base import Base, UINoSuchElementError, UIError
from robottelo.ui.locators import common_locators, locators, tab_locators
from robottelo.ui.navigator import Navigator
from selenium.webdriver.support.select import Select
Expand Down Expand Up @@ -68,8 +68,8 @@ def _configure_resource_provider(
'button'
))
self.click(locators[button_locator])
self.find_element(
locators[param_locator]
Select(
self.find_element(locators[param_locator])
).select_by_visible_text(parameter_value)

def _configure_orgs(self, orgs, org_select):
Expand Down Expand Up @@ -112,7 +112,8 @@ def create(self, name, provider_type, parameter_list,
self._configure_locations(locations, loc_select)
if orgs:
self._configure_orgs(orgs, org_select)
self.click(common_locators['submit'])
#self.click(common_locators['submit'])
self.click(common_locators['submit'], wait_for_ajax=False)

def search(self, name):
"""Searches existing compute resource from UI."""
Expand Down Expand Up @@ -142,10 +143,128 @@ def update(self, name, newname=None, parameter_list=None,

def delete(self, name, really=True):
"""Removes the compute resource entity"""
Navigator(self.browser).go_to_compute_resources()
self.delete_entity(
name,
really,
locators['resource.select_name'],
locators['resource.delete'],
drop_locator=locators['resource.dropdown']
)

def go_to_compute_resource(self, res_name):
""" Navigates to compute resource page """
resource = self.search(res_name)
if resource is None:
raise UINoSuchElementError(
'Could not find the resource {0}'.format(res_name))
strategy, value = locators['resource.get_by_name']
locator = (strategy, value % res_name)
self.click(locator)
self.wait_until_element(locators['resource.virtual_machines_tab'])

def list_vms(self, res_name):
""" Lists vms on compute resource

note: lists only vms that show up on the first page
"""
self.go_to_compute_resource(res_name)
self.click(locators['resource.virtual_machines_tab'])
vms = self.browser.find_elements_by_xpath(
"//table[contains(@id, 'DataTables')]//a[contains(@data-id, '%s')]"
% res_name)
return vms

def add_image(self, res_name, parameter_list):
""" Adds an image to a compute resource """
self.go_to_compute_resource(res_name)
self.click(locators['resource.image.add'])
self.wait_until_element(locators['resource.image.name'])
if parameter_list is None:
return
for parameter_name, parameter_value, parameter_type in parameter_list:
param_locator = '.'.join((
'resource.image',
(parameter_name.lower()).replace(' ', '_')
))
if parameter_type == 'field':
self.find_element(
locators[param_locator]).send_keys(parameter_value)
elif parameter_type == 'select':
Select(
self.find_element(locators[param_locator])
).select_by_visible_text(parameter_value)
self.click(locators['resource.image.submit'])
self.wait_until_element(common_locators['notif.success'])

def list_images(self, res_name):
""" Lists images on compute resource

note: lists only images that show up on the first page
"""
self.go_to_compute_resource(res_name)
self.click(locators['resource.images_tab'])
images = self.browser.find_elements_by_xpath(
"//table[contains(@id, 'DataTables_Table_0')]/tbody/tr/*[1]")
return images

def vm_action_stop(self, res_name, vm_name, really):
""" Stops a vm on the compute resource """
self.go_to_compute_resource(res_name)
self.click(locators['resource.virtual_machines_tab'])
strategy, value = locators['resource.vm.power_button']
locator = (strategy, value % (res_name, vm_name))
button = self.find_element(locator)
if 'Off' in button.text:
self.click(locator, wait_for_ajax=False)
self.handle_alert(really)
#note: this should probably have a timeout
self.wait_until_element(common_locators['notif.success'])
else:
raise UIError(
'Could not stop VM {0}. VM is not running'.format(vm_name)
)

def vm_action_start(self, res_name, vm_name):
""" Starts a vm on the compute resource """
self.go_to_compute_resource(res_name)
self.click(locators['resource.virtual_machines_tab'])
strategy, value = locators['resource.vm.power_button']
locator = (strategy, value % (res_name, vm_name))
button = self.find_element(locator)
if 'On' in button.text:
self.click(locator,wait_for_ajax=False)
#note: this should probably have a timeout
self.wait_until_element(common_locators['notif.success'])
else:
raise UIError(
'Could not start VM {0}. VM is already running'.format(vm_name)
)

def vm_action_toggle(self, res_name, vm_name, really):
""" Toggle power status of a vm on the compute resource """
self.go_to_compute_resource(res_name)
self.click(locators['resource.virtual_machines_tab'])
strategy, value = locators['resource.vm.power_button']
locator = (strategy, value % (res_name, vm_name))
button = self.find_element(locator)
if "On" in button.text:
self.click(locator,wait_for_ajax=False)
self.wait_until_element(common_locators['notif.success'])
else:
self.click(locator, wait_for_ajax=False)
self.handle_alert(really)
self.wait_until_element(common_locators['notif.success'])

def vm_delete(self, res_name, vm_name, really):
""" Removes a vm from the compute resource """
self.go_to_compute_resource(res_name)
self.click(locators['resource.virtual_machines_tab'])
strategy, value = locators['resource.vm.delete_button_dropdown']
locator = (strategy, value % (res_name, vm_name))
self.click(locator)
strategy, value = locators['resource.vm.delete_button']
locator = (strategy, value % (res_name, vm_name))
self.click(locator, wait_for_ajax=False)
self.handle_alert(really)
self.wait_until_element(common_locators['notif.success'])
83 changes: 83 additions & 0 deletions robottelo/ui/locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,9 +817,14 @@ def __iter__(self):
"resource.username": (By.ID, "compute_resource_user"),
"resource.password": (By.ID, "compute_resource_password"),
"resource.datacenter": (By.XPATH, "//select[@id='compute_resource_uuid']"),
"resource.datacenter_vsphere": (By.XPATH, "//select[@id='compute_resource_datacenter']"),
"resource.datacenter.button": (
By.XPATH,
"//a[contains(@data-url, '/compute_resources/test_connection')]"),
"resource.datacenter_vsphere.button": (
By.XPATH,
"//a[contains(@data-url, '/compute_resources/test_connection')]"),

"resource.quota_id": (
By.XPATH, "//select[@id='compute_resource_ovirt_quota']"),
"resource.x509_certification_authorities": (
Expand Down Expand Up @@ -859,6 +864,84 @@ def __iter__(self):
"resource.edit": (
By.XPATH, "//a[contains(@data-id,'edit') and contains(@href,'%s')]"),

# TODO testing locators

"resource.virtual_machines_tab": (
By.XPATH,
"//a[contains(@href, 'vms')]"
),
"resource.images_tab": (
By.XPATH,
#"//a[contains(@href, 'images')]"
#"//a[contains(@text, 'Images')]"
"//a[.='Images']"
),
#TODO this is not used
"resource.virtual_machines": (
By.XPATH,
#"//table[@id='DataTables_Table_0']//a"
#"//table[contains(@id, 'DataTables')]//*[contains(@data-id, 'vms')]"
#"//table[contains(@id, 'DataTables')]/../a"
#"//table[contains(@id, 'DataTables')]/tbody//tr/td/a"
#"//a[contains(@data-id, %s)]"
#"//a[contains(@href, %s)]"
"//a[contains(@href, 'vms')]"
),
"resource.get_by_name": (
By.XPATH,
#"//a[not(contains(@data-id, 'edit')) and contains(@href, '%s')]"
"//a[not(contains(@href, 'search')) and contains(@href, '%s')]"
),
"resource.vm.power_button": (
By.XPATH,
#"//table[contains(@id, 'DataTables')]//a[contains(@data-id, '%s')]/../../*[5]//a"
"//table[contains(@id, 'DataTables')]//a[contains(@data-id, '%s') and .='%s']/../../td[5]//a"
),
"resource.vm.delete_button_dropdown": (
By.XPATH,
"//table[contains(@id, 'DataTables')]//a[contains(@data-id, '%s') and .='%s']/../../td[5]//a[2]"
),
"resource.vm.delete_button": (
By.XPATH,
"//table[contains(@id, 'DataTables')]//a[contains(@data-id, '%s') and .='%s']/../../td[5]//a[.='Delete']"
),
"resource.image.add": (
By.XPATH,
"//a[.='New Image']"
),
"resource.image.name": (
By.ID,
"image_name"
),
"resource.image.operatingsystem": (
By.XPATH,
"//select[@id='image_operatingsystem_id']"
),
"resource.image.architecture": (
By.XPATH,
"//select[@id='image_architecture_id']"
),
"resource.image.username": (
By.ID,
"image_username"
),
"resource.image.password": (
By.ID,
"image_password"
),
"resource.image.image": (
By.XPATH,
"//select[@id='image_uuid']"
),
"resource.image.submit": (
By.XPATH,
"//input[@data-id='aid_create_image']"
),
"resource.image.delete": (
By.XPATH,
""
),

# Hosts

# host.primary
Expand Down
Loading