From 09959fb2fd55d8b6ef9a821e68f128ccd20caeea Mon Sep 17 00:00:00 2001
From: shahaan <shahaan@gmail.com>
Date: Wed, 4 Feb 2015 10:37:28 +1100
Subject: [PATCH] New Dynamic Inventory from Chris

---
 dynamicInventory | 50 ------------------------------------------------
 1 file changed, 50 deletions(-)
 delete mode 100755 dynamicInventory

diff --git a/dynamicInventory b/dynamicInventory
deleted file mode 100755
index bfb6b4b9..00000000
--- a/dynamicInventory
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env python
-import sys, os, string, subprocess, socket, re
-import copy, shlex,uuid, random, multiprocessing, time, shutil, json
-import novaclient.v1_1.client as nvclient
-import novaclient.exceptions as nvexceptions
-
-class Authenticate:
-	
-	def __init__(self, username, passwd):
-		self.username=username
-		self.passwd=passwd
-		self.tenantName= os.environ['OS_TENANT_NAME']
-		self.tenantID= os.environ['OS_TENANT_ID']
-		self.authUrl="https://keystone.rc.nectar.org.au:5000/v2.0"
-	
-	def gatherInfo(self):
-
-		## Fetch the Nova Object
-
-		nc = nvclient.Client(	auth_url=self.authUrl,
-			username=self.username,
-			api_key=self.passwd,
-			project_id=self.tenantName,
-			tenant_id=self.tenantID,
-			service_type="compute"
-			)
-		inventory = {}
-		inventory['_meta'] = { 'hostvars': {} }
-		for server in nc.servers.list():
-			if server.metadata:
-				hostname = socket.gethostbyaddr(server.networks.values()[0][0])[0]
-				# Set Ansible Host Group
-				if server.metadata['ansible_host_group'] in inventory:
-					inventory[server.metadata['ansible_host_group']].append(hostname)
-				else:
-					inventory[server.metadata['ansible_host_group']] = [hostname]
-				# Set the other host variables
-				inventory['_meta']['hostvars'][hostname] = {}
-				inventory['_meta']['hostvars'][hostname]['ansible_ssh_user'] =  server.metadata['ansible_ssh_user']
-				inventory['_meta']['hostvars'][hostname]['ansible_ssh_private_key_file'] = server.metadata['ansible_ssh_private_key_file']	
-				
-			else:
-				continue
-		print json.dumps(inventory)
-
-if __name__ == "__main__":
-	username = os.environ['OS_USERNAME']
-	passwd = os.environ['OS_PASSWORD']
-	auth = Authenticate(username, passwd)
-	auth.gatherInfo()
-- 
GitLab