Skip to content

Commit

Permalink
feat: copy logstore support keep config name (#309)
Browse files Browse the repository at this point in the history
* copy logstore support use same config name
  • Loading branch information
crimson-gao authored Dec 17, 2024
1 parent 8e3346e commit 771d0a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions aliyun/log/logclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -3077,7 +3077,7 @@ def copy_project(self, from_project, to_project, to_client=None, copy_machine_gr
to_client = self
return copy_project(self, to_client, from_project, to_project, copy_machine_group)

def copy_logstore(self, from_project, from_logstore, to_logstore, to_project=None, to_client=None, to_region_endpoint=None):
def copy_logstore(self, from_project, from_logstore, to_logstore, to_project=None, to_client=None, to_region_endpoint=None, keep_config_name=False):
"""
copy logstore, index, logtail config to target logstore, machine group are not included yet.
the target logstore will be crated if not existing
Expand All @@ -3102,7 +3102,7 @@ def copy_logstore(self, from_project, from_logstore, to_logstore, to_project=Non
:return:
"""
return copy_logstore(self, from_project, from_logstore, to_logstore, to_project=to_project, to_client=to_client, to_region_endpoint=to_region_endpoint)
return copy_logstore(self, from_project, from_logstore, to_logstore, to_project=to_project, to_client=to_client, to_region_endpoint=to_region_endpoint, keep_config_name=keep_config_name)

def list_project(self, offset=0, size=100, project_name_pattern=None, resource_group_id=''):
""" list the project
Expand Down
11 changes: 8 additions & 3 deletions aliyun/log/logclient_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def copy_project(from_client, to_client, from_project, to_project, copy_machine_
break


def copy_logstore(from_client, from_project, from_logstore, to_logstore, to_project=None, to_client=None, to_region_endpoint=None):
def copy_logstore(from_client, from_project, from_logstore, to_logstore, to_project=None, to_client=None, to_region_endpoint=None, keep_config_name=False):
"""
copy logstore, index, logtail config to target logstore, machine group are not included yet.
the target logstore will be crated if not existing
Expand All @@ -211,6 +211,9 @@ def copy_logstore(from_client, from_project, from_logstore, to_logstore, to_proj
:type to_region_endpoint: string
:param to_region_endpoint: target region, use it to operate on the "to_project" while "to_client" not be specified
:type keep_config_name: bool
:param keep_config_name: use the same logtail config name as the source one, note that the config name must be unique in the same project
:return:
"""
Expand Down Expand Up @@ -299,8 +302,10 @@ def copy_logstore(from_client, from_project, from_logstore, to_logstore, to_proj
config = ret.logtail_config
if config.logstore_name != from_logstore:
continue

config.config_name = to_logstore + '_' + config_name
if keep_config_name:
config.config_name = config_name
else:
config.config_name = to_logstore + '_' + config_name
config.logstore_name = to_logstore
ret = to_client.create_logtail_config(to_project, config)

Expand Down
2 changes: 1 addition & 1 deletion aliyun/log/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.9.12'
__version__ = '0.9.13rc1'

import sys
OS_VERSION = str(sys.platform)
Expand Down

0 comments on commit 771d0a2

Please sign in to comment.