Skip to content

Commit

Permalink
Remove the concept of host aliases
Browse files Browse the repository at this point in the history
Between playbook labels and the name of the hosts being searchable,
the host alias feature is redundant.

Change-Id: I0c09e8cf29ca8c82f9fdb496823eebb46f2739f4
  • Loading branch information
David Moreau Simard committed May 23, 2019
1 parent 89daa48 commit 0eea9bf
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 19 deletions.
4 changes: 1 addition & 3 deletions ara/api/migrations/0001_initial.py
Expand Up @@ -14,8 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with ARA. If not, see <http://www.gnu.org/licenses/>.

# Generated by Django 2.2.1 on 2019-05-17 10:13
# Generated by Django 2.2.1 on 2019-05-23 14:26

from django.db import migrations, models
import django.db.models.deletion
Expand Down Expand Up @@ -63,7 +62,6 @@ class Migration(migrations.Migration):
('updated', models.DateTimeField(auto_now=True)),
('name', models.CharField(max_length=255)),
('facts', models.BinaryField(max_length=4294967295)),
('alias', models.CharField(max_length=255, null=True)),
('changed', models.IntegerField(default=0)),
('failed', models.IntegerField(default=0)),
('ok', models.IntegerField(default=0)),
Expand Down
9 changes: 0 additions & 9 deletions ara/api/models.py
Expand Up @@ -210,15 +210,6 @@ class Meta:

name = models.CharField(max_length=255)
facts = models.BinaryField(max_length=(2 ** 32) - 1)
# Ansible doesn't supply a mechanism to uniquely identify a host out of
# the box.
# ARA can attempt to reconcile what it believes are the results same hosts
# based on user-supplied configuration or through a hashing algorithm.
# The goal is to "regroup" all unique hosts under a single alias if they
# are the same host.
# The logic for supplying aliases does not live here, it's provided by the
# clients and consumers.
alias = models.CharField(max_length=255, null=True)

changed = models.IntegerField(default=0)
failed = models.IntegerField(default=0)
Expand Down
2 changes: 1 addition & 1 deletion ara/api/serializers.py
Expand Up @@ -130,7 +130,7 @@ class Meta:
class NestedPlaybookHostSerializer(serializers.ModelSerializer):
class Meta:
model = models.Host
fields = ("id", "name", "alias")
fields = ("id", "name")


class NestedPlaybookResultSerializer(DurationSerializer):
Expand Down
1 change: 0 additions & 1 deletion ara/api/tests/factories.py
Expand Up @@ -100,7 +100,6 @@ class Meta:

facts = utils.compressed_obj(HOST_FACTS)
name = "hostname"
alias = "9f5d3ba7-e43d-4f3b-ab17-f90c39e43d07"
playbook = factory.SubFactory(PlaybookFactory)


Expand Down
8 changes: 3 additions & 5 deletions ara/plugins/callback/ara_default.py
Expand Up @@ -197,9 +197,7 @@ def v2_playbook_on_play_start(self, play):

# Record all the hosts involved in the play
for host in play.hosts:
hostvars = play_vars["hostvars"][host] if host in play_vars["hostvars"] else {}
host_alias = hostvars["ara_host_alias"] if "ara_host_alias" in hostvars else host
self._get_or_create_host(host=host, host_alias=host_alias)
self._get_or_create_host(host=host)

return self.play

Expand Down Expand Up @@ -300,10 +298,10 @@ def _get_or_create_file(self, path):

return self.client.post("/api/v1/files", playbook=self.playbook["id"], path=path, content=content)

def _get_or_create_host(self, host, host_alias=None):
def _get_or_create_host(self, host):
self.log.debug("Getting or creating host: %s" % host)
# Note: The get_or_create is handled through the serializer of the API server.
return self.client.post("/api/v1/hosts", name=host, alias=host_alias, playbook=self.playbook["id"])
return self.client.post("/api/v1/hosts", name=host, playbook=self.playbook["id"])

def _load_result(self, result, status, **kwargs):
"""
Expand Down

0 comments on commit 0eea9bf

Please sign in to comment.