<s> __author__ = '<STR_LIT>' <EOL> from tests . config import * <EOL> from nsxramlclient . client import NsxClient <EOL> import time <EOL> s = NsxClient ( nsxraml_file , nsxmanager , nsx_username , nsx_password , debug = True ) <EOL> def create_controller ( ) : <EOL> controller_spec = s . extract_resource_body_schema ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . view_body_dict ( controller_spec ) <EOL> controller_spec [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> controller_spec [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> controller_spec [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> controller_spec [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> controller_spec [ '<STR_LIT>' ] [ '<STR_LIT:password>' ] = '<STR_LIT>' <EOL> controller_spec [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> s . view_body_dict ( controller_spec ) <EOL> create_response = s . create ( '<STR_LIT>' , request_body_dict = controller_spec ) <EOL> s . view_response ( create_response ) <EOL> return create_response [ '<STR_LIT>' ] , create_response [ '<STR_LIT:body>' ] <EOL> def read_all_controllers ( ) : <EOL> response = s . read ( '<STR_LIT>' ) <EOL> s . view_response ( response ) <EOL> def wait_for_controller ( job_id ) : <EOL> status_poll_count = <NUM_LIT:0> <EOL> while status_poll_count < <NUM_LIT:20> : <EOL> response = s . read ( '<STR_LIT>' , uri_parameters = { '<STR_LIT>' : job_id } ) <EOL> s . view_response ( response ) <EOL> status = response [ '<STR_LIT:body>' ] [ '<STR_LIT>' ] [ '<STR_LIT:status>' ] <EOL> if status == '<STR_LIT>' : <EOL> return True <EOL> elif status == '<STR_LIT>' : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> else : <EOL> time . sleep ( <NUM_LIT:30> ) <EOL> raise Exception ( '<STR_LIT>' ) <EOL> def delete_controller ( controller_id , force = False ) : <EOL> removal_response = s . delete ( '<STR_LIT>' , uri_parameters = { '<STR_LIT>' : controller_id } , <EOL> query_parameters_dict = { '<STR_LIT>' : force } ) <EOL> s . view_response ( removal_response ) <EOL> def cluster_config ( ) : <EOL> config_read = s . read ( '<STR_LIT>' ) <EOL> s . view_response ( config_read ) <EOL> config = config_read [ '<STR_LIT:body>' ] <EOL> config [ '<STR_LIT>' ] [ '<STR_LIT>' ] = False <EOL> config_response = s . update ( '<STR_LIT>' , request_body_dict = config ) <EOL> s . view_response ( config_response ) <EOL> config_read = s . read ( '<STR_LIT>' ) <EOL> s . view_response ( config_read ) <EOL> def controller_techsupport ( controller_id ) : <EOL> response = s . read ( '<STR_LIT>' , uri_parameters = { '<STR_LIT>' : controller_id } ) <EOL> s . view_response ( response ) <EOL> def set_controller_syslog ( controller_id ) : <EOL> syslog_spec = s . extract_resource_body_schema ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> syslog_spec [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> s . view_body_dict ( syslog_spec ) <EOL> set_response = s . create ( '<STR_LIT>' , uri_parameters = { '<STR_LIT>' : controller_id } , <EOL> request_body_dict = syslog_spec ) <EOL> s . view_response ( set_response ) <EOL> def delete_controller_syslog ( controller_id ) : <EOL> del_response = s . delete ( '<STR_LIT>' , uri_parameters = { '<STR_LIT>' : controller_id } ) <EOL> s . view_response ( del_response ) <EOL> def get_controller_syslog ( controller_id ) : <EOL> response = s . read ( '<STR_LIT>' , uri_parameters = { '<STR_LIT>' : controller_id } ) <EOL> s . view_response ( response ) <EOL> def update_controller_credentials ( ) : <EOL> password_spec = s . extract_resource_body_schema ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> password_spec [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> s . view_body_dict ( password_spec ) <EOL> response = s . update ( '<STR_LIT>' , request_body_dict = password_spec ) <EOL> s . view_response ( response ) <EOL> controller1_id , job_id_resp = create_controller ( ) <EOL> wait_for_controller ( job_id_resp ) <EOL> read_all_controllers ( ) <EOL> update_controller_credentials ( ) <EOL> cluster_config ( ) <EOL> controller_techsupport ( controller1_id ) <EOL> set_controller_syslog ( controller1_id ) <EOL> get_controller_syslog ( controller1_id ) <EOL> delete_controller_syslog ( controller1_id ) </s>
