Browse Source

Add robot suite directory to be verified by pylint

Add automated-robot-suite to tox.ini file in order to apply pylint
validation to the suite directory.

Change-Id: I34ba7fecb10f115813e731f5344fbadf5bf7996c
Signed-off-by: Jose Perez Carranza <jose.perez.carranza@intel.com>
tags/v3.0.0.rc0
Jose Perez Carranza 5 months ago
parent
commit
bc0efc1806
7 changed files with 61 additions and 71 deletions
  1. +3
    -2
      automated-robot-suite/Libraries/common.py
  2. +2
    -2
      automated-robot-suite/Libraries/iso_setup.py
  3. +36
    -45
      automated-robot-suite/Libraries/pxe_server.py
  4. +14
    -16
      automated-robot-suite/Qemu/qemu_setup.py
  5. +4
    -4
      automated-robot-suite/Utils/network.py
  6. +1
    -1
      pylint.rc
  7. +1
    -1
      tox.ini

+ 3
- 2
automated-robot-suite/Libraries/common.py View File

@@ -380,9 +380,9 @@ def grub_checker(iso, mode, grub_option, grub_cmd):
diff = [
element for element in iso_boot_line
if element not in grub_cmd.split()]
LOG.warn('missed params from cmd grub line')
LOG.warning('missed params from cmd grub line')
for element in diff:
LOG.warn(element)
LOG.warning(element)

elif mode == 'uefi':
raise NotImplementedError
@@ -395,6 +395,7 @@ def grub_checker(iso, mode, grub_option, grub_cmd):

return status


def get_controllers_ip(env, config_file, config_type, lab_file):
"""Get IPs of the controllers from the specific stx configuration file


+ 2
- 2
automated-robot-suite/Libraries/iso_setup.py View File

@@ -66,7 +66,7 @@ class Installer(object):
_pid.suspend()
_pid.resume()
except subprocess.CalledProcessError:
LOG.info('There is not process for : {}'.format(terminal))
LOG.info('There is not process for : %s', terminal)

os.system('{term} -geometry {geo} -T {title} -e {cmd} &'.format(
term=terminal, geo=geometry, title=terminal_title, cmd=command))
@@ -85,7 +85,7 @@ class Installer(object):
self.child.expect('boot:')
cmd_boot_line = common.get_cmd_boot_line()
self.child.sendline(cmd_boot_line)
LOG.info('kernel command line sent: {}'.format(cmd_boot_line))
LOG.info('kernel command line sent: %s', cmd_boot_line)
# send a enter character
self.child.sendline('\r')
# setting a boot timeout

+ 36
- 45
automated-robot-suite/Libraries/pxe_server.py View File

@@ -30,8 +30,8 @@ PROMPT = '$'
# Setup the logger
LOG_FILENAME = 'iso_setup_baremetal.log'
LOG_PATH = config.get('general', 'LOG_PATH')
LOG = logger.setup_logging('iso_setup_baremetal', log_file='{path}/{filename}'
.format(path=LOG_PATH, filename=LOG_FILENAME),
LOG = logger.setup_logging('iso_setup_baremetal', log_file=('%s/%s', LOG_PATH,
LOG_FILENAME),
console_log=False)


@@ -52,15 +52,14 @@ class PxeServer(object):
tmp_mnt_point = '/tmp'

if os.listdir(mount_point):
LOG.info('{} is busy umounting'.format(mount_point))
LOG.info('%s is busy umounting', mount_point)
umounting_attempts = 3

while umounting_attempts > 0:
umounting = bash('sudo umount -l {}'.format(mount_point))

if umounting.stderr and umounting_attempts:
LOG.info('Failed to umount {}, retrying...'.format(
mount_point))
LOG.info('Failed to umount %s, retrying...', mount_point)
elif umounting.stderr and not umounting_attempts:
LOG.info('Max umounting attempts reached, leaving '
'installation')
@@ -71,17 +70,17 @@ class PxeServer(object):
umounting_attempts -= 1

bash('sudo mount {0} {1}'.format(self.iso_path, mount_point))
LOG.info('Mounting ISO on {}'.format(mount_point))
LOG.info('Mounting ISO on %s', mount_point)

if isdir(os.path.join(http_mnt_point, self.iso_name)):
LOG.info('Folder {0}/{1} already exists in http server, deleting '
'it.'.format(http_mnt_point, self.iso_name))
LOG.info('Folder %s/%s already exists in http server, deleting '
'it.', http_mnt_point, self.iso_name)
rmtree(os.path.join(http_mnt_point, self.iso_name))
copytree(mount_point, os.path.join(http_mnt_point, self.iso_name))

if isdir(os.path.join(tmp_mnt_point, self.iso_name)):
LOG.info('Folder {0}/{1} already exists in http server, deleting '
'it.'.format(tmp_mnt_point, self.iso_name))
LOG.info('Folder %s/%s already exists in http server, deleting '
'it.', tmp_mnt_point, self.iso_name)
rmtree(os.path.join(tmp_mnt_point, self.iso_name))

# Changing from RPM to CPIO format
@@ -124,8 +123,7 @@ class PxeServer(object):
images_dir = os.path.join(self.tftp_dir, 'images')

if isdir(images_dir):
LOG.info('{} already exists, deleting directory.'.format(
images_dir))
LOG.info('%s already exists, deleting directory.', images_dir)
rmtree(images_dir)

LOG.info('Copying vmlinuz and initrd files.')
@@ -145,11 +143,10 @@ class PxeServer(object):
active_service = bash('sudo systemctl is-active {}'
.format(service))
if 'active' in active_service.stdout:
LOG.info('{} service is active'.format(service))
LOG.info('%s service is active', service)
continue
else:
LOG.info('{} service is not active, restarting'
.format(service))
LOG.info('%s service is not active, restarting', service)
bash('sudo systemctl restart {}'.format(service))

def get_efi_boot_line(self, grub_dict):
@@ -247,19 +244,15 @@ class Node(object):
def boot_server_to_pxe(self):
"""Boot the installation target server using PXE server"""

LOG.info('Booting {} To PXE'.format(self.name))
LOG.info('Node {}: Setting PXE as first boot option'
.format(self.name))
set_pxe = bash('ipmitool -I lanplus -H {node_bmc_ip} '
'-U {node_bmc_user} -P {node_bmc_pswd} '
'chassis bootdev pxe'.format(
node_bmc_ip=self.bmc_ip,
node_bmc_user=self.bmc_user,
node_bmc_pswd=self.bmc_pswd))
LOG.info('Booting %s To PXE', self.name)
LOG.info('Node %s : Setting PXE as first boot option', self.name)
set_pxe = bash('ipmitool -I lanplus -H %s -U %s -P %s '
'chassis bootdev pxe', self.bmc_ip, self.bmc_user,
self.bmc_pswd)
if set_pxe.stderr:
LOG.info(set_pxe.stderr)

LOG.info('Node {}: Resetting target.'.format(self.name))
LOG.info('Node %s : Resetting target.', self.name)
power_status = bash('ipmitool -I lanplus -H {node_bmc_ip} '
'-U {node_bmc_user} -P {node_bmc_pswd} '
'chassis power status'.format(
@@ -286,7 +279,7 @@ class Node(object):
if power.stderr:
LOG.info(power.stderr)

LOG.info('Node {}: Deactivating sol sessions.'.format(self.name))
LOG.info('Node %s: Deactivating sol sessions.', self.name)
kill_sol = bash('ipmitool -I lanplus -H {node_bmc_ip} '
'-U {node_bmc_user} -P {node_bmc_pswd} sol '
'deactivate'.format(node_bmc_ip=self.bmc_ip,
@@ -301,7 +294,7 @@ class Node(object):
user_name = config.get('credentials', 'STX_DEPLOY_USER_NAME')
password = config.get('credentials', 'STX_DEPLOY_USER_PSWD')

LOG.info('Node {}: Following node installation.'.format(self.name))
LOG.info('Node %s: Following node installation.', self.name)
installation = pexpect.spawn(('ipmitool -I lanplus -H {node_bmc_ip} '
'-U {node_bmc_user} -P {node_bmc_pswd} '
'sol activate')
@@ -312,23 +305,23 @@ class Node(object):
LOG_PATH), 'wb')
installation.timeout = int(config.get('iso_installer', 'BOOT_TIMEOUT'))
installation.expect('Start PXE over IPv4.')
LOG.info('Node {}: Trying to boot using PXE'.format(self.name))
LOG.info('Node %s: Trying to boot using PXE', self.name)
installation.expect('Linux version')
LOG.info('Node {}: Loading Linux Kernel'.format(self.name))
LOG.info('Node %s: Loading Linux Kernel', self.name)
installation.expect('Welcome to')
LOG.info('Node {}: CentOS have been loaded'.format(self.name))
LOG.info('Node %s: CentOS have been loaded', self.name)
installation.expect('Starting installer, one moment...')
LOG.info('Node {}: Starting installer ...'.format(self.name))
LOG.info('Node %s: Starting installer ...', self.name)
installation.expect('Performing post-installation setup tasks')
LOG.info('Node {}: Performing post-installation setup tasks'
.format(self.name))
LOG.info('Node %s: Performing post-installation setup tasks',
self.name)
installation.expect('login:')
LOG.info('Node {}: the system boot up correctly'.format(self.name))
LOG.info('Node {}: logging into the system'.format(self.name))
LOG.info('Node %s: the system boot up correctly', self.name)
LOG.info('Node %s: logging into the system', self.name)
installation.sendline(user_name)
installation.expect('Password:')
installation.sendline(user_name)
LOG.info('Node {}: setting a new password'.format(self.name))
LOG.info('Node %s: setting a new password', self.name)
installation.expect('UNIX password:')
installation.sendline(user_name)
installation.expect('New password:')
@@ -336,11 +329,10 @@ class Node(object):
installation.expect('Retype new password:')
installation.sendline(password)
installation.expect('$')
LOG.info('Node {}: the password was changed successfully'
.format(self.name))
LOG.info('Node %s: the password was changed successfully', self.name)
installation.close()
LOG.info('Node {}: Closing SOL session after successfully installation'
.format(self.name))
LOG.info('Node %s: Closing SOL session after successfully '
'installation', self.name)
deactivate_sol = bash(('ipmitool -I lanplus -H {node_bmc_ip} '
'-U {node_bmc_user} -P {node_bmc_pswd} '
'sol deactivate')
@@ -348,8 +340,7 @@ class Node(object):
node_bmc_user=self.bmc_user,
node_bmc_pswd=self.bmc_pswd))
if not deactivate_sol.stderr:
LOG.info('Node {}: SOL session closed successfully'
.format(self.name))
LOG.info('Node %s: SOL session closed successfully', self.name)


def analyze_grub(grub_cfg_file):
@@ -458,8 +449,8 @@ def config_controller(config_file):
configuring_controller.sendline('\r')
configuring_controller.expect(PROMPT)
LOG.info('Applying configuration (this will take several minutes)')
configuring_controller.sendline('sudo config_controller --force --config-file {}'
.format(config_file))
configuring_controller.sendline(
'sudo config_controller --force --config-file {}'.format(config_file))
configuring_controller.timeout = config_controller_timeout
configuring_controller.expect('Configuration was applied')
LOG.info(configuring_controller.before)
@@ -515,7 +506,7 @@ def install_secondary_nodes():
for nodes_instance in nodes_instances:
thread = threading.Thread(
target=nodes_instance.follow_node_installation())
LOG.info('Starting installation on {}'.format(nodes_instance.name))
LOG.info('Starting installation on %s', nodes_instance.name)
thread.start()
node_installation_threads.append(thread)


+ 14
- 16
automated-robot-suite/Qemu/qemu_setup.py View File

@@ -263,8 +263,8 @@ def check_system_resources(configurations):
# order to avoid the following error:
# error: XML error: Invalid CPU topology
if controller_system_cores < 1:
LOG.error('{}: must have assigned at least 1 core'.format(
current_controller))
LOG.error('%s: must have assigned at least 1 core',
current_controller)
exit_dict_status(1)

# checking how many computes the current controller has
@@ -299,8 +299,8 @@ def check_system_resources(configurations):
# order to avoid the following error:
# error: XML error: Invalid CPU topology
if compute_system_cores < 1:
LOG.error('{}: must have assigned at least 1 core'.format(
current_compute))
LOG.error('%s: must have assigned at least 1 core',
current_compute)
exit_dict_status(1)

# increasing the variables (computes loop)
@@ -324,28 +324,26 @@ def check_system_resources(configurations):
LOG.error(
'the memory defined in the yaml is greater than the recommended '
'free memory')
LOG.error('user memory defined : {}'.format(
user_memory_defined))
LOG.error('recommended system free memory : {}'.format(
recommended_system_free_memory))
LOG.error('user memory defined : %s',
user_memory_defined)
LOG.error('recommended system free memory : %s',
recommended_system_free_memory)
exit_dict_status(1)
elif user_disk_space_defined > r_system_free_disk_size:
LOG.error(
'the disk space defined in the yaml is greater than the '
'recommended free disk size')
LOG.error('user disk space defined : {}'.format(
user_disk_space_defined))
LOG.error('recommended system free disk size : {}'.format(
r_system_free_disk_size))
LOG.error('user disk space defined : %s',
user_disk_space_defined)
LOG.error('recommended system free disk size : %s',
r_system_free_disk_size)
exit_dict_status(1)
elif user_system_cores_defined > recommended_system_cores:
LOG.error(
'the system cores defined in the yaml is greater than the '
'recommended system cores')
LOG.error('user system cores defined : {}'.format(
user_system_cores_defined))
LOG.error('recommended system cores : {}'.format(
recommended_system_cores))
LOG.error('user system cores defined : %s', user_system_cores_defined)
LOG.error('recommended system cores : %s', recommended_system_cores)
exit_dict_status(1)



+ 4
- 4
automated-robot-suite/Utils/network.py View File

@@ -34,7 +34,7 @@ def delete_network_interfaces():
bash('sudo virsh net-destroy {}'.format('stx-nat'))
bash('sudo virsh net-undefine {}'.format('stx-nat'))
except IOError:
LOG.warn('NAT network not found')
LOG.warning('NAT network not found')

for interface in range(1, 5):
current_interface = 'stxbr{}'.format(interface)
@@ -52,8 +52,8 @@ def delete_network_interfaces():
ifconfig.Interface(current_interface).down()
brctl.Bridge(current_interface).delete()
except IOError:
LOG.warn('[Errno 19] No such device: {}'.format(
current_interface))
LOG.warning('[Errno 19] No such device: '
'%s', current_interface)


def configure_network_interfaces():
@@ -68,7 +68,7 @@ def configure_network_interfaces():
try:
brctl.addbr(current_interface)
except IOError:
LOG.warn('[Errno 17] File exists {}'.format(current_interface))
LOG.warning('[Errno 17] File exists %s', current_interface)

networks = ['stxbr1 10.10.10.1/24', 'stxbr2 192.168.204.1/24',
'stxbr3', 'stxbr4']

+ 1
- 1
pylint.rc View File

@@ -73,7 +73,7 @@ disable=C,R,
W0601,W0603,W0611,W0612,W0613,W0621,W0622,W0632,
W0702,W0703,W0706,
W1113,W1302,W1308,W1401,
E0102,E0401,E0611,E0711,E1102,E1120,E1305
E0102,E0401,E0611,E0711,E1102,E1120,E1136,E1305


[REPORTS]

+ 1
- 1
tox.ini View File

@@ -33,7 +33,7 @@ commands =
[testenv:pylint]
basepython = python3
recreate = True
commands = pylint --rcfile=pylint.rc automated-pytest-suite
commands = pylint --rcfile=pylint.rc automated-pytest-suite automated-robot-suite

[testenv:pep8]
basepython = python3

Loading…
Cancel
Save