<s> """<STR_LIT>""" <EOL> __docformat__ = "<STR_LIT>" <EOL> import os <EOL> import logging <EOL> import uuid <EOL> from rundeck . client import Rundeck <EOL> from rundeck . api import RundeckApi , RundeckNode <EOL> from rundeck . transforms import _transforms as transforms <EOL> _RUNDECK_API_TOKEN_VAR = '<STR_LIT>' <EOL> _RUNDECK_SERVER_VAR = '<STR_LIT>' <EOL> _RUNDECK_PORT_VAR = '<STR_LIT>' <EOL> _RUNDECK_PROTOCOL_VAR = '<STR_LIT>' <EOL> _RUNDECK_USR_VAR = '<STR_LIT>' <EOL> _RUNDECK_PWD_VAR = '<STR_LIT>' <EOL> _RUNDECK_API_VERSION_VAR = '<STR_LIT>' <EOL> logger = logging . getLogger ( __name__ ) <EOL> logger . setLevel ( logging . INFO ) <EOL> logger . addHandler ( logging . StreamHandler ( ) ) <EOL> cwd = os . path . dirname ( os . path . realpath ( __file__ ) ) <EOL> job_def_file = '<STR_LIT>' <EOL> job_def_path = os . path . join ( cwd , job_def_file ) <EOL> api_token = os . environ . get ( _RUNDECK_API_TOKEN_VAR , None ) <EOL> server = os . environ . get ( _RUNDECK_SERVER_VAR , '<STR_LIT:localhost>' ) <EOL> port = os . environ . get ( _RUNDECK_PORT_VAR , <NUM_LIT> ) <EOL> protocol = os . environ . get ( _RUNDECK_PROTOCOL_VAR , '<STR_LIT:http>' ) <EOL> usr = os . environ . get ( _RUNDECK_USR_VAR , None ) <EOL> pwd = os . environ . get ( _RUNDECK_PWD_VAR , None ) <EOL> api_version = os . environ . get ( _RUNDECK_API_VERSION_VAR , <NUM_LIT:11> ) <EOL> test_job_id = uuid . uuid4 ( ) <EOL> test_job_name = '<STR_LIT>' <EOL> test_job_proj = '<STR_LIT>' <EOL> test_job_def_tmpl = """<STR_LIT>""" <EOL> test_job_def = test_job_def_tmpl . format ( test_job_id , test_job_name , test_job_proj ) <EOL> assert any ( [ api_token , all ( [ usr , pwd ] ) ] ) , '<STR_LIT>' + '<STR_LIT>' . format ( _RUNDECK_API_TOKEN_VAR ) + '<STR_LIT>' . format ( _RUNDECK_USR_VAR , _RUNDECK_PWD_VAR ) <EOL> options = { <EOL> '<STR_LIT>' : server , <EOL> '<STR_LIT>' : protocol , <EOL> '<STR_LIT:port>' : port , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : api_version , <EOL> } <EOL> if api_token is not None : <EOL> options [ '<STR_LIT>' ] = api_token <EOL> else : <EOL> if usr is not None and pwd is not None : <EOL> options [ '<STR_LIT>' ] = usr <EOL> options [ '<STR_LIT>' ] = pwd <EOL> else : <EOL> assert False , '<STR_LIT>' + '<STR_LIT>' . format ( _RUNDECK_USR_VAR , _RUNDECK_PWD_VAR ) <EOL> rundeck_client = Rundeck ( ** options ) <EOL> rundeck_api = RundeckApi ( ** options ) <EOL> def setup ( ) : <EOL> rundeck_api . jobs_import ( test_job_def , uuidOption = '<STR_LIT>' ) <EOL> def teardown ( ) : <EOL> jobs = transforms [ '<STR_LIT>' ] ( rundeck_api . jobs ( test_job_proj ) ) <EOL> rundeck_api . jobs_delete ( [ job [ '<STR_LIT:id>' ] for job in jobs ] ) </s>
