get mac and switch from config file.
Change-Id: I048057d7d5804478e331ebf92bbe299bb029d7ed
This commit is contained in:
parent
603b7cab4e
commit
c5bb8f17f6
@ -19,6 +19,8 @@ import re
|
||||
|
||||
from compass.hdsdiscovery.error import TimeoutError
|
||||
from compass.hdsdiscovery import utils
|
||||
from compass.utils import setting_wrapper as setting
|
||||
from compass.utils import util
|
||||
|
||||
|
||||
UNREACHABLE = 'unreachable'
|
||||
@ -99,7 +101,11 @@ class HDManager(object):
|
||||
:return a tuple (vendor, switch_state, error)
|
||||
"""
|
||||
|
||||
if host == '127.0.0.1':
|
||||
switch_lists = util.load_configs(setting.SWITCH_LIST_DIR)
|
||||
switch_list = None
|
||||
for item in switch_lists:
|
||||
switch_list = item['SWITCH_LIST']
|
||||
if host in switch_list:
|
||||
return ("appliance", "Found", "")
|
||||
|
||||
# TODO(grace): Why do we need to have valid IP?
|
||||
|
@ -14,6 +14,11 @@
|
||||
|
||||
"""Compass Appliance Mac module."""
|
||||
from compass.hdsdiscovery import base
|
||||
from compass.utils import setting_wrapper as setting
|
||||
from compass.utils import util
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
CLASS_NAME = "Mac"
|
||||
|
||||
@ -31,42 +36,8 @@ class Mac(base.BaseSnmpMacPlugin):
|
||||
Dummy scan function for compass appliance.
|
||||
Returns fixed mac addresses.
|
||||
"""
|
||||
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,
|
||||
}]
|
||||
mac_lists = util.load_configs(setting.MAC_LIST_DIR)
|
||||
mac_list = None
|
||||
for item in mac_lists:
|
||||
mac_list = item['MAC_LIST']
|
||||
return mac_list
|
||||
|
@ -116,6 +116,12 @@ 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')
|
||||
)
|
||||
PROXY_URL_PREFIX = 'http://10.145.81.205:5000'
|
||||
|
||||
if (
|
||||
|
42
conf/mac_list/mac_list.conf
Normal file
42
conf/mac_list/mac_list.conf
Normal file
@ -0,0 +1,42 @@
|
||||
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,
|
||||
}
|
||||
]
|
3
conf/switch_list/switch_list.conf
Normal file
3
conf/switch_list/switch_list.conf
Normal file
@ -0,0 +1,3 @@
|
||||
SWITCH_LIST = [
|
||||
'127.0.0.1'
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user