def get_region_access_info(self, team_name, region_name): """获取一个团队在指定数据中心的身份认证信息""" url, token = client_auth_service.get_region_access_token_by_tenant(team_name, region_name) # 如果团队所在企业所属数据中心信息不存在则使用通用的配置(兼容未申请数据中心token的企业) region_info = region_repo.get_region_by_region_name(region_name) url = region_info.url if not token: token = region_info.token else: token = "Token {}".format(token) return url, token
def get_file_down_req(self, export_format, tenant_name, app): export_record = app_export_record_repo.get_export_record_by_unique_key(app.group_key, app.version, export_format) region = self.get_app_share_region(app) download_url = self.__get_down_url(region, export_record.file_path) file_name = export_record.file_path.split("/")[-1] url, token = client_auth_service.get_region_access_token_by_tenant( tenant_name, region) if not token: region_info = region_repo.get_region_by_region_name(region) if region_info: token = region_info.token req = urllib2.Request(download_url) if token: req.add_header("Authorization", "Token {}".format(token)) return req, file_name