def compare(isamAppliance1, isamAppliance2):
    """
    Compare Policy Sets between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    for obj in ret_obj1['data']:
        del obj['id']
        del obj['userlastmodified']
        del obj['lastmodified']
        del obj['datecreated']
        del obj['lastdeployed']
        for pol in obj['policies']:
            del pol['id']
            del pol['lastmodified']
    for obj in ret_obj2['data']:
        del obj['id']
        del obj['userlastmodified']
        del obj['lastmodified']
        del obj['datecreated']
        del obj['lastdeployed']
        for pol in obj['policies']:
            del pol['id']
            del pol['lastmodified']

    return tools.json_compare(ret_obj1,
                              ret_obj2,
                              deleted_keys=[
                                  'id', 'userlastmodified', 'lastmodified',
                                  'datecreated', 'lastdeployed'
                              ])
Beispiel #2
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare Host Records between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    return json_compare(ret_obj1, ret_obj2, deleted_keys=[])
Beispiel #3
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare lmi tracing between two appliances
    """
    ret_obj1 = get(isamAppliance1)
    ret_obj2 = get(isamAppliance2)

    return tools.json_compare(ret_obj1, ret_obj2)
Beispiel #4
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare kerberos keytab files between two appliances
    """
    ret_obj1 = get(isamAppliance1)
    ret_obj2 = get(isamAppliance2)

    return tools.json_compare(ret_obj1, ret_obj2, deleted_keys=[])
Beispiel #5
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare forwarder Policies between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    return tools.json_compare(ret_obj1, ret_obj2, deleted_keys=[])
Beispiel #6
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare configuration between two appliances
    """
    ret_obj1 = get(isamAppliance1)
    ret_obj2 = get(isamAppliance2)

    return tools.json_compare(ret_obj1, ret_obj2, deleted_keys=[])
Beispiel #7
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare cors policies between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    return tools.json_compare(ret_obj1, ret_obj2)
Beispiel #8
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare redis configurations between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    return tools.json_compare(ret_obj1, ret_obj2)
Beispiel #9
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare resources between two appliances
    """

    app1_instances = ibmsecurity.isam.web.api_access_control.resources.instances.get_all(isamAppliance1)
    app2_instances = ibmsecurity.isam.web.api_access_control.resources.instances.get_all(isamAppliance2)

    obj1 = []
    obj2 = []

    for inst1 in app1_instances['data']:
        servers = ibmsecurity.isam.web.api_access_control.resources.servers.get_all(isamAppliance1,
                                                                                    instance_name=inst1['name'])
        for srv in servers['data']:
            if "servers" in srv:
                srvlist = srv['servers'].split(";")
                new_str = None
                for value in srvlist:
                    if value.find("server_uuid") == -1 and \
                            value.find("current_requests") == -1 and \
                            value.find("total_requests") == -1:
                        if new_str is None:
                            new_str = value
                        else:
                            new_str = new_str + ";" + value
                srv['servers'] = new_str
            obj1.append(srv)
            resources1 = get_all(isamAppliance1, instance_name=inst1['name'], resource_server_name=srv['name'])
            obj1.extend(resources1['data'])

    for inst2 in app2_instances['data']:
        servers = ibmsecurity.isam.web.api_access_control.resources.servers.get_all(isamAppliance2,
                                                                                    instance_name=inst2['name'])
        for srv in servers['data']:
            if "servers" in srv:
                srvlist = srv['servers'].split(";")
                new_str = None
                for value in srvlist:
                    if value.find("server_uuid") == -1 and \
                            value.find("current_requests") == -1 and \
                            value.find("total_requests") == -1:
                        if new_str is None:
                            new_str = value
                        else:
                            new_str = new_str + ";" + value
                srv['servers'] = new_str
            obj2.append(srv)
            resources2 = get_all(isamAppliance2, instance_name=inst2['name'], resource_server_name=srv['name'])
            obj2.extend(resources2['data'])

    app1_instances['data'].extend(obj1)
    app2_instances['data'].extend(obj2)

    return tools.json_compare(app1_instances, app2_instances,
                              deleted_keys=['server_uuid', 'current_requests', 'total_requests'])
Beispiel #10
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare Attribute Matchers between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)
    for obj in ret_obj1['data']:
        del obj['id']
    for obj in ret_obj2['data']:
        del obj['id']

    return tools.json_compare(ret_obj1, ret_obj2, deleted_keys=['id'])
Beispiel #11
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare isamruntime between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    for obj in ret_obj1['data']:
        del obj['uuid']
    for obj in ret_obj2['data']:
        del obj['uuid']

    return tools.json_compare(ret_obj1, ret_obj2, deleted_keys=['uuid'])
Beispiel #12
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare list of extension bundles between 2 appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    for obj in ret_obj1['data']:
        del obj['id']
    for obj in ret_obj2['data']:
        del obj['id']

    return tools.json_compare(ret_obj1, ret_obj2, deleted_keys=['id'])
Beispiel #13
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare kerberos configuration domains between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    for obj in ret_obj1['data']:
        del obj['id']
    for obj in ret_obj2['data']:
        del obj['id']

    return tools.json_compare(ret_obj1, ret_obj2, deleted_keys=['id'])
def compare(isamAppliance1, isamAppliance2):
    """
    Compare access policies between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    for obj in ret_obj1['data']:
        del obj['push_id']

    for obj in ret_obj2['data']:
        del obj['push_id']

    return tools.json_compare(ret_obj1, ret_obj2, deleted_keys=['push_id'])
Beispiel #15
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare API Protection Definitions between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    for obj in ret_obj1['data']:
        del obj['id']
        del obj['definition']
    for obj in ret_obj2['data']:
        del obj['id']
        del obj['definition']

    return tools.json_compare(ret_obj1, ret_obj2, deleted_keys=['id', 'definition'])
Beispiel #16
0
def compare(isamAppliance1,
            isamAppliance2,
            instance1_name,
            instance2_name=None):
    """
    Compare documentation root between two appliances
    """

    if instance2_name is None or instance2_name == '':
        instance2_name = instance1_name

    ret_obj1 = get_all(isamAppliance1, instance1_name)
    ret_obj2 = get_all(isamAppliance2, instance2_name)

    return tools.json_compare(ret_obj1, ret_obj2)
Beispiel #17
0
def compare(isdsAppliance1, isdsAppliance2):
    """
    Compare list of support files between 2 appliances - not sure if this will ever be useful?
    """
    ret_obj1 = get(isdsAppliance1)
    ret_obj2 = get(isdsAppliance2)

    for snapshot in ret_obj1['data']:
        del snapshot['id']
        del snapshot['filename']

    for snapshot in ret_obj2['data']:
        del snapshot['id']
        del snapshot['filename']

    return tools.json_compare(ret_obj1, ret_obj2, deleted_keys=['id', 'filename'])
Beispiel #18
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare host records between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    # # Ignore differences between comments/uuid as they are immaterial
    # for param in ret_obj1['data']['tuningParameters']:
    #     del param['comment']
    #     del param['uuid']
    # for param in ret_obj2['data']['tuningParameters']:
    #     del param['comment']
    #     del param['uuid']

    return json_compare(ret_obj1, ret_obj2)
Beispiel #19
0
def compare_one_server(isamAppliance1, isamAppliance2, instance1_name, server1_name, instance2_name=None,
                       server2_name=None):
    """
    Compare resources between two appliances
    """

    if instance2_name is None or instance2_name == '':
        instance2_name = instance1_name

    if server2_name is None or server2_name == '':
        server2_name = server1_name

    resources1 = get_all(isamAppliance1, instance_name=instance1_name, resource_server_name=server1_name)
    resources2 = get_all(isamAppliance2, instance_name=instance2_name, resource_server_name=server2_name)

    return tools.json_compare(resources1, resources2)
Beispiel #20
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare Authentication mechanisms between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    for obj in ret_obj1['data']:
        del obj['id']
        del obj['typeId']
    for obj in ret_obj2['data']:
        del obj['id']
        del obj['typeId']

    return tools.json_compare(ret_obj1,
                              ret_obj2,
                              deleted_keys=['id', 'typeId'])
Beispiel #21
0
def compare(isamAppliance1,
            isamAppliance2,
            reverseproxy_id,
            reverseproxy_id2=None):
    """
    Compare list of junctions in a given reverse proxy between 2 appliances
    """
    if reverseproxy_id2 is None or reverseproxy_id2 == '':
        reverseproxy_id2 = reverseproxy_id

    ret_obj1 = get_all(isamAppliance1, reverseproxy_id)
    ret_obj2 = get_all(isamAppliance2, reverseproxy_id2)

    for jct in ret_obj1['data']:
        ret_obj = get(isamAppliance1, reverseproxy_id, jct['id'])
        del ret_obj['data']['active_worker_threads']
        for srv in ret_obj['data']['servers']:
            del srv['current_requests']
            del srv['operation_state']
            del srv['server_state']
            if ret_obj['data']['stateful_junction'] == 'no':
                del srv['server_uuid']
            del srv['total_requests']
        jct['details'] = ret_obj['data']

    for jct in ret_obj2['data']:
        ret_obj = get(isamAppliance2, reverseproxy_id2, jct['id'])
        del ret_obj['data']['active_worker_threads']
        for srv in ret_obj['data']['servers']:
            del srv['current_requests']
            del srv['operation_state']
            del srv['server_state']
            if ret_obj['data']['stateful_junction'] == 'no':
                del srv['server_uuid']
            del srv['total_requests']
        jct['details'] = ret_obj['data']

    return tools.json_compare(
        ret_obj1,
        ret_obj2,
        deleted_keys=[
            'active_worker_threads', 'servers/current_requests',
            'servers/operation_state', 'servers/server_state',
            'servers/server_uuid', 'servers/total_requests'
        ])
Beispiel #22
0
def compare_one_instance(isamAppliance1, isamAppliance2, instance1_name, instance2_name=None):
    """
    Compare resources between two appliances
    """
    if instance2_name is None or instance2_name == '':
        instance2_name = instance1_name

    obj1 = []
    obj2 = []
    servers1 = get_all(isamAppliance1, instance_name=instance1_name)
    for srv in servers1['data']:
        if "servers" in srv:
            srvlist = srv['servers'].split(";")
            new_str = None
            for value in srvlist:
                if value.find("server_uuid") == -1 and \
                        value.find("current_requests") == -1 and \
                        value.find("total_requests") == -1:
                    if new_str is None:
                        new_str = value
                    else:
                        new_str = new_str + ";" + value
            srv['servers'] = new_str
        obj1.append(srv)

    servers2 = get_all(isamAppliance2, instance_name=instance2_name)
    for srv in servers2['data']:
        if "servers" in srv:
            srvlist = srv['servers'].split(";")
            new_str = None
            for value in srvlist:
                if value.find("server_uuid") == -1 and \
                        value.find("current_requests") == -1 and \
                        value.find("total_requests") == -1:
                    if new_str is None:
                        new_str = value
                    else:
                        new_str = new_str + ";" + value
            srv['servers'] = new_str
        obj2.append(srv)

    servers1['data'] = obj1
    servers2['data'] = obj2

    return tools.json_compare(servers1, servers2, deleted_keys=['server_uuid', 'current_requests', 'total_requests'])
Beispiel #23
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare user name mapping
    """

    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    for obj in ret_obj1['data']:
        ret_obj = get(isamAppliance1, obj['id'])['data']
        del obj['version']
        obj['contents'] = ret_obj['contents']
    for obj in ret_obj2['data']:
        ret_obj = get(isamAppliance2, obj['id'])['data']
        del obj['version']
        obj['contents'] = ret_obj['contents']

    return tools.json_compare(ret_obj1, ret_obj2, deleted_keys=['version'])
Beispiel #24
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare STS Chains Templates between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    for obj in ret_obj1['data']:
        del obj['id']
        for ci in obj['chainItems']:
            del ci['prefix']
    for obj in ret_obj2['data']:
        del obj['id']
        for ci in obj['chainItems']:
            del ci['prefix']

    return tools.json_compare(ret_obj1,
                              ret_obj2,
                              deleted_keys=['id', 'chainItems/prefix'])
Beispiel #25
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare access policies between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    obj1 = {'rc': 0, 'data': []}
    obj2 = {'rc': 0, 'data': []}

    for attr in ret_obj1["data"]:
        if search(isamAppliance=isamAppliance1, attribute_name=attr["name"]):
            value = get(isamAppliance1, attribute_name=attr["name"])
            obj1['data'].append({attr["name"]: value["data"]["value"]})

    for attr in ret_obj2["data"]:
        if search(isamAppliance=isamAppliance2, attribute_name=attr["name"]):
            value = get(isamAppliance2, attribute_name=attr["name"])
            obj2['data'].append({attr["name"]: value["data"]["value"]})

    return tools.json_compare(obj1, obj2)
Beispiel #26
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare between two appliances
    """

    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    obj1_warnings = ret_obj1['warnings']
    obj2_warnings = ret_obj2['warnings']
    warnings = []

    if "Docker" in obj1_warnings or "Docker" in obj2_warnings:
        warnings.append(obj1_warnings)
        warnings.append(obj2_warnings)
        return isamAppliance1.create_return_object(changed=False,
                                                   warnings=warnings)

    obj1 = {'rc': 0, 'data': [], 'warnings': []}
    obj2 = {'rc': 0, 'data': [], 'warnings': []}

    for attr in ret_obj1["data"]:
        search_result, warnings = search(isamAppliance=isamAppliance1,
                                         attribute_name=attr["name"])
        if search_result is not False:
            value = get(isamAppliance1, attribute_name=attr["name"])
            obj1['data'].append({attr["name"]: value["data"]["value"]})
            obj1['warnings'].append(warnings)

    for attr in ret_obj2["data"]:
        search_result, warnings = search(isamAppliance=isamAppliance2,
                                         attribute_name=attr["name"])
        if search_result is not False:
            value = get(isamAppliance2, attribute_name=attr["name"])
            obj2['data'].append({attr["name"]: value["data"]["value"]})
            obj2['warnings'].append(warnings)

    return tools.json_compare(obj1, obj2)
Beispiel #27
0
def compare(isamAppliance1, isamAppliance2):
    """
    Compare API Protection Definitions between two appliances
    """
    ret_obj1 = get_all(isamAppliance1)
    ret_obj2 = get_all(isamAppliance2)

    for obj in ret_obj1['data']:
        del obj['id']
        del obj['datecreated']
        del obj['lastmodified']
        for rules in obj['mappingRules']:
            del rules['id']
    for obj in ret_obj2['data']:
        del obj['id']
        del obj['datecreated']
        del obj['lastmodified']
        for rules in obj['mappingRules']:
            del rules['id']

    return tools.json_compare(ret_obj1, ret_obj2,
                              deleted_keys=['id', 'datecreated', 'lastmodified',
                                            'mappingRules/id'])