summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraward <award@rentpath.com>2014-07-10 16:32:51 -0400
committeraward <award@rentpath.com>2014-07-10 16:32:51 -0400
commit95325f1ffbdeb9da06af0fcd83f85a2dcb6c8e92 (patch)
tree2f05045cfd05ce1b5cccadcb83f1f88de2164b0f
parentAdd hostgroup to the host description output (diff)
downloadansible-foreman-inventory-95325f1ffbdeb9da06af0fcd83f85a2dcb6c8e92.tar.gz
Add python 2.6 compatibility
Diffstat (limited to '')
-rwxr-xr-xtheforeman.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/theforeman.py b/theforeman.py
index 8bbd816..398c3ea 100755
--- a/theforeman.py
+++ b/theforeman.py
@@ -60,7 +60,7 @@ Version: 0.0.1
import sys
import os
import re
-import argparse
+import optparse
import ConfigParser
import collections
@@ -88,7 +88,10 @@ class ForemanInventory(object):
def _empty_cache(self):
"""Empty cache"""
keys = ['operatingsystem', 'hostgroup', 'environment', 'model', 'compute_resource', 'domain', 'subnet', 'architecture', 'host']
- return {k:{} for k in keys}
+ keys_d = {}
+ for i in keys:
+ keys_d[i] = {}
+ return keys_d
def __init__(self):
"""Main execution path"""
@@ -189,10 +192,10 @@ They must be specified via ini file.'''
def parse_cli_args(self):
"""Command line argument processing"""
- parser = argparse.ArgumentParser(description='Produce an Ansible Inventory file based on Foreman')
- parser.add_argument('--list', action='store_true', default=True, help='List instances (default: True)')
- parser.add_argument('--host', action='store', help='Get all the variables about a specific instance')
- self.args = parser.parse_args()
+ parser = optparse.OptionParser(description='Produce an Ansible Inventory file based on Foreman')
+ parser.add_option('--list', action='store_true', default=True, help='List instances (default: True)')
+ parser.add_option('--host', action='store', help='Get all the variables about a specific instance')
+ (self.args, self.options) = parser.parse_args()
def _get_os_from_id(self, os_id):
"""Get operating system name"""