Beispiel #1
0
    def __init__(self, module):
        self.module = module
        self.fetcher = NitroAPIFetcher(self.module)

        # Dictionary containing attribute information
        # for each NITRO object utilized by this module
        self.attribute_config = {
            'systemfile': {
                'attributes_list': [
                    'filename',
                    'filecontent',
                    'filelocation',
                    'fileencoding',
                ],
                'transforms': {
                },
                'get_id_attributes': [
                ],
                'delete_id_attributes': [
                    'filename',
                    'filelocation',
                ],
                'non_updateable_attributes': [
                ],
            },
        }

        self.module_result = dict(
            changed=False,
            failed=False,
            loglines=loglines,
        )

        # Calculate functions will apply transforms to values read from playbook
        self.calculate_configured_systemfile()
    def __init__(self, module):
        self.module = module
        self.fetcher = NitroAPIFetcher(self.module)
        self.main_nitro_class = 'servicegroup'

        # Dictionary containing attribute information
        # for each NITRO object utilized by this module
        self.attribute_config = {
            'sslcipher': {
                'attributes_list': [
                    'ciphergroupname',
                ],
                'transforms': {},
                'get_id_attributes': [
                    'ciphergroupname',
                ],
                'delete_id_attributes': [
                    'ciphergroupname',
                    'ciphername',
                ],
                'non_updateable_attributes': [],
            },
        }

        self.module_result = dict(
            changed=False,
            failed=False,
            loglines=loglines,
        )

        # Calculate functions will apply transforms to values read from playbook
        self.calculate_configured_cipher()
Beispiel #3
0
    def __init__(self, module):
        self.module = module
        self.fetcher = NitroAPIFetcher(self.module)

        # Dictionary containing attribute information
        # for each NITRO object utilized by this module
        self.attribute_config = {
            'dnsnsrec': {
                'attributes_list': [
                    'domain',
                    'nameserver',
                    'ttl',
                ],
                'transforms': {},
                'get_id_attributes': [
                    'domain',
                ],
                'delete_id_attributes': [
                    'domain',
                    'nameserver',
                    'ecssubnet',
                ],
                'non_updateable_attributes': [],
            },
        }

        self.module_result = dict(
            changed=False,
            failed=False,
            loglines=loglines,
        )

        # Calculate functions will apply transforms to values read from playbook
        self.calculate_configured_dnsnsrec()
Beispiel #4
0
def get_nitro_api_info(module):
    log('In get_nitro_api_info')

    fetcher = NitroAPIFetcher(module=module)

    endpoint = module.params.get('endpoint')
    args = module.params.get('args', None)
    attrs = module.params.get('attrs', None)
    filter = module.params.get('filter', None)

    nitro_info_key = module.params.get('nitro_info_key', None)
    if nitro_info_key is None:
        nitro_info_key = endpoint

    module_result = dict(
        changed=False,
        failed=False,
        loglines=loglines,
    )

    get_result = fetcher.get(resource=endpoint,
                             args=args,
                             attrs=attrs,
                             filter=filter)
    log("get_result: %s" % get_result)
    data = get_result.get('data')

    # data key is always expected from a NITRO request
    if data is None:
        module_result['failed'] = True
        module.fail_json(msg='There is no data key in get result',
                         **module_result)

    nitro_empty_errorcodes = module.params.get('nitro_empty_errorcodes')
    if nitro_empty_errorcodes is None:
        nitro_empty_errorcodes = []

    # Resource does not exist and appropriate errorcode returned
    errorcode = data.get('errorcode', 0)
    if errorcode in nitro_empty_errorcodes:
        module.exit_json(nitro_info=[], **module_result)

    acceptable_errorcodes = [0]
    acceptable_errorcodes.extend(nitro_empty_errorcodes)

    # Errorcode that signifies actual error
    if errorcode not in acceptable_errorcodes:
        msg = 'NITRO error %s. message: %s' % (errorcode, data.get('message'))
        module.fail_json(msg=msg, **module_result)

    nitro_info = data.get(nitro_info_key)

    # Fail if the data do not contain expected key
    if nitro_info is None:
        module_result['failed'] = True
        module.fail_json(msg='There is no nitro_info_key "%s"' %
                         nitro_info_key,
                         **module_result)

    module.exit_json(nitro_info=nitro_info, **module_result)
Beispiel #5
0
    def __init__(self, module):
        self.module = module
        self.fetcher = NitroAPIFetcher(self.module)

        self.module_result = dict(
            changed=False,
            failed=False,
            loglines=loglines,
        )

        self.lifecycle = self.module.params['workflow']['lifecycle']

        self.retrieved_object = None
        self.configured_object = self.module.params['resource']

        self.endpoint = self.module.params['workflow'].get('endpoint')

        self.differing_attributes = []

        # Parse non updateable attributes
        self.non_updateable_attributes = self.module.params['workflow'].get(
            'non_updateable_attributes')
        if self.non_updateable_attributes is None:
            self.non_updateable_attributes = []

        id_key = self.module.params['workflow'].get('primary_id_attribute')
        if id_key is not None:
            self.id = self.module.params['resource'][id_key]
        else:
            self.id = None

        log('self.id %s' % self.id)

        # Parse delete id attributes
        self.delete_id_attributes = self.module.params['workflow'].get(
            'delete_id_attributes')
        if self.delete_id_attributes is None:
            self.delete_id_attributes = []

        self.prepared_list = []
    def __init__(self, module):
        self.module = module
        self.fetcher = NitroAPIFetcher(self.module)
        self.main_nitro_class = 'service'

        # Dictionary containing attribute information
        # for each NITRO object utilized by this module
        self.attribute_config = {
            'appfwsignatures': {
                'attributes_list': [
                    'name',
                    'src',
                    'xslt',
                    'xslt_builtin',
                ],
                'transforms': {},
                'get_id_attributes': [
                    'name',
                ],
                'delete_id_attributes': [
                    'name',
                ],
                'non_updateable_attributes': [],
            },
        }

        self.module_result = dict(
            changed=False,
            failed=False,
            loglines=loglines,
        )

        self.init_tmp_dir()
        self.calculate_configured_signatures()

        self.local_native_signatures = os.path.join(
            self.tmp_dir, self.configured_signatures['name'])
    def __init__(self, module):
        self.module = module
        self.fetcher = NitroAPIFetcher(self.module)

        # Dictionary containing attribute information
        # for each NITRO object utilized by this module
        self.attribute_config = {
            'nspartition': {
                'attributes_list': [
                    'partitionname',
                    'maxbandwidth',
                    'minbandwidth',
                    'maxconn',
                    'maxmemlimit',
                    'partitionmac',
                ],
                'transforms': {
                },
                'get_id_attributes': [
                    'partitionname',
                ],
                'delete_id_attributes': [
                    'partitionname',
                ],
                'non_updateable_attributes': [
                ],
            },
        }

        self.module_result = dict(
            changed=False,
            failed=False,
            loglines=loglines,
        )

        # Calculate functions will apply transforms to values read from playbook
        self.calculate_configured_nspartition()
def main():

    argument_spec = dict()

    module_specific_arguments = dict(
        username=dict(
            type='str',
            required=True,
        ),
        password=dict(
            type='str',
            required=True,
            no_log=True,
        ),
        new_password=dict(
            type='str',
            required=True,
            no_log=True,
        ),
        nsip=dict(
            type='str',
            required=True,
        ),
        nitro_protocol=dict(
            required=True,
            type='str',
            choices=['https', 'http'],
        ),
        validate_certs=dict(required=True, type='bool'),
    )

    argument_spec.update(module_specific_arguments)

    module = AnsibleModule(
        argument_spec=argument_spec,
        supports_check_mode=False,
    )
    post_data = {
        'login': {
            'username': module.params['username'],
            'password': module.params['password'],
            'new_password': module.params['new_password'],
        }
    }

    fetcher = NitroAPIFetcher(module)
    result = fetcher.post(post_data=post_data, resource='login')

    module_result = dict(
        changed=False,
        failed=False,
        loglines=loglines,
    )

    log('{0}'.format(result))
    if result['nitro_errorcode'] == 0:
        module_result['changed'] = True
        module.exit_json(**module_result)
    else:
        msg = 'Non zero nitro errorcode {0}'.format(result['nitro_errorcode'])
        module.fail_json(msg=msg, **module_result)
Beispiel #9
0
    def __init__(self, module):
        self.module = module
        self.fetcher = NitroAPIFetcher(self.module)
        self.main_nitro_class = 'sslcertkey'

        # Dictionary containing attribute information
        # for each NITRO object utilized by this module
        self.attribute_config = {
            'sslcertkey': {
                'attributes_list': [
                    'certkey',
                    'cert',
                    'key',
                    'password',
                    'fipskey',
                    'hsmkey',
                    'inform',
                    'passplain',
                    'expirymonitor',
                    'notificationperiod',
                    'bundle',
                    'deletefromdevice',
                    'linkcertkeyname',
                    'nodomaincheck',
                    'ocspstaplingcache',
                ],
                'transforms': {
                    'expirymonitor': lambda v: v.upper(),
                    'bundle': lambda v: 'YES' if v else 'NO',
                },
                'get_id_attributes': [
                    'certkey',
                ],
                'delete_id_attributes': [
                    'certkey',
                    'deletefromdevice',
                ],
                'non_updateable_attributes': [
                ],
            },
        }

        self.module_result = dict(
            changed=False,
            failed=False,
            loglines=loglines,
        )

        self.change_keys = [
            'cert',
            'key',
            'fipskey',
            'inform',
        ]

        self.update_keys = [
            'expirymonitor',
            'notificationperiod',
        ]

        # Calculate functions will apply transforms to values read from playbook
        self.calculate_configured_ssl_certkey()
    def __init__(self, module):
        self.module = module
        self.fetcher = NitroAPIFetcher(self.module)

        # Dictionary containing attribute information
        # for each NITRO object utilized by this module
        self.attribute_config = {
            'nsip': {
                'attributes_list': [
                    'ipaddress',
                    'netmask',
                    'type',
                    'arp',
                    'icmp',
                    'vserver',
                    'telnet',
                    'ftp',
                    'gui',
                    'ssh',
                    'snmp',
                    'mgmtaccess',
                    'restrictaccess',
                    'dynamicrouting',
                    'decrementttl',
                    'ospf',
                    'bgp',
                    'rip',
                    'hostroute',
                    'advertiseondefaultpartition',
                    'networkroute',
                    'tag',
                    'hostrtgw',
                    'metric',
                    'vserverrhilevel',
                    'vserverrhimode',
                    'ospflsatype',
                    'ospfarea',
                    'vrid',
                    'icmpresponse',
                    'ownernode',
                    'arpresponse',
                    'ownerdownresponse',
                    'td',
                    'arpowner',
                ],
                'transforms': {
                    'arp': lambda v: v.upper(),
                    'icmp': lambda v: v.upper(),
                    'vserver': lambda v: v.upper(),
                    'telnet': lambda v: v.upper(),
                    'ftp': lambda v: v.upper(),
                    'ssh': lambda v: v.upper(),
                    'snmp': lambda v: v.upper(),
                    'mgmtaccess': lambda v: v.upper(),
                    'restrictaccess': lambda v: v.upper(),
                    'dynamicrouting': lambda v: v.upper(),
                    'decrementttl': lambda v: v.upper(),
                    'ospf': lambda v: v.upper(),
                    'bgp': lambda v: v.upper(),
                    'rip': lambda v: v.upper(),
                    'hostroute': lambda v: v.upper(),
                    'advertiseondefaultpartition': lambda v: v.upper(),
                    'networkroute': lambda v: v.upper(),
                    'ownerdownresponse': lambda v: 'YES' if v else 'NO',
                },
                'get_id_attributes': [
                ],
                'delete_id_attributes': [
                    'ipaddress',
                    'td',
                ],
                'non_updateable_attributes': [
                    'type',
                    'state',
                    'ownernode',
                ],
            },
        }

        self.module_result = dict(
            changed=False,
            failed=False,
            loglines=loglines,
        )

        # Calculate functions will apply transforms to values read from playbook
        self.calculate_configured_nsip()
Beispiel #11
0
    def __init__(self, module):
        self.module = module
        self.fetcher = NitroAPIFetcher(self.module)
        self.main_nitro_class = 'service'

        # Dictionary containing attribute information
        # for each NITRO object utilized by this module
        self.attribute_config = {
            'service': {
                'attributes_list': [
                    'name',
                    'ip',
                    'servername',
                    'servicetype',
                    'port',
                    'cleartextport',
                    'cachetype',
                    'maxclient',
                    'healthmonitor',
                    'maxreq',
                    'cacheable',
                    'cip',
                    'cipheader',
                    'usip',
                    'pathmonitor',
                    'pathmonitorindv',
                    'useproxyport',
                    'sc',
                    'sp',
                    'rtspsessionidremap',
                    'clttimeout',
                    'svrtimeout',
                    'customserverid',
                    'serverid',
                    'cka',
                    'tcpb',
                    'cmp',
                    'maxbandwidth',
                    'accessdown',
                    'monthreshold',
                    'downstateflush',
                    'tcpprofilename',
                    'httpprofilename',
                    'contentinspectionprofilename',
                    'hashid',
                    'comment',
                    'appflowlog',
                    'netprofile',
                    'td',
                    'processlocal',
                    'dnsprofilename',
                    'monconnectionclose',
                    'ipaddress',
                    'weight',
                    'monitor_name_svc',
                    'riseapbrstatsmsgcode',
                    'delay',
                    'graceful',
                    'all',
                    'Internal',
                ],
                'transforms': {
                    'healthmonitor': lambda v: 'YES' if v else 'NO',
                    'cacheable': lambda v: 'YES' if v else 'NO',
                    'cip': lambda v: v.upper(),
                    'usip': lambda v: 'YES' if v else 'NO',
                    'pathmonitor': lambda v: 'YES' if v else 'NO',
                    'pathmonitorindv': lambda v: 'YES' if v else 'NO',
                    'useproxyport': lambda v: 'YES' if v else 'NO',
                    'sc': lambda v: 'ON' if v else 'OFF',
                    'sp': lambda v: 'ON' if v else 'OFF',
                    'rtspsessionidremap': lambda v: 'ON' if v else 'OFF',
                    'cka': lambda v: 'YES' if v else 'NO',
                    'tcpb': lambda v: 'YES' if v else 'NO',
                    'cmp': lambda v: 'YES' if v else 'NO',
                    'accessdown': lambda v: 'YES' if v else 'NO',
                    'downstateflush': lambda v: v.upper(),
                    'appflowlog': lambda v: v.upper(),
                    'processlocal': lambda v: v.upper(),
                    'graceful': lambda v: 'YES' if v else 'NO',
                },
                'get_id_attributes': [
                    'name',
                ],
                'delete_id_attributes': [
                    'name',
                ],
                'non_updateable_attributes': [
                    'ip',
                    'servername',
                    'servicetype',
                    'port',
                    'cleartextport',
                    'cachetype',
                    'state',
                    'td',
                    'riseapbrstatsmsgcode',
                    'delay',
                    'graceful',
                    'all',
                    'Internal',
                    'newname',
                ],
            },
            'monitor_bindings': {
                'attributes_list': [
                    'monitor_name',
                    'monstate',
                    'weight',
                    'passive',
                ],
                'transforms': {
                    'monstate': lambda v: v.upper(),
                    'weight': str,
                },
                'get_id_attributes': [
                    'name',
                ],
                'delete_id_attributes': [
                    'monitor_name',
                    'name',
                ]
            }
        }

        self.module_result = dict(
            changed=False,
            failed=False,
            loglines=loglines,
        )
        self.prepared_list = []

        self.calculate_configured_service()
        self.calculate_configured_monitor_bindings()