def tdd(): tdd1() # save results of the tdds in a list results = list() res = myLib.database_check('glance') results.append(res) res = myLib.keystone_check('glance') results.append(res) res = imageCreationTDD() results.append(res) # check if any of the functions failed # and set status accordingly if any([r == 'FAIL' for r in results]): status = 'bad' else: status = 'good' # save config files confFile = "/etc/glance/glance-api.conf" saveConfigFile(confFile, status) confFile = "/etc/glance/glance-registry.conf" saveConfigFile(confFile, status)
def tdd(): if database_check('neutron') == 'FAIL' or keystone_check('neutron') == 'FAIL': execute(saveConfigController,'bad') sys.exit(1) execute(controllerTDD) execute(networkTDD) execute(computeTDD) execute(createInitialNetworkTDD) # if all TDDs passed, save config files as 'good' execute(saveConfigController,'good') execute(saveConfigNetwork,'good') execute(saveConfigCompute,'good')
def tdd(): if database_check('neutron') == 'FAIL' or keystone_check( 'neutron') == 'FAIL': execute(saveConfigController, 'bad') sys.exit(1) execute(controllerTDD) execute(networkTDD) execute(computeTDD) execute(createInitialNetworkTDD) # if all TDDs passed, save config files as 'good' execute(saveConfigController, 'good') execute(saveConfigNetwork, 'good') execute(saveConfigCompute, 'good')
def tdd(): res = database_check('nova') if res == 'FAIL': saveConfigFile(etc_nova_config_file, 'bad') sys.exit(1) res = keystone_check('nova') if res == 'FAIL': saveConfigFile(etc_nova_config_file, 'bad') sys.exit(1) execute(servicesTDD) execute(imageTDD) # if all TDDs passed, save config files as 'good' saveConfigFile(etc_nova_config_file, 'good')
def tdd(): # status is initialized as 'good' # if any of the tdd functions gets an error, # it changes the value to 'bad' status = 'good' with settings(warn_only=True): res = keystone_check('heat') if res != 'OK': status = 'bad' res = database_check('heat') if res != 'OK': status = 'bad' create_stack() # save config file saveConfigFile(etc_heat_config_file, status)
def keystone_tdd(): with settings(warn_only=True): status = 'good' resk = keystone_check('keystone') resd = database_check('keystone') if (resk == 'FAIL') or (resd == 'FAIL'): status = 'bad' # Check if 'admin' and 'demo' are users user_list_output = run("keystone --os-tenant-name admin --os-username admin " + \ "--os-password {} --os-auth-url http://controller:35357/v2.0 user-list"\ .format(passwd['ADMIN_PASS']), quiet=True) if 'admin' in user_list_output: print align_y('Admin was found in user list') else: print align_n('admin not a user') status = 'bad' if 'demo' in user_list_output: print align_y('Demo was found in user list') else: print align_n('demo not a user') status = 'bad' # Check if 'admin', 'service' and 'demo' are tenants tenant_list_output = run("keystone --os-tenant-name admin --os-username admin " + \ "--os-password {} --os-auth-url http://controller:35357/v2.0 tenant-list"\ .format(passwd['ADMIN_PASS']), quiet=True) for name in ['admin', 'demo', 'service']: if name in tenant_list_output: print align_y('{} was found in tenant list'.format(name)) else: print align_n('{} not a tenant'.format(name)) status = 'bad' # Check if '_member_' and 'admin' are roles role_list_output = run("keystone --os-tenant-name admin --os-username admin " + \ "--os-password {} --os-auth-url http://controller:35357/v2.0 role-list"\ .format(passwd['ADMIN_PASS']), quiet=True) if '_member_' in role_list_output: print align_y('_member_ is a role') else: print align_n('_member_ not a role') status = 'bad' if 'admin' in role_list_output: print align_y('admin is a role') else: print align_n('admin not a role') status = 'bad' # Check if non-admin user is forbidden to perform admin tasks user_list_output = run("keystone --os-tenant-name demo --os-username demo " + \ "--os-password {} --os-auth-url http://controller:35357/v2.0 user-list"\ .format(passwd['DEMO_PASS']), quiet=True) if 'You are not authorized to perform the requested action' in user_list_output: print align_y('demo was not allowed to run user-list') else: print align_n('demo was allowed to run user-list') status = 'bad' confFile = '/etc/keystone/keystone.conf' saveConfigFile(confFile, status) print blue('\nCalling openstack-status\n###########################\n') run('openstack-status')
def keystone_tdd(): with settings(warn_only=True): status = 'good' resk = keystone_check('keystone') resd = database_check('keystone') if (resk == 'FAIL') or (resd == 'FAIL'): status = 'bad' # Check if 'admin' and 'demo' are users user_list_output = run("keystone --os-tenant-name admin --os-username admin " + \ "--os-password {} --os-auth-url http://controller:35357/v2.0 user-list"\ .format(passwd['ADMIN_PASS']), quiet=True) if 'admin' in user_list_output: print align_y('Admin was found in user list') else: print align_n('admin not a user') status = 'bad' if 'demo' in user_list_output: print align_y('Demo was found in user list') else: print align_n('demo not a user') status = 'bad' # Check if 'admin', 'service' and 'demo' are tenants tenant_list_output = run("keystone --os-tenant-name admin --os-username admin " + \ "--os-password {} --os-auth-url http://controller:35357/v2.0 tenant-list"\ .format(passwd['ADMIN_PASS']), quiet=True) for name in ['admin','demo','service']: if name in tenant_list_output: print align_y('{} was found in tenant list'.format(name)) else: print align_n('{} not a tenant'.format(name)) status = 'bad' # Check if '_member_' and 'admin' are roles role_list_output = run("keystone --os-tenant-name admin --os-username admin " + \ "--os-password {} --os-auth-url http://controller:35357/v2.0 role-list"\ .format(passwd['ADMIN_PASS']), quiet=True) if '_member_' in role_list_output: print align_y('_member_ is a role') else: print align_n('_member_ not a role') status = 'bad' if 'admin' in role_list_output: print align_y('admin is a role') else: print align_n('admin not a role') status = 'bad' # Check if non-admin user is forbidden to perform admin tasks user_list_output = run("keystone --os-tenant-name demo --os-username demo " + \ "--os-password {} --os-auth-url http://controller:35357/v2.0 user-list"\ .format(passwd['DEMO_PASS']), quiet=True) if 'You are not authorized to perform the requested action' in user_list_output: print align_y('demo was not allowed to run user-list') else: print align_n('demo was allowed to run user-list') status = 'bad' confFile= '/etc/keystone/keystone.conf' saveConfigFile(confFile,status) print blue('\nCalling openstack-status\n###########################\n') run('openstack-status')