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 imageTDD(): "Run image-list to verify connectivity with Keystone and Glance" with prefix(env_config.admin_openrc): msg = 'Run nova image-list' out = runCheck(msg, 'nova image-list') if 'ACTIVE' not in out: print align_n('No active images') saveConfigFile(etc_nova_config_file, 'bad') sys.exit(1)
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): reach_dashboard() # save config file saveConfigFile(etc_horizon_config_file, status)
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 servicesTDD(): "Check service-list to see if the nova services are up and running" with prefix(env_config.admin_openrc): msg = 'Get service list' serviceList = runCheck(msg, 'nova service-list >service-list') run('cat service-list') servlist = run('cat service-list | grep nova', quiet=True) # check if all services are running allRunning = True for line in servlist.splitlines(): if 'enabled' not in line: print align_n('One of the services is not enabled') print line allRunning = False elif 'up' not in line: print align_n('One of the services is not up') print line allRunning = False if allRunning: print align_y('All services OK') # check if all compute nodes are mentioned in the list computeNodes = [ host.replace('root@', '') for host in env.roledefs['compute'] ] allComputes = True for node in computeNodes: if node not in servlist: print align_n('%s is not mentioned in the service list' % node) allComputes = False if allComputes: print align_y('All compute nodes have a service') if not allRunning or not allComputes: saveConfigFile(etc_nova_config_file, 'bad') sys.exit(1)
def servicesTDD(): "Check service-list to see if the nova services are up and running" with prefix(env_config.admin_openrc): msg = 'Get service list' serviceList = runCheck(msg, 'nova service-list >service-list') run('cat service-list') servlist = run('cat service-list | grep nova', quiet=True) # check if all services are running allRunning = True for line in servlist.splitlines(): if 'enabled' not in line: print align_n('One of the services is not enabled') print line allRunning = False elif 'up' not in line: print align_n('One of the services is not up') print line allRunning = False if allRunning: print align_y('All services OK') # check if all compute nodes are mentioned in the list computeNodes = [host.replace('root@','') for host in env.roledefs['compute']] allComputes = True for node in computeNodes: if node not in servlist: print align_n('%s is not mentioned in the service list' % node) allComputes = False if allComputes: print align_y('All compute nodes have a service') if not allRunning or not allComputes: saveConfigFile(etc_nova_config_file, 'bad') sys.exit(1)
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 saveConfigCompute(status): "Save locally the config files that exist in the compute nodes" saveConfigFile(sysctl_conf, status) saveConfigFile(neutron_conf, status) saveConfigFile(nova_conf, status)
def saveConfigNetwork(status): "Save locally the config files that exist in the network node" saveConfigFile(sysctl_conf,status) saveConfigFile(neutron_conf,status) saveConfigFile(ml2_conf_file,status) saveConfigFile(l3_agent_file,status) saveConfigFile(dhcp_agent_file,status) saveConfigFile(metadata_agent_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')
def saveConfigController(status): "Save locally the config files that exist in the controller node" saveConfigFile(neutron_conf,status) saveConfigFile(ml2_conf_file,status) saveConfigFile(nova_conf,status)
def saveConfigController(status): "Save locally the config files that exist in the controller node" saveConfigFile(neutron_conf, status) saveConfigFile(ml2_conf_file, status) saveConfigFile(nova_conf, status)
def saveConfigCompute(status): "Save locally the config files that exist in the compute nodes" saveConfigFile(sysctl_conf,status) saveConfigFile(neutron_conf,status) saveConfigFile(nova_conf,status)
def saveConfigNetwork(status): "Save locally the config files that exist in the network node" saveConfigFile(sysctl_conf, status) saveConfigFile(neutron_conf, status) saveConfigFile(ml2_conf_file, status) saveConfigFile(l3_agent_file, status) saveConfigFile(dhcp_agent_file, status) saveConfigFile(metadata_agent_file, status)