示例#1
0
def get_cserver(server):
    vserver_info = zapi.NaElement('vserver-get-iter')
    query_details = zapi.NaElement.create_node_with_children(
        'vserver-info', **{'vserver-type': 'admin'})
    query = zapi.NaElement('query')
    query.add_child_elem(query_details)
    vserver_info.add_child_elem(query)
    result = server.invoke_successfully(vserver_info, enable_tunneling=False)
    attribute_list = result.get_child_by_name('attributes-list')
    vserver_list = attribute_list.get_child_by_name('vserver-info')
    return vserver_list.get_child_content('vserver-name')
示例#2
0
def autosupport(vol_name, vol_size):
    server = setup_ontap_zapi(
        {'username': '******', 'password': '******', 'hostname': '10.193.77.37'}, 'ansible_test')
    api = zapi.NaElement('ems-autosupport-log')
    # Host name invoking the API.
    api.add_new_child("computer-name", "BuildAtScale")
    # ID of event. A user defined event-id, range [0..2^32-2].
    api.add_new_child("event-id", "123")
    # Name of the application invoking the API.
    api.add_new_child("event-source", "create_pipeline")
    # Version of application invoking the API.
    api.add_new_child("app-version", "1.1")
    # Application defined category of the event.
    api.add_new_child("category", "Information")
    # Description of event to log. An application defined message to log.
    # if state is 'pipeline-create':
    api.add_new_child("event-description", "A Jenkins pipeline and an ONTAP volume: " + vol_name
                      + " of size " + str(vol_size) + " has been created")
    # Log level. Accepted values are 0 for 'emergency', 1 for 'alert', 2 for 'critical', 3 for 'error', 4 for 'warning',
    # 5 for 'notice', 6 for 'info', and 7 for 'debug'. As of Data ONTAP 9.0, log-levels 2 and 4 are no longer supported.
    # Specifying 2 or 4 would be equivalent to specifying 3 or 5, respectively.
    api.add_new_child("log-level", "6")
    # If 'true', an AutoSupport message will be generated.
    api.add_new_child("auto-support", "false")
    server.invoke_successfully(api, True)