@@ -111,42 +111,20 @@ def convert_virtual_dns_to_identifier(cf, virtual_dns_name):
111111
112112 exit ('cli4: %s - no virtual_dns found' % (virtual_dns_name ))
113113
114- def convert_load_balancers_map_to_identifier (cf , map_name ):
115- """load balancer map names to numbers"""
114+ def convert_load_balancers_pool_to_identifier (cf , pool_name ):
115+ """load balancer pool names to numbers"""
116116 try :
117- maps = cf .user .load_balancers .maps .get ()
117+ pools = cf .user .load_balancers .pools .get ()
118118 except CloudFlare .exceptions .CloudFlareAPIError as e :
119- exit ('cli4: %s - %d %s' % (map_name , e , e ))
119+ exit ('cli4: %s - %d %s' % (pool_name , e , e ))
120120 except Exception as e :
121- exit ('cli4: %s - %s' % (map_name , e ))
122-
123- for m in maps :
124- if map_name == m ['description' ]:
125- return m ['id' ]
126-
127- exit ('cli4: %s - no maps found' % (map_name ))
128-
129- def convert_load_balancers_map_regions (cf , region_name ):
130- """load balancer map regions"""
131- # this will/must go away; however it allows :WNAM etc in path.
132- regions = {
133- 'WNAM' , # Western North America
134- 'ENAM' , # Eastern North America
135- 'EU' , # Europe
136- 'NSAM' , # Northern South America
137- 'SSAM' , # Southern South America
138- 'OC' , # Oceania
139- 'ME' , # Middle East
140- 'NAF' , # Northern Africa
141- 'SAF' , # Southern Africa
142- 'IN' , # India
143- 'SEAS' , # Southeast Asia
144- 'NEAS' , # Northeast Asia
145- 'CHINA' # China
146- }
147- if region_name in regions :
148- return region_name
149- exit ('cli4: %s - no region found' % (region_name ))
121+ exit ('cli4: %s - %s' % (pool_name , e ))
122+
123+ for p in pools :
124+ if pool_name == p ['description' ]:
125+ return p ['id' ]
126+
127+ exit ('cli4: %s - no pools found' % (pool_name ))
150128
151129def dump_commands (cf ):
152130 """dump a tree of all the known API commands"""
@@ -314,8 +292,8 @@ def cli4(args):
314292 identifier1 = convert_invites_to_identifier (cf , element )
315293 elif (cmd [0 ] == 'user' ) and (cmd [1 ] == 'virtual_dns' ):
316294 identifier1 = convert_virtual_dns_to_identifier (cf , element )
317- elif (cmd [0 ] == 'user' ) and (cmd [1 ] == 'load_balancers' ) and (cmd [2 ] == 'maps ' ):
318- identifier1 = convert_load_balancers_map_to_identifier (cf , element )
295+ elif (cmd [0 ] == 'user' ) and (cmd [1 ] == 'load_balancers' ) and (cmd [2 ] == 'pools ' ):
296+ identifier1 = convert_load_balancers_pool_to_identifier (cf , element )
319297 else :
320298 exit ("/%s/%s :NOT CODED YET 1" % ('/' .join (cmd ), element ))
321299 cmd .append (':' + identifier1 )
@@ -325,11 +303,6 @@ def cli4(args):
325303 identifier2 = element
326304 elif (cmd [0 ] and cmd [0 ] == 'zones' ) and (cmd [2 ] and cmd [2 ] == 'dns_records' ):
327305 identifier2 = convert_dns_record_to_identifier (cf , identifier1 , element )
328- elif ((cmd [0 ] == 'user' ) and
329- (cmd [1 ] == 'load_balancers' ) and
330- (cmd [2 ] == 'maps' ) and
331- (cmd [4 ] == 'region' )):
332- identifier2 = convert_load_balancers_map_regions (cf , element )
333306 else :
334307 exit ("/%s/%s :NOT CODED YET 2" % ('/' .join (cmd ), element ))
335308 # identifier2 may be an array - this needs to be dealt with later
0 commit comments