in curator/actions/create_index.py [0:0]
def do_action(self):
"""
:py:meth:`~.elasticsearch.client.IndicesClient.create` index identified
by :py:attr:`name` with values from :py:attr:`aliases`, :py:attr:`mappings`,
and :py:attr:`settings`
"""
msg = f'Creating index "{self.name}" with settings: {self.extra_settings}'
self.loggit.info(msg)
try:
self.client.indices.create(
index=self.name,
aliases=self.aliases,
mappings=self.mappings,
settings=self.settings,
)
# Most likely error is a 400, `resource_already_exists_exception`
except RequestError as err:
match_list = [
"index_already_exists_exception",
"resource_already_exists_exception",
]
if err.error in match_list:
if self.ignore_existing:
self.loggit.warning('Index %s already exists.', self.name)
else:
raise FailedExecution(f'Index {self.name} already exists.') from err
else:
msg = f'Unable to create index "{self.name}". Error: {err.error}'
raise FailedExecution(msg) from err
# pylint: disable=broad-except
except Exception as err:
report_failure(err)