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>
This commit is contained in:
Jose Perez Carranza 2019-09-01 14:21:24 -05:00
parent 8da6f67057
commit bc0efc1806
7 changed files with 61 additions and 71 deletions

View File

@ -380,9 +380,9 @@ def grub_checker(iso, mode, grub_option, grub_cmd):
diff = [ diff = [
element for element in iso_boot_line element for element in iso_boot_line
if element not in grub_cmd.split()] 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: for element in diff:
LOG.warn(element) LOG.warning(element)
elif mode == 'uefi': elif mode == 'uefi':
raise NotImplementedError raise NotImplementedError
@ -395,6 +395,7 @@ def grub_checker(iso, mode, grub_option, grub_cmd):
return status return status
def get_controllers_ip(env, config_file, config_type, lab_file): def get_controllers_ip(env, config_file, config_type, lab_file):
"""Get IPs of the controllers from the specific stx configuration file """Get IPs of the controllers from the specific stx configuration file

View File

@ -66,7 +66,7 @@ class Installer(object):
_pid.suspend() _pid.suspend()
_pid.resume() _pid.resume()
except subprocess.CalledProcessError: 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( os.system('{term} -geometry {geo} -T {title} -e {cmd} &'.format(
term=terminal, geo=geometry, title=terminal_title, cmd=command)) term=terminal, geo=geometry, title=terminal_title, cmd=command))
@ -85,7 +85,7 @@ class Installer(object):
self.child.expect('boot:') self.child.expect('boot:')
cmd_boot_line = common.get_cmd_boot_line() cmd_boot_line = common.get_cmd_boot_line()
self.child.sendline(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 # send a enter character
self.child.sendline('\r') self.child.sendline('\r')
# setting a boot timeout # setting a boot timeout

View File

@ -30,8 +30,8 @@ PROMPT = '$'
# Setup the logger # Setup the logger
LOG_FILENAME = 'iso_setup_baremetal.log' LOG_FILENAME = 'iso_setup_baremetal.log'
LOG_PATH = config.get('general', 'LOG_PATH') LOG_PATH = config.get('general', 'LOG_PATH')
LOG = logger.setup_logging('iso_setup_baremetal', log_file='{path}/{filename}' LOG = logger.setup_logging('iso_setup_baremetal', log_file=('%s/%s', LOG_PATH,
.format(path=LOG_PATH, filename=LOG_FILENAME), LOG_FILENAME),
console_log=False) console_log=False)
@ -52,15 +52,14 @@ class PxeServer(object):
tmp_mnt_point = '/tmp' tmp_mnt_point = '/tmp'
if os.listdir(mount_point): if os.listdir(mount_point):
LOG.info('{} is busy umounting'.format(mount_point)) LOG.info('%s is busy umounting', mount_point)
umounting_attempts = 3 umounting_attempts = 3
while umounting_attempts > 0: while umounting_attempts > 0:
umounting = bash('sudo umount -l {}'.format(mount_point)) umounting = bash('sudo umount -l {}'.format(mount_point))
if umounting.stderr and umounting_attempts: if umounting.stderr and umounting_attempts:
LOG.info('Failed to umount {}, retrying...'.format( LOG.info('Failed to umount %s, retrying...', mount_point)
mount_point))
elif umounting.stderr and not umounting_attempts: elif umounting.stderr and not umounting_attempts:
LOG.info('Max umounting attempts reached, leaving ' LOG.info('Max umounting attempts reached, leaving '
'installation') 'installation')
@ -71,17 +70,17 @@ class PxeServer(object):
umounting_attempts -= 1 umounting_attempts -= 1
bash('sudo mount {0} {1}'.format(self.iso_path, mount_point)) 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)): if isdir(os.path.join(http_mnt_point, self.iso_name)):
LOG.info('Folder {0}/{1} already exists in http server, deleting ' LOG.info('Folder %s/%s already exists in http server, deleting '
'it.'.format(http_mnt_point, self.iso_name)) 'it.', http_mnt_point, self.iso_name)
rmtree(os.path.join(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)) copytree(mount_point, os.path.join(http_mnt_point, self.iso_name))
if isdir(os.path.join(tmp_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 ' LOG.info('Folder %s/%s already exists in http server, deleting '
'it.'.format(tmp_mnt_point, self.iso_name)) 'it.', tmp_mnt_point, self.iso_name)
rmtree(os.path.join(tmp_mnt_point, self.iso_name)) rmtree(os.path.join(tmp_mnt_point, self.iso_name))
# Changing from RPM to CPIO format # Changing from RPM to CPIO format
@ -124,8 +123,7 @@ class PxeServer(object):
images_dir = os.path.join(self.tftp_dir, 'images') images_dir = os.path.join(self.tftp_dir, 'images')
if isdir(images_dir): if isdir(images_dir):
LOG.info('{} already exists, deleting directory.'.format( LOG.info('%s already exists, deleting directory.', images_dir)
images_dir))
rmtree(images_dir) rmtree(images_dir)
LOG.info('Copying vmlinuz and initrd files.') LOG.info('Copying vmlinuz and initrd files.')
@ -145,11 +143,10 @@ class PxeServer(object):
active_service = bash('sudo systemctl is-active {}' active_service = bash('sudo systemctl is-active {}'
.format(service)) .format(service))
if 'active' in active_service.stdout: if 'active' in active_service.stdout:
LOG.info('{} service is active'.format(service)) LOG.info('%s service is active', service)
continue continue
else: else:
LOG.info('{} service is not active, restarting' LOG.info('%s service is not active, restarting', service)
.format(service))
bash('sudo systemctl restart {}'.format(service)) bash('sudo systemctl restart {}'.format(service))
def get_efi_boot_line(self, grub_dict): def get_efi_boot_line(self, grub_dict):
@ -247,19 +244,15 @@ class Node(object):
def boot_server_to_pxe(self): def boot_server_to_pxe(self):
"""Boot the installation target server using PXE server""" """Boot the installation target server using PXE server"""
LOG.info('Booting {} To PXE'.format(self.name)) LOG.info('Booting %s To PXE', self.name)
LOG.info('Node {}: Setting PXE as first boot option' LOG.info('Node %s : Setting PXE as first boot option', self.name)
.format(self.name)) set_pxe = bash('ipmitool -I lanplus -H %s -U %s -P %s '
set_pxe = bash('ipmitool -I lanplus -H {node_bmc_ip} ' 'chassis bootdev pxe', self.bmc_ip, self.bmc_user,
'-U {node_bmc_user} -P {node_bmc_pswd} ' self.bmc_pswd)
'chassis bootdev pxe'.format(
node_bmc_ip=self.bmc_ip,
node_bmc_user=self.bmc_user,
node_bmc_pswd=self.bmc_pswd))
if set_pxe.stderr: if set_pxe.stderr:
LOG.info(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} ' power_status = bash('ipmitool -I lanplus -H {node_bmc_ip} '
'-U {node_bmc_user} -P {node_bmc_pswd} ' '-U {node_bmc_user} -P {node_bmc_pswd} '
'chassis power status'.format( 'chassis power status'.format(
@ -286,7 +279,7 @@ class Node(object):
if power.stderr: if power.stderr:
LOG.info(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} ' kill_sol = bash('ipmitool -I lanplus -H {node_bmc_ip} '
'-U {node_bmc_user} -P {node_bmc_pswd} sol ' '-U {node_bmc_user} -P {node_bmc_pswd} sol '
'deactivate'.format(node_bmc_ip=self.bmc_ip, 'deactivate'.format(node_bmc_ip=self.bmc_ip,
@ -301,7 +294,7 @@ class Node(object):
user_name = config.get('credentials', 'STX_DEPLOY_USER_NAME') user_name = config.get('credentials', 'STX_DEPLOY_USER_NAME')
password = config.get('credentials', 'STX_DEPLOY_USER_PSWD') 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} ' installation = pexpect.spawn(('ipmitool -I lanplus -H {node_bmc_ip} '
'-U {node_bmc_user} -P {node_bmc_pswd} ' '-U {node_bmc_user} -P {node_bmc_pswd} '
'sol activate') 'sol activate')
@ -312,23 +305,23 @@ class Node(object):
LOG_PATH), 'wb') LOG_PATH), 'wb')
installation.timeout = int(config.get('iso_installer', 'BOOT_TIMEOUT')) installation.timeout = int(config.get('iso_installer', 'BOOT_TIMEOUT'))
installation.expect('Start PXE over IPv4.') 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') 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') 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...') 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') installation.expect('Performing post-installation setup tasks')
LOG.info('Node {}: Performing post-installation setup tasks' LOG.info('Node %s: Performing post-installation setup tasks',
.format(self.name)) self.name)
installation.expect('login:') installation.expect('login:')
LOG.info('Node {}: the system boot up correctly'.format(self.name)) LOG.info('Node %s: the system boot up correctly', self.name)
LOG.info('Node {}: logging into the system'.format(self.name)) LOG.info('Node %s: logging into the system', self.name)
installation.sendline(user_name) installation.sendline(user_name)
installation.expect('Password:') installation.expect('Password:')
installation.sendline(user_name) 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.expect('UNIX password:')
installation.sendline(user_name) installation.sendline(user_name)
installation.expect('New password:') installation.expect('New password:')
@ -336,11 +329,10 @@ class Node(object):
installation.expect('Retype new password:') installation.expect('Retype new password:')
installation.sendline(password) installation.sendline(password)
installation.expect('$') installation.expect('$')
LOG.info('Node {}: the password was changed successfully' LOG.info('Node %s: the password was changed successfully', self.name)
.format(self.name))
installation.close() installation.close()
LOG.info('Node {}: Closing SOL session after successfully installation' LOG.info('Node %s: Closing SOL session after successfully '
.format(self.name)) 'installation', self.name)
deactivate_sol = bash(('ipmitool -I lanplus -H {node_bmc_ip} ' deactivate_sol = bash(('ipmitool -I lanplus -H {node_bmc_ip} '
'-U {node_bmc_user} -P {node_bmc_pswd} ' '-U {node_bmc_user} -P {node_bmc_pswd} '
'sol deactivate') 'sol deactivate')
@ -348,8 +340,7 @@ class Node(object):
node_bmc_user=self.bmc_user, node_bmc_user=self.bmc_user,
node_bmc_pswd=self.bmc_pswd)) node_bmc_pswd=self.bmc_pswd))
if not deactivate_sol.stderr: if not deactivate_sol.stderr:
LOG.info('Node {}: SOL session closed successfully' LOG.info('Node %s: SOL session closed successfully', self.name)
.format(self.name))
def analyze_grub(grub_cfg_file): def analyze_grub(grub_cfg_file):
@ -458,8 +449,8 @@ def config_controller(config_file):
configuring_controller.sendline('\r') configuring_controller.sendline('\r')
configuring_controller.expect(PROMPT) configuring_controller.expect(PROMPT)
LOG.info('Applying configuration (this will take several minutes)') LOG.info('Applying configuration (this will take several minutes)')
configuring_controller.sendline('sudo config_controller --force --config-file {}' configuring_controller.sendline(
.format(config_file)) 'sudo config_controller --force --config-file {}'.format(config_file))
configuring_controller.timeout = config_controller_timeout configuring_controller.timeout = config_controller_timeout
configuring_controller.expect('Configuration was applied') configuring_controller.expect('Configuration was applied')
LOG.info(configuring_controller.before) LOG.info(configuring_controller.before)
@ -515,7 +506,7 @@ def install_secondary_nodes():
for nodes_instance in nodes_instances: for nodes_instance in nodes_instances:
thread = threading.Thread( thread = threading.Thread(
target=nodes_instance.follow_node_installation()) 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() thread.start()
node_installation_threads.append(thread) node_installation_threads.append(thread)

View File

@ -263,8 +263,8 @@ def check_system_resources(configurations):
# order to avoid the following error: # order to avoid the following error:
# error: XML error: Invalid CPU topology # error: XML error: Invalid CPU topology
if controller_system_cores < 1: if controller_system_cores < 1:
LOG.error('{}: must have assigned at least 1 core'.format( LOG.error('%s: must have assigned at least 1 core',
current_controller)) current_controller)
exit_dict_status(1) exit_dict_status(1)
# checking how many computes the current controller has # checking how many computes the current controller has
@ -299,8 +299,8 @@ def check_system_resources(configurations):
# order to avoid the following error: # order to avoid the following error:
# error: XML error: Invalid CPU topology # error: XML error: Invalid CPU topology
if compute_system_cores < 1: if compute_system_cores < 1:
LOG.error('{}: must have assigned at least 1 core'.format( LOG.error('%s: must have assigned at least 1 core',
current_compute)) current_compute)
exit_dict_status(1) exit_dict_status(1)
# increasing the variables (computes loop) # increasing the variables (computes loop)
@ -324,28 +324,26 @@ def check_system_resources(configurations):
LOG.error( LOG.error(
'the memory defined in the yaml is greater than the recommended ' 'the memory defined in the yaml is greater than the recommended '
'free memory') 'free memory')
LOG.error('user memory defined : {}'.format( LOG.error('user memory defined : %s',
user_memory_defined)) user_memory_defined)
LOG.error('recommended system free memory : {}'.format( LOG.error('recommended system free memory : %s',
recommended_system_free_memory)) recommended_system_free_memory)
exit_dict_status(1) exit_dict_status(1)
elif user_disk_space_defined > r_system_free_disk_size: elif user_disk_space_defined > r_system_free_disk_size:
LOG.error( LOG.error(
'the disk space defined in the yaml is greater than the ' 'the disk space defined in the yaml is greater than the '
'recommended free disk size') 'recommended free disk size')
LOG.error('user disk space defined : {}'.format( LOG.error('user disk space defined : %s',
user_disk_space_defined)) user_disk_space_defined)
LOG.error('recommended system free disk size : {}'.format( LOG.error('recommended system free disk size : %s',
r_system_free_disk_size)) r_system_free_disk_size)
exit_dict_status(1) exit_dict_status(1)
elif user_system_cores_defined > recommended_system_cores: elif user_system_cores_defined > recommended_system_cores:
LOG.error( LOG.error(
'the system cores defined in the yaml is greater than the ' 'the system cores defined in the yaml is greater than the '
'recommended system cores') 'recommended system cores')
LOG.error('user system cores defined : {}'.format( LOG.error('user system cores defined : %s', user_system_cores_defined)
user_system_cores_defined)) LOG.error('recommended system cores : %s', recommended_system_cores)
LOG.error('recommended system cores : {}'.format(
recommended_system_cores))
exit_dict_status(1) exit_dict_status(1)

View File

@ -34,7 +34,7 @@ def delete_network_interfaces():
bash('sudo virsh net-destroy {}'.format('stx-nat')) bash('sudo virsh net-destroy {}'.format('stx-nat'))
bash('sudo virsh net-undefine {}'.format('stx-nat')) bash('sudo virsh net-undefine {}'.format('stx-nat'))
except IOError: except IOError:
LOG.warn('NAT network not found') LOG.warning('NAT network not found')
for interface in range(1, 5): for interface in range(1, 5):
current_interface = 'stxbr{}'.format(interface) current_interface = 'stxbr{}'.format(interface)
@ -52,8 +52,8 @@ def delete_network_interfaces():
ifconfig.Interface(current_interface).down() ifconfig.Interface(current_interface).down()
brctl.Bridge(current_interface).delete() brctl.Bridge(current_interface).delete()
except IOError: except IOError:
LOG.warn('[Errno 19] No such device: {}'.format( LOG.warning('[Errno 19] No such device: '
current_interface)) '%s', current_interface)
def configure_network_interfaces(): def configure_network_interfaces():
@ -68,7 +68,7 @@ def configure_network_interfaces():
try: try:
brctl.addbr(current_interface) brctl.addbr(current_interface)
except IOError: 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', networks = ['stxbr1 10.10.10.1/24', 'stxbr2 192.168.204.1/24',
'stxbr3', 'stxbr4'] 'stxbr3', 'stxbr4']

View File

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

View File

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