How to use _copy_script method in Airtest

Best Python code snippet using Airtest

nagios_910.py

Source:nagios_910.py Github

copy

Full Screen

...67 for key in sorted(kwargs.keys()):68 s += "\t%s\t%s\n" % (key, kwargs[key])69 s += "\t}\n"70 return s71def _copy_script(**kwargs):72 # TODO : Replace all these shell templates with with python73 return ('file{"/usr/lib64/nagios/plugins/%(name)s":'74 'mode => 755, owner => "nagios", '75 'seltype => "nagios_unconfined_plugin_exec_t", '76 'content => template("packstack/%(name)s.erb"),}\n'77 'nagios_command {"%(name)s": '78 'command_line => "/usr/lib64/nagios/plugins/%(name)s",}\n'79 % kwargs)80def nagios_host(hostname, **kwargs):81 out = ("nagios_host { '%s': " % hostname)82 for key, value in kwargs.items():83 out = "%s, %s => '%s'" % (out, key, value)84 return "%s}\n" % out85def createmanifest(config):86 manifest_entries = ''87 # I should be adding service entries with nagios_service but it appears to be broken88 # http://projects.puppetlabs.com/issues/342089 service_entries = ''90 for hostname in gethostlist(config):91 manifest_entries += nagios_host(hostname, address=hostname, use='linux-server')92 service_entries += _serviceentry(name='load5-%s'%hostname, service_description='5 minute load average',93 host_name=hostname, check_command="check_nrpe!load5", use="generic-service",94 normal_check_interval='5')95 service_entries += _serviceentry(name='df_var-%s'%hostname,96 service_description='Percent disk space used on /var',97 host_name=hostname,98 check_command="check_nrpe!df_var", use="generic-service")99 manifest_entries += _copy_script(name="keystone-user-list")100 service_entries += _serviceentry(name='keystone-user-list',101 service_description='number of keystone users',102 host_name=controller.CONF['CONFIG_NAGIOS_HOST'],103 check_command="keystone-user-list", use="generic-service",104 normal_check_interval='5')105 if controller.CONF['CONFIG_GLANCE_INSTALL'] == 'y':106 manifest_entries += _copy_script(name="glance-index")107 service_entries += _serviceentry(name='glance-index',108 service_description='number of glance images',109 host_name=controller.CONF['CONFIG_NAGIOS_HOST'],110 check_command="glance-index", use="generic-service",111 normal_check_interval='5')112 if controller.CONF['CONFIG_NOVA_INSTALL'] == 'y':113 manifest_entries += _copy_script(name="nova-list")114 service_entries += _serviceentry(name='nova-list',115 service_description='number of nova vm instances',116 host_name=controller.CONF['CONFIG_NAGIOS_HOST'],117 check_command="nova-list", use="generic-service",118 normal_check_interval='5')119 if controller.CONF['CONFIG_CINDER_INSTALL'] == 'y':120 manifest_entries += _copy_script(name="cinder-list")121 service_entries += _serviceentry(name='cinder-list',122 service_description='number of cinder volumes',123 host_name=controller.CONF['CONFIG_NAGIOS_HOST'],124 check_command="cinder-list", use="generic-service",125 normal_check_interval='5')126 if controller.CONF['CONFIG_SWIFT_INSTALL'] == 'y':127 manifest_entries += _copy_script(name="swift-list")128 service_entries += _serviceentry(name='swift-list',129 service_description='number of swift containers',130 host_name=controller.CONF['CONFIG_NAGIOS_HOST'],131 check_command="swift-list", use="generic-service",132 normal_check_interval='5')133 manifest_entries += ("file { '/etc/nagios/nagios_service.cfg': \n"134 "ensure => present, mode => 644,\n"135 "owner => 'nagios', group => 'nagios',\n"136 "before => Service['nagios'],\n"137 "content => '%s'}" % service_entries)138 controller.CONF['CONFIG_NAGIOS_MANIFEST_CONFIG'] = manifest_entries139 manifestfile = "%s_nagios.pp" % controller.CONF['CONFIG_NAGIOS_HOST']140 manifestdata = getManifestTemplate("nagios_server.pp")141 appendManifestFile(manifestfile, manifestdata)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful