【发布时间】:2017-08-20 07:42:05
【问题描述】:
我正在使用 python boto 编写 AWS Elasticsearch 快照备份/恢复实现。我能够将 AWS S3 注册为 ES 快照存储库。这是我的创建快照功能的 sn-p。
import boto
import urllib
from boto.connection import AWSAuthConnection
class ESConnection(AWSAuthConnection):
def __init__(self, region, **kwargs):
super(ESConnection, self).__init__(**kwargs)
self._set_auth_region_name(region)
self._set_auth_service_name("es")
def _required_auth_capability(self):
return ['hmac-v4']
def create_snapshots(profile, region_name, es_host,total_snapshots_to_keep):
.
.
.
url = "/_snapshot/es_repository/{}?".format(snapshot_name)
flag = urllib.urlencode({'wait_for_completion':'true'})
resp = client.make_request(method='PUT',
path=urllib.quote("{}{}".format(url,flag)),
data='{"indices": "' + audit_index_name + '", "ignore_unavailable": true, "include_global_state": false}')
主要问题似乎在 sn-p 上面,我正在尝试为
构造一个 url{u'status': 400, u'error': {u'root_cause': [{u'reason': u'[es_repository:v4_2017_03_27_snapshot?wait_for_completion=true] 无效的快照名称 [v4_2017_03_27_snapshot?wait_for_completion=true],不得包含 以下字符 [\, /, *, ?, ", , |, , ,]', u'type': u'invalid_snapshot_name_exception'}],u'type': 你'invalid_snapshot_name_exception',你'原因': u'[es_repository:v4_2017_03_27_snapshot?wait_for_completion=true] 无效的快照名称 [v4_2017_03_27_snapshot?wait_for_completion=true],不得包含 以下字符 [\, /, *, ?, ", , |, , ,]'}}
它将我的实际快照名称和 wait_for_completion 标志完全作为快照名称
快照名称无效 [v4_2017_03_27_snapshot?wait_for_completion=true],不得包含 以下字符 [\, /, *, ?, ", , |, , ,]'}}
您能否帮我指出我在为 elasticsearch 构建 url 时做错的地方?或者有没有更好的方法来实现这一点?
【问题讨论】:
标签: python amazon-web-services elasticsearch boto amazon-elasticsearch