22
33from cdpy .common import CdpSdkBase , Squelch , CdpError , CdpWarning
44
5+ ENTITLEMENT_DISABLED = 'Datahubs not enabled on CDP Tenant'
6+
57
68class CdpyDatahub (CdpSdkBase ):
79 def __init__ (self , * args , ** kwargs ):
810 super ().__init__ (* args , ** kwargs )
911
1012 def describe_cluster (self , name ):
1113 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+ ],
1318 clusterName = name
1419 )
1520
1621 def list_clusters (self , environment_name = None ):
1722 return self .sdk .call (
1823 svc = 'datahub' , func = 'list_clusters' , ret_field = 'clusters' , squelch = [
1924 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 )
2127 ],
2228 environmentName = environment_name
2329 )
@@ -31,8 +37,10 @@ def describe_all_clusters(self, environment_name=None):
3137 def list_cluster_templates (self , retries = 3 , delay = 5 ):
3238 # Intermittent timeout issue in CDP 7.2.10, should be reverted to bare listing in 7.2.12
3339 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
3644 )
3745 if isinstance (resp , CdpError ):
3846 if retries > 0 :
@@ -49,38 +57,72 @@ def list_cluster_templates(self, retries=3, delay=5):
4957 return resp
5058
5159 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+ )
5467
5568 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+ )
5775
5876 def delete_cluster_templates (self , names ):
5977 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+ )
6285
6386 def create_cluster_template (self , name , description , content ):
6487 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
6793 )
6894
6995 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+ )
71102
72103 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+ )
75111
76112 def start_cluster (self , name ):
77113 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+ ],
79118 clusterName = name
80119 )
81120
82121 def stop_cluster (self , name ):
83122 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+ ],
85127 clusterName = name
86128 )
0 commit comments