def get_all_switch(self, conf): resp = [] try: resp = mul_nbapi.get_switch_all() except: return None return self.json_serializer.nbapi_switch_brief_list_t_serialization(resp)
def __init__(self): self.json_serializer = mlapi_json_serialization() self.json_deserializer = mlapi_json_deserialization() self.flow_tbl={} self.fab_host_tbl={} self.alias_map = {} self.db_client = MongoClient(DB_HOST, DB_PORT) self.db = self.db_client[DB_NAME] self.err = Error() ''' Make API and DB mapping table ''' ServiceChainMgr_package = __import__('kulcloud.api.v1') ServiceChainMgr_module = getattr(ServiceChainMgr_package, 'ServiceChainManager') ServiceChainMgr_validator = getattr(ServiceChainMgr_module, 'input_validation') NFVTopologyMgr_package = __import__('kulcloud.api.v1') NFVTopologyMgr_module = getattr(NFVTopologyMgr_package, 'NFVTopologyManager') NFVTopologyMgr_validator = getattr(NFVTopologyMgr_module, 'input_validation') ServiceChainDefaultRuleMgr_package = __import__('kulcloud.api.v1') ServiceChainDefaultRuleMgr_module = getattr(ServiceChainDefaultRuleMgr_package, 'ServiceChainDefaultRuleManager') ServiceChainDefaultRuleMgr_validator = getattr(ServiceChainDefaultRuleMgr_module, 'input_validation') self.db_collection['NFVGroupMgr']={'name':'NFVGroupMgr', 'keys':['name'], 'validator':None} self.db_collection['NFVTopologyMgr']={'name':'NFVTopologyMgr', 'keys':['dpid','in_port','out_port','name'], 'validator':NFVTopologyMgr_validator} self.db_collection['ServiceChainDefaultRuleMgr']={'name':'ServiceChainDefaultRuleMgr', 'keys':['service_id', 'service_level'], 'validator':ServiceChainDefaultRuleMgr_validator} self.db_collection['ServiceChainMgr']={'name':'ServiceChainMgr', 'keys':['ip','service_id'], 'validator':ServiceChainMgr_validator} self.db_collection['ServiceMgr']={'name':'ServiceMgr', 'keys':['name', 'vlan'], 'validator':None} self.db_collection['UserMgr']={'name':'UserMgr', 'keys':['mdn', 'ip'], 'validator':None} resp =[] # TODO : Threading to check the switch pull status and alias_map try: resp = mul_nbapi.get_switch_all() except: print 'error' for s in resp: sw_info = mul_nbapi.get_switch(s.switch_id.datapath_id) self.alias_map[mul_nbapi.get_switch_alias_from_switch_info(sw_info)]='0x%lx' % s.switch_id.datapath_id