<s> __author__ = '<STR_LIT>' <EOL> from tests . config import * <EOL> from nsxramlclient . client import NsxClient <EOL> import time <EOL> def vxlan_prep ( session , cluster_moid , dvs_moid , ipaddresspool , vlan_id = <NUM_LIT:0> , vmknics = <NUM_LIT:1> , teaming = '<STR_LIT>' , <EOL> mtu = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> vxlan_prep_dvs = session . extract_resource_body_schema ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> vxlan_prep_dvs [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = dvs_moid <EOL> vxlan_prep_dvs [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> vxlan_prep_dvs [ '<STR_LIT>' ] [ '<STR_LIT>' ] . update ( { '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT>' : dvs_moid } , <EOL> '<STR_LIT>' : mtu , <EOL> '<STR_LIT>' : teaming } , <EOL> } ) <EOL> vxlan_prep_dvs_response = session . create ( '<STR_LIT>' , request_body_dict = vxlan_prep_dvs ) <EOL> session . view_response ( vxlan_prep_dvs_response ) <EOL> vxlan_prep_cluster = session . extract_resource_body_schema ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> vxlan_prep_cluster [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = cluster_moid <EOL> vxlan_prep_cluster [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> vxlan_prep_cluster [ '<STR_LIT>' ] [ '<STR_LIT>' ] . update ( { '<STR_LIT>' : <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT>' : dvs_moid } , <EOL> '<STR_LIT>' : vlan_id , <EOL> '<STR_LIT>' : vmknics , <EOL> '<STR_LIT>' : ipaddresspool } , <EOL> } ) <EOL> vxlan_prep_cluster_response = session . create ( '<STR_LIT>' , request_body_dict = vxlan_prep_cluster ) <EOL> session . view_response ( vxlan_prep_cluster_response ) <EOL> return vxlan_prep_cluster_response [ '<STR_LIT>' ] <EOL> def vxlan_unprep_cluster ( session , cluster_moid ) : <EOL> vxlan_prep_cluster = session . extract_resource_body_schema ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> vxlan_prep_cluster [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = cluster_moid <EOL> vxlan_prep_cluster [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> vxlan_prep_cluster_response = session . delete ( '<STR_LIT>' , request_body_dict = vxlan_prep_cluster ) <EOL> session . view_response ( vxlan_prep_cluster_response ) <EOL> return vxlan_prep_cluster_response [ '<STR_LIT>' ] <EOL> def vxlan_unprep_dvs_context ( session , dvs_moid ) : <EOL> vxlan_prep_dvs = session . extract_resource_body_schema ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> vxlan_prep_dvs [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = dvs_moid <EOL> vxlan_prep_dvs [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> vxlan_prep_dvs_response = session . delete ( '<STR_LIT>' , request_body_dict = vxlan_prep_dvs ) <EOL> session . view_response ( vxlan_prep_dvs_response ) <EOL> return vxlan_prep_dvs_response [ '<STR_LIT>' ] <EOL> def wait_for_job_completion ( session , job_id , completion_status ) : <EOL> status_poll_count = <NUM_LIT:0> <EOL> while status_poll_count < <NUM_LIT:20> : <EOL> response = session . read ( '<STR_LIT>' , uri_parameters = { '<STR_LIT>' : job_id } ) <EOL> session . view_response ( response ) <EOL> status = response [ '<STR_LIT:body>' ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT:status>' ] <EOL> if status == completion_status : <EOL> return True <EOL> else : <EOL> time . sleep ( <NUM_LIT:30> ) <EOL> status_poll_count += <NUM_LIT:1> <EOL> raise Exception ( '<STR_LIT>' ) <EOL> def main ( ) : <EOL> s = NsxClient ( nsxraml_file , nsxmanager , nsx_username , nsx_password , debug = True ) <EOL> vxlan_prep_response = vxlan_prep ( s , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> wait_for_job_completion ( s , vxlan_prep_response , completion_status = '<STR_LIT>' ) <EOL> unprep_response = vxlan_unprep_cluster ( s , '<STR_LIT>' ) <EOL> wait_for_job_completion ( s , unprep_response , completion_status = '<STR_LIT>' ) <EOL> vxlan_unprep_dvs_context ( s , '<STR_LIT>' ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
