text
stringlengths 0
828
|
---|
Find the most suitable mapper that the client wants and we support.
|
:returns: the preferred mapper based on the accept header or ``None``.
|
""""""
|
accepts = util.parse_accept_header(request.META.get(""HTTP_ACCEPT"", """"))
|
if not accepts:
|
return None
|
for accept in accepts:
|
if accept[0] in self._datamappers:
|
return accept[0]
|
raise errors.NotAcceptable()"
|
4609,"def _get_name_from_url(self, request):
|
"""""" Determine short name for the mapper based on the URL.
|
Short name can be either in query string (e.g. ?format=json)
|
or as an extension to the URL (e.g. myresource.json).
|
:returns: short name of the mapper or ``None`` if not found.
|
""""""
|
format = request.GET.get('format', None)
|
if not format:
|
match = self._format_query_pattern.match(request.path)
|
if match and match.group('format'):
|
format = match.group('format')
|
return format"
|
4610,"def _check_mapper(self, mapper):
|
"""""" Check that the mapper has valid signature. """"""
|
if not hasattr(mapper, 'parse') or not callable(mapper.parse):
|
raise ValueError('mapper must implement parse()')
|
if not hasattr(mapper, 'format') or not callable(mapper.format):
|
raise ValueError('mapper must implement format()')"
|
4611,"def setup_cluster(self, cluster, extra_args=tuple()):
|
""""""
|
Configure the cluster by running an Ansible playbook.
|
The ElastiCluster configuration attribute `<kind>_groups`
|
determines, for each node kind, what Ansible groups nodes of
|
that kind are assigned to.
|
:param cluster: cluster to configure
|
:type cluster: :py:class:`elasticluster.cluster.Cluster`
|
:param list extra_args:
|
List of additional command-line arguments
|
that are appended to each invocation of the setup program.
|
:return: ``True`` on success, ``False`` otherwise. Please note, if nothing
|
has to be configured, then ``True`` is returned.
|
:raises: `ConfigurationError` if the playbook can not be found
|
or is corrupt.
|
""""""
|
inventory_path = self._build_inventory(cluster)
|
if inventory_path is None:
|
# No inventory file has been created, maybe an
|
# invalid class has been specified in config file? Or none?
|
# assume it is fine.
|
elasticluster.log.info(""No setup required for this cluster."")
|
return True
|
assert os.path.exists(inventory_path), (
|
""inventory file `{inventory_path}` does not exist""
|
.format(inventory_path=inventory_path))
|
# build list of directories to search for roles/include files
|
ansible_roles_dirs = [
|
# include Ansible default first ...
|
'/etc/ansible/roles',
|
]
|
for root_path in [
|
# ... then ElastiCluster's built-in defaults
|
resource_filename('elasticluster', 'share/playbooks'),
|
# ... then wherever the playbook is
|
os.path.dirname(self._playbook_path),
|
]:
|
for path in [
|
root_path,
|
os.path.join(root_path, 'roles'),
|
]:
|
if path not in ansible_roles_dirs and os.path.exists(path):
|
ansible_roles_dirs.append(path)
|
# Use env vars to configure Ansible;
|
# see all values in https://github.com/ansible/ansible/blob/devel/lib/ansible/constants.py
|
#
|
# Ansible does not merge keys in configuration files: rather
|
# it uses the first configuration file found. However,
|
# environment variables can be used to selectively override
|
# parts of the config; according to [1]: ""they are mostly
|
# considered to be a legacy system as compared to the config
|
# file, but are equally valid.""
|
#
|
# [1]: http://docs.ansible.com/ansible/intro_configuration.html#environmental-configuration
|
#
|
# Provide default values for important configuration variables...
|
ansible_env = {
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.