Ejemplo n.º 1
0
from apache_ranger.model.ranger_service     import RangerService
from apache_ranger.client.ranger_client     import RangerClient

ranger_client = RangerClient('http://ranger:6080', 'admin', 'rangerR0cks!')

service = RangerService(name='dev_hbase', type='hbase', configs={'username':'******', 'password':'******', 'hadoop.security.authentication': 'simple', 'hbase.security.authentication': 'simple', 'hadoop.security.authorization': 'true', 'hbase.zookeeper.property.clientPort': '16181', 'hbase.zookeeper.quorum': 'ranger-hbase', 'zookeeper.znode.parent': '/hbase'})

ranger_client.create_service(service)
Ejemplo n.º 2
0
    # create a new service definition
    config       = RangerServiceConfigDef(itemId=1, name='sampleConfig', type='string')
    access_type  = RangerAccessTypeDef(itemId=1, name='sampleAccess')
    resource_def = RangerResourceDef(itemId=1, name='root', type='string')
    service_def  = RangerServiceDef(name=service_def_name, configs=[config], accessTypes=[access_type],
                                    resources=[resource_def])

    created_service_def = ranger_client.create_service_def(service_def)

    log.info('New Service Definition created successfully {}'.format(created_service_def))


    # create a new service
    service = RangerService(name=service_name, type=service_def_name)

    created_service = ranger_client.create_service(service)

    log.info('New Service created successfully {}'.format(created_service))


    # create a new policy
    resource = RangerPolicyResource(['/path/to/sample/resource'], False, False)
    policy   = RangerPolicy(service=service_name, name=policy_name, resources={'root': resource})

    created_policy = ranger_client.create_policy(policy)

    log.info('New Ranger Policy created successfully {}'.format(created_policy))


    # update an existing policy
    policy = RangerPolicy(service=service_name, name=policy_name, description='Policy Updated!')