Exemple #1
0
    def test_get_success(self, mock_session):
        response = RangerService()
        mock_session.return_value.get.return_value = MockResponse(
            HTTPStatus.OK, response=response, content='Success')
        result = RangerClient(TestRangerClient.URL, TestRangerClient.USERNAME,
                              TestRangerClient.PASSWORD).find_services({})

        self.assertTrue(response.__repr__() in result)
Exemple #2
0
    def test_get_success(self, mock_session):
        response = [RangerService()]
        mock_session.return_value.get.return_value = MockResponse(
            HTTPStatus.OK, response=response, content='Success')
        result = RangerClient(TestRangerClient.URL,
                              TestRangerClient.AUTH).find_services()

        self.assertEqual(response, result)
Exemple #3
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)
Exemple #4
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_kafka',
                        type='kafka',
                        configs={
                            'username': '******',
                            'password': '******',
                            'zookeeper.connect': 'ranger-kafka:2181'
                        })

ranger_client.create_service(service)
Exemple #5
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_hive', 'type': 'hive', 'configs': {'username':'******', 'password':'******', 'jdbc.driverClassName': 'org.apache.hive.jdbc.HiveDriver', 'jdbc.url': 'jdfb:hive2://ranger-hadoop:10000', 'hadoop.security.authorization': 'true'}})

ranger_client.create_service(service)
Exemple #6
0
    def get_service(self, serviceName):
        ret = self.__call_api_with_url_params(
            RangerClient.GET_SERVICE_BY_NAME,
            {RangerClient.PARAM_NAME: serviceName}, {}, {})

        return RangerService(**ret) if ret is not None else None
Exemple #7
0
    def update_service(self, serviceName, service):
        ret = self.__call_api_with_url_params(
            RangerClient.UPDATE_SERVICE_BY_NAME,
            {RangerClient.PARAM_NAME: serviceName}, {}, service)

        return RangerService(**ret) if ret is not None else None
Exemple #8
0
    def get_service_by_id(self, serviceId):
        ret = self.__call_api_with_url_params(
            RangerClient.GET_SERVICE_BY_ID, {RangerClient.PARAM_ID: serviceId},
            {}, {})

        return RangerService(**ret) if ret is not None else None
Exemple #9
0
    def create_service(self, service):
        ret = self.__call_api(RangerClient.CREATE_SERVICE, {}, service)

        return RangerService(**ret) if ret is not None else None
Exemple #10
0
    def update_service_by_id(self, serviceId, service):
        ret = self.__call_api_with_url_params(
            RangerClient.UPDATE_SERVICE_BY_ID,
            {RangerClient.PARAM_ID: serviceId}, {}, service)

        return RangerService(**ret) if ret is not None else None
Exemple #11
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_kafka',
    'type': 'kafka',
    'configs': {
        'username': '******',
        'password': '******',
        'zookeeper.connect': 'ranger-kafka:2181'
    }
})

ranger_client.create_service(service)
Exemple #12
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_hdfs',
                        type='hdfs',
                        configs={
                            'username': '******',
                            'password': '******',
                            'fs.default.name': 'hdfs://ranger-hadoop:9000',
                            'hadoop.security.authentication': 'simple',
                            'hadoop.security.authorization': 'true'
                        })

ranger_client.create_service(service)
Exemple #13
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))

Exemple #14
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_knox',
    'type': 'knox',
    'configs': {
        'username': '******',
        'password': '******',
        'knox.url': 'http://ranger-hadoop:8088'
    }
})

ranger_client.create_service(service)
Exemple #15
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_yarn',
                        type='yarn',
                        configs={
                            'username': '******',
                            'password': '******',
                            'yarn.url': 'http://ranger-hadoop:8088'
                        })

ranger_client.create_service(service)