diff --git a/compass/hdsdiscovery/hdmanager.py b/compass/hdsdiscovery/hdmanager.py index 38a19dbc..262dc6c2 100644 --- a/compass/hdsdiscovery/hdmanager.py +++ b/compass/hdsdiscovery/hdmanager.py @@ -101,11 +101,12 @@ class HDManager(object): :return a tuple (vendor, switch_state, error) """ - switch_lists = util.load_configs(setting.SWITCH_LIST_DIR) + switch_lists = util.load_configs(setting.MACHINE_LIST_DIR) switch_list = [] - for item in switch_lists: - if item and 'SWITCH_LIST' in item and item['SWITCH_LIST']: - switch_list.extend(item['SWITCH_LIST']) + for items in switch_lists: + for item in items['MACHINE_LIST']: + for k, v in item.items(): + switch_list.append(k) if host in switch_list: return ("appliance", "Found", "") diff --git a/compass/hdsdiscovery/vendors/appliance/plugins/mac.py b/compass/hdsdiscovery/vendors/appliance/plugins/mac.py index 4244eb13..6fec8abe 100644 --- a/compass/hdsdiscovery/vendors/appliance/plugins/mac.py +++ b/compass/hdsdiscovery/vendors/appliance/plugins/mac.py @@ -27,7 +27,9 @@ class Mac(base.BaseSnmpMacPlugin): """Processes MAC address.""" def __init__(self, host, credential): - return + self.host = host + #self.credential = credential + #return def scan(self): """Implemnets the scan method in BasePlugin class. @@ -36,8 +38,11 @@ class Mac(base.BaseSnmpMacPlugin): Dummy scan function for compass appliance. Returns fixed mac addresses. """ - mac_lists = util.load_configs(setting.MAC_LIST_DIR) mac_list = None - for item in mac_lists: - mac_list = item['MAC_LIST'] + machine_lists = util.load_configs(setting.MACHINE_LIST_DIR) + for items in machine_lists: + for item in items['MACHINE_LIST']: + for k, v in item.items(): + if k == self.host: + mac_list = v return mac_list diff --git a/compass/utils/setting_wrapper.py b/compass/utils/setting_wrapper.py index b660bf66..e029c130 100644 --- a/compass/utils/setting_wrapper.py +++ b/compass/utils/setting_wrapper.py @@ -116,11 +116,8 @@ CALLBACK_DIR = lazypy.delay( TMPL_DIR = lazypy.delay( lambda: os.path.join(CONFIG_DIR, 'templates') ) -MAC_LIST_DIR = lazypy.delay( - lambda: os.path.join(CONFIG_DIR, 'mac_list') -) -SWITCH_LIST_DIR = lazypy.delay( - lambda: os.path.join(CONFIG_DIR, 'switch_list') +MACHINE_LIST_DIR = lazypy.delay( + lambda: os.path.join(CONFIG_DIR, 'machine_list') ) PROXY_URL_PREFIX = 'http://10.145.81.205:5000' diff --git a/conf/mac_list/mac_list.conf b/conf/mac_list/mac_list.conf deleted file mode 100644 index 6485f6c1..00000000 --- a/conf/mac_list/mac_list.conf +++ /dev/null @@ -1,42 +0,0 @@ -MAC_LIST = [ - { - 'port': '200', - 'mac': '80:fb:06:35:8c:85', - 'vlan': 0, - }, - { - 'port': '201', - 'mac': '70:7b:e8:75:71:dc', - 'vlan': 0, - }, - { - 'port': '202', - 'mac': '80:fb:06:35:8c:a0', - 'vlan': 0, - }, - { - 'port': '203', - 'mac': '70:7b:e8:75:71:d3', - 'vlan': 0, - }, - { - 'port': '204', - 'mac': '70:7b:e8:75:72:21', - 'vlan': 0, - }, - { - 'port': '205', - 'mac': '70:7b:e8:75:71:37', - 'vlan': 0, - }, - { - 'port': '206', - 'mac': '70:fb:e8:75:71:d6', - 'vlan': 0, - }, - { - 'port': '207', - 'mac': '70:7b:e8:75:71:d9', - 'vlan': 0, - } -] diff --git a/conf/machine_list/machine_list.conf b/conf/machine_list/machine_list.conf new file mode 100644 index 00000000..a07ce517 --- /dev/null +++ b/conf/machine_list/machine_list.conf @@ -0,0 +1,46 @@ +MACHINE_LIST = [ + { + '127.0.0.1': [ + { + 'port': '200', + 'mac': '80:fb:06:35:8c:85', + 'vlan': 0, + }, + { + 'port': '201', + 'mac': '70:7b:e8:75:71:dc', + 'vlan': 0, + }, + { + 'port': '202', + 'mac': '80:fb:06:35:8c:a0', + 'vlan': 0, + }, + { + 'port': '203', + 'mac': '70:7b:e8:75:71:d3', + 'vlan': 0, + }, + { + 'port': '204', + 'mac': '70:7b:e8:75:72:21', + 'vlan': 0, + }, + { + 'port': '205', + 'mac': '70:7b:e8:75:71:37', + 'vlan': 0, + }, + { + 'port': '206', + 'mac': '70:fb:e8:75:71:d6', + 'vlan': 0, + }, + { + 'port': '207', + 'mac': '70:7b:e8:75:71:d9', + 'vlan': 0, + } + ] + }, +]