@@ -129,11 +129,11 @@ def http_delete(url, data, headers=None, verify=False, cert=None, timeout=None,
129129
130130
131131class Client (object ):
132- def __init__ (self , app_code , app_secret , bk_apigateway_url , tenant_id = "" ):
132+ def __init__ (self , app_code , app_secret , bk_apigateway_url , bk_tenant_id = "" ):
133133 self .app_code = app_code
134134 self .app_secret = app_secret
135135 self .bk_apigateway_url = bk_apigateway_url .rstrip ("/" )
136- self .tenant_id = tenant_id
136+ self .bk_tenant_id = bk_tenant_id
137137 self .system_id_set = set ()
138138 self .resource_id_set = set ()
139139 self .action_id_set = set ()
@@ -143,8 +143,8 @@ def _call_iam_api(self, http_func, path, data):
143143 headers = {
144144 "X-Bkapi-Authorization" : json .dumps ({"bk_app_code" : self .app_code , "bk_app_secret" : self .app_secret }),
145145 }
146- if self .tenant_id :
147- headers ["X-Bk-Tenant-Id" ] = self .tenant_id
146+ if self .bk_tenant_id :
147+ headers ["X-Bk-Tenant-Id" ] = self .bk_tenant_id
148148
149149 url = "{host}{path}" .format (host = self .bk_apigateway_url , path = path )
150150 ok , _data = http_func (url , data , headers = headers )
@@ -561,7 +561,7 @@ def api_ping(bk_apigateway_url):
561561 return ok , data
562562
563563
564- def do_migrate (data , bk_apigateway_url = BK_APIGATEWAY_URL , app_code = APP_CODE , app_secret = APP_SECRET , tenant_id = "" ):
564+ def do_migrate (data , bk_apigateway_url = BK_APIGATEWAY_URL , app_code = APP_CODE , app_secret = APP_SECRET , bk_tenant_id = "" ):
565565 system_id = data .get ("system_id" )
566566 if not system_id :
567567 print ("invald json. [system_id] required, and should not be empty" )
@@ -574,7 +574,7 @@ def do_migrate(data, bk_apigateway_url=BK_APIGATEWAY_URL, app_code=APP_CODE, app
574574
575575 print ("do migrate" )
576576
577- client = Client (app_code , app_secret , bk_apigateway_url , tenant_id = tenant_id )
577+ client = Client (app_code , app_secret , bk_apigateway_url , bk_tenant_id = bk_tenant_id )
578578
579579 # 1. query all data of the system
580580 system_ids , resource_type_ids , action_ids , instance_selection_ids = client .query_all_models (system_id )
@@ -626,15 +626,17 @@ def do_migrate(data, bk_apigateway_url=BK_APIGATEWAY_URL, app_code=APP_CODE, app
626626 )
627627 p .add_argument ("-a" , action = "store" , dest = "app_code" , help = "app code" , required = True )
628628 p .add_argument ("-s" , action = "store" , dest = "app_secret" , help = "app secret" , required = True )
629- p .add_argument ("--tenant_id" , action = "store" , dest = "tenant_id" , help = "tenant id" , default = "" , required = False )
629+ p .add_argument (
630+ "--bk_tenant_id" , action = "store" , dest = "bk_tenant_id" , help = "blueking tenant id" , default = "" , required = False
631+ )
630632
631633 args = p .parse_args ()
632634
633635 data_file = args .json_data_file
634636 APP_CODE = args .app_code
635637 APP_SECRET = args .app_secret
636638 BK_APIGATEWAY_URL = args .bk_apigateway_url .rstrip ("/" )
637- tenant_id = args .tenant_id
639+ bk_tenant_id = args .bk_tenant_id
638640
639641 # test ping
640642 ok , _ = api_ping (BK_APIGATEWAY_URL )
@@ -649,7 +651,7 @@ def do_migrate(data, bk_apigateway_url=BK_APIGATEWAY_URL, app_code=APP_CODE, app
649651 if not data :
650652 exit (1 )
651653
652- ok = do_migrate (data , BK_APIGATEWAY_URL , APP_CODE , APP_SECRET , tenant_id = tenant_id )
654+ ok = do_migrate (data , BK_APIGATEWAY_URL , APP_CODE , APP_SECRET , bk_tenant_id = bk_tenant_id )
653655 if not ok :
654656 print ("do migrate [%s] fail" % data_file )
655657 exit (1 )
0 commit comments