def __init__(self): LOG.info("xh: compass_server=%s" % CONF.compass_server) self.client = Client(CONF.compass_server) self.subnet_mapping = {} self.role_mapping = {} self.host_mapping = {} self.host_ips = defaultdict(list) self.host_roles = {} self.login()
'ROLES_LIST': ['allinone-compute'], 'MACHINES_TO_ADD': ['00:0c:29:a7:ea:4b'], 'BUILD_TIMEOUT': 60, 'SEARCH_PATH': ['ods.com'], 'SERVER_USERNAME': '******', 'SERVER_PASSWORD': '******' } for v in PRESET_VALUES: if v in os.environ.keys(): PRESET_VALUES[v] = os.environ.get(v) print(v + PRESET_VALUES[v] + " is set by env variables") else: print(PRESET_VALUES[v]) # instantiate a client client = Client(COMPASS_SERVER_URL) # login status, response = client.login(COMPASS_LOGIN_EMAIL, COMPASS_LOGIN_PASSWORD) print '============================================================' print 'login status: %s response: %s' % (status, response) if status >= 400: sys.exit(1) # list all switches status, response = client.list_switches() print '=============================================================' print 'get all switches status: %s response: %s' % (status, response) # add a switch status, response = client.add_switch(SWITCH_IP, SWITCH_SNMP_VERSION,