def get_service(self): """ Return the Cloudera Management Services instance. @return: An ApiService instance. """ resp = self._get_resource_root().get("/cm/service") return ApiService.from_json_dict(resp, self._get_resource_root())
def get_service(self): """ Return the Cloudera Management Services instance. @return: An ApiService instance. """ resp = self._get_resource_root().get('/cm/service') return ApiService.from_json_dict(resp, self._get_resource_root())
def create_mgmt_service(self, service_setup_info): """ Setup the Cloudera Management Service. @param service_setup_info: ApiServiceSetupInfo object. @return: The management service instance. """ body = json.dumps(service_setup_info.to_json_dict()) resp = self._get_resource_root().put("/cm/service", data=body) return ApiService.from_json_dict(resp, self._get_resource_root())
def create_mgmt_service(self, service_setup_info): """ Setup the Cloudera Management Service. @param service_setup_info: ApiServiceSetupInfo object. @return: The management service instance. """ body = json.dumps(service_setup_info.to_json_dict()) resp = self._get_resource_root().put('/cm/service', data=body) return ApiService.from_json_dict(resp, self._get_resource_root())
def test_snapshot(self): service = ApiService(self.resource, 'hdfs1', 'HDFS') service.__dict__['clusterRef'] = ApiClusterRef(self.resource, clusterName='cluster1') hdfs_args = ApiHdfsSnapshotPolicyArguments(self.resource, pathPatterns='/user/oozie') return_policy = ApiSnapshotPolicy(self.resource, name='sn1', weeklySnapshots=2, hdfsArguments=hdfs_args) return_policy.__dict__['id'] = 1 return_list = ApiList([return_policy]).to_json_dict() self.resource.expect( "POST", "/clusters/cluster1/services/hdfs1/snapshots/policies", retdata=return_list) policy = service.create_snapshot_policy(return_policy) self._test_policy(return_policy, policy) self.resource.expect( "GET", "/clusters/cluster1/services/hdfs1/snapshots/policies", retdata=return_list) policies = service.get_snapshot_policies() self.assertEqual(1, len(policies)) self._test_policy(return_policy, policies[0]) self.resource.expect( "GET", "/clusters/cluster1/services/hdfs1/snapshots/policies/sn1", retdata=return_policy.to_json_dict()) self._test_policy(return_policy, service.get_snapshot_policy("sn1")) return_policy.dayOfWeek = 5 self.resource.expect( "PUT", "/clusters/cluster1/services/hdfs1/snapshots/policies/sn1", data=return_policy, retdata=return_policy.to_json_dict()) policy = service.update_snapshot_policy('sn1', return_policy) self._test_policy(return_policy, policy) self.resource.expect( "DELETE", "/clusters/cluster1/services/hdfs1/snapshots/policies/sn1", retdata=return_policy.to_json_dict()) policy = service.delete_snapshot_policy('sn1') self._test_policy(return_policy, policy)
def test_snapshot(self): service = ApiService(self.resource, 'hdfs1', 'HDFS') service.__dict__['clusterRef'] = ApiClusterRef(self.resource, clusterName='cluster1') hdfs_args = ApiHdfsSnapshotPolicyArguments(self.resource, pathPatterns='/user/oozie') return_policy = ApiSnapshotPolicy(self.resource, name='sn1', weeklySnapshots=2, hdfsArguments=hdfs_args) return_policy.__dict__['id'] = 1 return_list = ApiList([ return_policy ]).to_json_dict() self.resource.expect("POST", "/clusters/cluster1/services/hdfs1/snapshots/policies", retdata=return_list) policy = service.create_snapshot_policy(return_policy) self._test_policy(return_policy, policy) self.resource.expect("GET", "/clusters/cluster1/services/hdfs1/snapshots/policies", retdata=return_list) policies = service.get_snapshot_policies() self.assertEqual(1, len(policies)) self._test_policy(return_policy, policies[0]) self.resource.expect("GET", "/clusters/cluster1/services/hdfs1/snapshots/policies/sn1", retdata=return_policy.to_json_dict()) self._test_policy(return_policy, service.get_snapshot_policy("sn1")) return_policy.dayOfWeek=5 return_policy.paused=True self.resource.expect("PUT", "/clusters/cluster1/services/hdfs1/snapshots/policies/sn1", data=return_policy, retdata=return_policy.to_json_dict()) policy = service.update_snapshot_policy('sn1', return_policy) self._test_policy(return_policy, policy) self.resource.expect("DELETE", "/clusters/cluster1/services/hdfs1/snapshots/policies/sn1", retdata=return_policy.to_json_dict()) policy = service.delete_snapshot_policy('sn1') self._test_policy(return_policy, policy)
def test_replication_crud(self): service = ApiService(self.resource, 'hdfs1', 'HDFS') service.__dict__['clusterRef'] = ApiClusterRef(self.resource, clusterName='cluster1') hdfs_args = ApiHdfsReplicationArguments(self.resource) hdfs_args.sourceService = ApiServiceRef('cluster2', 'hdfs2') hdfs_args.sourcePath = '/src' hdfs_args.destinationPath = '/dst' return_sched = ApiReplicationSchedule(self.resource, interval=2, intervalUnit='DAY') return_sched.hdfsArguments = hdfs_args return_sched.__dict__['id'] = 1 return_list = ApiList([ return_sched ]).to_json_dict() self.resource.expect("POST", "/clusters/cluster1/services/hdfs1/replications", retdata=return_list) sched = service.create_replication_schedule( None, None, 'DAY', 2, True, hdfs_args, alert_on_fail=True) self.assertEqual(return_sched.intervalUnit, sched.intervalUnit) self.assertEqual(return_sched.interval, sched.interval) self.assertIsInstance(sched.hdfsArguments, ApiHdfsReplicationArguments) self.resource.expect("GET", "/clusters/cluster1/services/hdfs1/replications", retdata=return_list) service.get_replication_schedules() self.resource.expect("GET", "/clusters/cluster1/services/hdfs1/replications/1", retdata=return_sched.to_json_dict()) service.get_replication_schedule(1) self.resource.expect("PUT", "/clusters/cluster1/services/hdfs1/replications/1", retdata=return_sched.to_json_dict()) service.update_replication_schedule(1, return_sched) self.resource.expect("DELETE", "/clusters/cluster1/services/hdfs1/replications/1", retdata=return_sched.to_json_dict()) service.delete_replication_schedule(1)