2
2
3
3
from cdpy .common import CdpSdkBase , Squelch , CdpError , CdpWarning
4
4
5
+ ENTITLEMENT_DISABLED = 'Datahubs not enabled on CDP Tenant'
6
+
5
7
6
8
class CdpyDatahub (CdpSdkBase ):
7
9
def __init__ (self , * args , ** kwargs ):
8
10
super ().__init__ (* args , ** kwargs )
9
11
10
12
def describe_cluster (self , name ):
11
13
return self .sdk .call (
12
- svc = 'datahub' , func = 'describe_cluster' , ret_field = 'cluster' , squelch = [Squelch ('NOT_FOUND' )],
14
+ svc = 'datahub' , func = 'describe_cluster' , ret_field = 'cluster' , squelch = [
15
+ Squelch ('NOT_FOUND' ),
16
+ Squelch (value = 'PATH_DISABLED' , warning = ENTITLEMENT_DISABLED )
17
+ ],
13
18
clusterName = name
14
19
)
15
20
16
21
def list_clusters (self , environment_name = None ):
17
22
return self .sdk .call (
18
23
svc = 'datahub' , func = 'list_clusters' , ret_field = 'clusters' , squelch = [
19
24
Squelch (value = 'INVALID_ARGUMENT' , default = list (),
20
- warning = 'No Datahubs found in Tenant or provided Environment %s' % str (environment_name ))
25
+ warning = 'No Datahubs found in Tenant or provided Environment %s' % str (environment_name )),
26
+ Squelch (value = 'PATH_DISABLED' , warning = ENTITLEMENT_DISABLED )
21
27
],
22
28
environmentName = environment_name
23
29
)
@@ -31,8 +37,10 @@ def describe_all_clusters(self, environment_name=None):
31
37
def list_cluster_templates (self , retries = 3 , delay = 5 ):
32
38
# Intermittent timeout issue in CDP 7.2.10, should be reverted to bare listing in 7.2.12
33
39
resp = self .sdk .call (
34
- svc = 'datahub' , func = 'list_cluster_templates' , ret_field = 'clusterTemplates' ,
35
- ret_error = True
40
+ svc = 'datahub' , func = 'list_cluster_templates' , ret_field = 'clusterTemplates' , squelch = [
41
+ Squelch (value = 'PATH_DISABLED' , warning = ENTITLEMENT_DISABLED )
42
+ ],
43
+ ret_error = True # if not a Squelch-able error, return for further review
36
44
)
37
45
if isinstance (resp , CdpError ):
38
46
if retries > 0 :
@@ -49,38 +57,72 @@ def list_cluster_templates(self, retries=3, delay=5):
49
57
return resp
50
58
51
59
def describe_cluster_template (self , name ):
52
- return self .sdk .call (svc = 'datahub' , func = 'describe_cluster_template' , ret_field = 'clusterTemplate' , squelch = [
53
- Squelch (value = 'NOT_FOUND' )], clusterTemplateName = name )
60
+ return self .sdk .call (
61
+ svc = 'datahub' , func = 'describe_cluster_template' , squelch = [
62
+ Squelch (value = 'NOT_FOUND' ),
63
+ Squelch (value = 'PATH_DISABLED' , warning = ENTITLEMENT_DISABLED )
64
+ ],
65
+ ret_field = 'clusterTemplate' , clusterTemplateName = name
66
+ )
54
67
55
68
def delete_cluster (self , name ):
56
- return self .sdk .call (svc = 'datahub' , func = 'delete_cluster' , clusterName = name )
69
+ return self .sdk .call (
70
+ svc = 'datahub' , func = 'delete_cluster' , squelch = [
71
+ Squelch (value = 'PATH_DISABLED' , warning = ENTITLEMENT_DISABLED )
72
+ ],
73
+ clusterName = name
74
+ )
57
75
58
76
def delete_cluster_templates (self , names ):
59
77
names = names if isinstance (names , list ) else [names ]
60
- return self .sdk .call (svc = 'datahub' , func = 'delete_cluster_templates' , squelch = [Squelch (value = 'NOT_FOUND' )],
61
- ret_field = 'clusterTemplates' , clusterTemplateNames = names )
78
+ return self .sdk .call (
79
+ svc = 'datahub' , func = 'delete_cluster_templates' , squelch = [
80
+ Squelch (value = 'NOT_FOUND' ),
81
+ Squelch (value = 'PATH_DISABLED' , warning = ENTITLEMENT_DISABLED )
82
+ ],
83
+ ret_field = 'clusterTemplates' , clusterTemplateNames = names
84
+ )
62
85
63
86
def create_cluster_template (self , name , description , content ):
64
87
return self .sdk .call (
65
- svc = 'datahub' , func = 'create_cluster_template' , ret_field = 'clusterTemplate' ,
66
- clusterTemplateName = name , description = description , clusterTemplateContent = content
88
+ svc = 'datahub' , func = 'create_cluster_template' , squelch = [
89
+ Squelch (value = 'PATH_DISABLED' , warning = ENTITLEMENT_DISABLED )
90
+ ],
91
+ ret_field = 'clusterTemplate' , clusterTemplateName = name ,
92
+ description = description , clusterTemplateContent = content
67
93
)
68
94
69
95
def list_cluster_definitions (self ):
70
- return self .sdk .call (svc = 'datahub' , func = 'list_cluster_definitions' , ret_field = 'clusterDefinitions' )
96
+ return self .sdk .call (
97
+ svc = 'datahub' , func = 'list_cluster_definitions' , squelch = [
98
+ Squelch (value = 'PATH_DISABLED' , warning = ENTITLEMENT_DISABLED )
99
+ ],
100
+ ret_field = 'clusterDefinitions'
101
+ )
71
102
72
103
def describe_cluster_definition (self , name ):
73
- return self .sdk .call (svc = 'datahub' , func = 'describe_cluster_definition' , ret_field = 'clusterDefinition' , squelch = [
74
- Squelch (value = 'NOT_FOUND' )], clusterDefinitionName = name )
104
+ return self .sdk .call (
105
+ svc = 'datahub' , func = 'describe_cluster_definition' , squelch = [
106
+ Squelch (value = 'NOT_FOUND' ),
107
+ Squelch (value = 'PATH_DISABLED' , warning = ENTITLEMENT_DISABLED )
108
+ ],
109
+ ret_field = 'clusterDefinition' , clusterDefinitionName = name
110
+ )
75
111
76
112
def start_cluster (self , name ):
77
113
return self .sdk .call (
78
- svc = 'datahub' , func = 'start_cluster' , squelch = [Squelch ('NOT_FOUND' )],
114
+ svc = 'datahub' , func = 'start_cluster' , squelch = [
115
+ Squelch ('NOT_FOUND' ),
116
+ Squelch (value = 'PATH_DISABLED' , warning = ENTITLEMENT_DISABLED )
117
+ ],
79
118
clusterName = name
80
119
)
81
120
82
121
def stop_cluster (self , name ):
83
122
return self .sdk .call (
84
- svc = 'datahub' , func = 'stop_cluster' , squelch = [Squelch ('NOT_FOUND' )],
123
+ svc = 'datahub' , func = 'stop_cluster' , squelch = [
124
+ Squelch ('NOT_FOUND' ),
125
+ Squelch (value = 'PATH_DISABLED' , warning = ENTITLEMENT_DISABLED )
126
+ ],
85
127
clusterName = name
86
128
)
0 commit comments