'Change volume\'s state (offline/online).
Note: \'is_infinite\' needs to be set to True in order to change the
state of an Infinite Volume.'

def change_volume_state(self):

    state_requested = None
    if self.is_online:
        state_requested = 'online'
        if self.is_infinite:
            volume_change_state = netapp_utils.zapi.NaElement.create_node_with_children('volume-online-async', **{'volume-name': self.name})
        else:
            volume_change_state = netapp_utils.zapi.NaElement.create_node_with_children('volume-online', **{'name': self.name})
    else:
        state_requested = 'offline'
        if self.is_infinite:
            volume_change_state = netapp_utils.zapi.NaElement.create_node_with_children('volume-offline-async', **{'volume-name': self.name})
        else:
            volume_change_state = netapp_utils.zapi.NaElement.create_node_with_children('volume-offline', **{'name': self.name})
    try:
        self.server.invoke_successfully(volume_change_state, enable_tunneling=True)
    except netapp_utils.zapi.NaApiError as e:
        self.module.fail_json(msg=('Error    changing    the    state    of    volume    %s    to    %s:    %s' % (self.name, state_requested, to_native(e))), exception=traceback.format_exc())
