From 8646b8d62cf4ca7b6bccae537a0c9e72ba45eab3 Mon Sep 17 00:00:00 2001 From: Harry Huang Date: Fri, 17 Nov 2017 14:53:44 +0800 Subject: Merge compass-tasks-osa and compass-tasks-k8s JIRA: COMPASS-568 rename compass-tasks to compass-tasks-base. add both osa and k8s support in compass-tasks Change-Id: I438f5b17e509d4cb751ced0ffe640ec70899882f Signed-off-by: Harry Huang --- compass-tasks/hdsdiscovery/vendors/__init__.py | 13 ---- .../hdsdiscovery/vendors/appliance/__init__.py | 0 .../hdsdiscovery/vendors/appliance/appliance.py | 34 --------- .../vendors/appliance/plugins/__init__.py | 0 .../hdsdiscovery/vendors/appliance/plugins/mac.py | 48 ------------ .../hdsdiscovery/vendors/arista/__init__.py | 13 ---- .../hdsdiscovery/vendors/arista/arista.py | 33 -------- .../vendors/arista/plugins/__init__.py | 13 ---- .../hdsdiscovery/vendors/arista/plugins/mac.py | 24 ------ compass-tasks/hdsdiscovery/vendors/hp/__init__.py | 13 ---- compass-tasks/hdsdiscovery/vendors/hp/hp.py | 33 -------- .../hdsdiscovery/vendors/hp/plugins/__init__.py | 13 ---- .../hdsdiscovery/vendors/hp/plugins/mac.py | 23 ------ .../hdsdiscovery/vendors/huawei/__init__.py | 13 ---- .../hdsdiscovery/vendors/huawei/huawei.py | 33 -------- .../vendors/huawei/plugins/__init__.py | 13 ---- .../hdsdiscovery/vendors/huawei/plugins/mac.py | 63 ---------------- .../hdsdiscovery/vendors/ovswitch/__init__.py | 13 ---- .../hdsdiscovery/vendors/ovswitch/ovswitch.py | 76 ------------------- .../vendors/ovswitch/plugins/__init__.py | 13 ---- .../hdsdiscovery/vendors/ovswitch/plugins/mac.py | 87 ---------------------- .../hdsdiscovery/vendors/pica8/__init__.py | 13 ---- compass-tasks/hdsdiscovery/vendors/pica8/pica8.py | 33 -------- .../hdsdiscovery/vendors/pica8/plugins/__init__.py | 13 ---- .../hdsdiscovery/vendors/pica8/plugins/mac.py | 24 ------ 25 files changed, 654 deletions(-) delete mode 100644 compass-tasks/hdsdiscovery/vendors/__init__.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/appliance/__init__.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/appliance/appliance.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/appliance/plugins/__init__.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/appliance/plugins/mac.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/arista/__init__.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/arista/arista.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/arista/plugins/__init__.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/arista/plugins/mac.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/hp/__init__.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/hp/hp.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/hp/plugins/__init__.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/hp/plugins/mac.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/huawei/__init__.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/huawei/huawei.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/huawei/plugins/__init__.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/huawei/plugins/mac.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/ovswitch/__init__.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/ovswitch/ovswitch.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/ovswitch/plugins/__init__.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/ovswitch/plugins/mac.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/pica8/__init__.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/pica8/pica8.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/pica8/plugins/__init__.py delete mode 100644 compass-tasks/hdsdiscovery/vendors/pica8/plugins/mac.py (limited to 'compass-tasks/hdsdiscovery/vendors') diff --git a/compass-tasks/hdsdiscovery/vendors/__init__.py b/compass-tasks/hdsdiscovery/vendors/__init__.py deleted file mode 100644 index 4ee55a4..0000000 --- a/compass-tasks/hdsdiscovery/vendors/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/compass-tasks/hdsdiscovery/vendors/appliance/__init__.py b/compass-tasks/hdsdiscovery/vendors/appliance/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/compass-tasks/hdsdiscovery/vendors/appliance/appliance.py b/compass-tasks/hdsdiscovery/vendors/appliance/appliance.py deleted file mode 100644 index 3d66f4e..0000000 --- a/compass-tasks/hdsdiscovery/vendors/appliance/appliance.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -"""Vendor: Compass Appliance""" -from compass.hdsdiscovery import base - - -# Vendor_loader will load vendor instance by CLASS_NAME -CLASS_NAME = 'Appliance' - - -class Appliance(base.BaseSnmpVendor): - """Fake SNMP object for compass appliance.""" - - def __init__(self): - base.BaseSnmpVendor.__init__(self, ['appliance']) - self.__name = 'appliance' - - @property - def name(self): - """Get 'name' proptery.""" - return self.__name diff --git a/compass-tasks/hdsdiscovery/vendors/appliance/plugins/__init__.py b/compass-tasks/hdsdiscovery/vendors/appliance/plugins/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/compass-tasks/hdsdiscovery/vendors/appliance/plugins/mac.py b/compass-tasks/hdsdiscovery/vendors/appliance/plugins/mac.py deleted file mode 100644 index cc14881..0000000 --- a/compass-tasks/hdsdiscovery/vendors/appliance/plugins/mac.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""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" - - -class Mac(base.BaseSnmpMacPlugin): - """Processes MAC address.""" - - def __init__(self, host, credential): - self.host = host - # self.credential = credential - # return - - def scan(self): - """Implemnets the scan method in BasePlugin class. - - .. note:: - Dummy scan function for compass appliance. - Returns fixed mac addresses. - """ - mac_list = None - 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-tasks/hdsdiscovery/vendors/arista/__init__.py b/compass-tasks/hdsdiscovery/vendors/arista/__init__.py deleted file mode 100644 index 4ee55a4..0000000 --- a/compass-tasks/hdsdiscovery/vendors/arista/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/compass-tasks/hdsdiscovery/vendors/arista/arista.py b/compass-tasks/hdsdiscovery/vendors/arista/arista.py deleted file mode 100644 index 5eacea1..0000000 --- a/compass-tasks/hdsdiscovery/vendors/arista/arista.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Vendor: Arista.""" -from compass.hdsdiscovery import base - - -# Vendor_loader will load vendor instance by CLASS_NAME -CLASS_NAME = 'Arista' - - -class Arista(base.BaseSnmpVendor): - """Arista Network switch object.""" - - def __init__(self): - base.BaseSnmpVendor.__init__(self, ['arista']) - self._name = 'arista' - - @property - def name(self): - """Get 'name' proptery.""" - return self._name diff --git a/compass-tasks/hdsdiscovery/vendors/arista/plugins/__init__.py b/compass-tasks/hdsdiscovery/vendors/arista/plugins/__init__.py deleted file mode 100644 index 4ee55a4..0000000 --- a/compass-tasks/hdsdiscovery/vendors/arista/plugins/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/compass-tasks/hdsdiscovery/vendors/arista/plugins/mac.py b/compass-tasks/hdsdiscovery/vendors/arista/plugins/mac.py deleted file mode 100644 index ed2f331..0000000 --- a/compass-tasks/hdsdiscovery/vendors/arista/plugins/mac.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Pica8 Switch Mac module.""" -from compass.hdsdiscovery.base import BaseSnmpMacPlugin - - -CLASS_NAME = 'Mac' - - -class Mac(BaseSnmpMacPlugin): - """Process MAC address by Arista switch.""" - pass diff --git a/compass-tasks/hdsdiscovery/vendors/hp/__init__.py b/compass-tasks/hdsdiscovery/vendors/hp/__init__.py deleted file mode 100644 index 4ee55a4..0000000 --- a/compass-tasks/hdsdiscovery/vendors/hp/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/compass-tasks/hdsdiscovery/vendors/hp/hp.py b/compass-tasks/hdsdiscovery/vendors/hp/hp.py deleted file mode 100644 index 7ddc5e9..0000000 --- a/compass-tasks/hdsdiscovery/vendors/hp/hp.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Vendor: HP.""" -from compass.hdsdiscovery import base - - -# Vendor_loader will load vendor instance by CLASS_NAME -CLASS_NAME = 'Hp' - - -class Hp(base.BaseSnmpVendor): - """Hp switch object.""" - - def __init__(self): - base.BaseSnmpVendor.__init__(self, ['hp', 'procurve']) - self.names = ['hp', 'procurve'] - - @property - def name(self): - """Get 'name' proptery.""" - return self.names[0] diff --git a/compass-tasks/hdsdiscovery/vendors/hp/plugins/__init__.py b/compass-tasks/hdsdiscovery/vendors/hp/plugins/__init__.py deleted file mode 100644 index 4ee55a4..0000000 --- a/compass-tasks/hdsdiscovery/vendors/hp/plugins/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/compass-tasks/hdsdiscovery/vendors/hp/plugins/mac.py b/compass-tasks/hdsdiscovery/vendors/hp/plugins/mac.py deleted file mode 100644 index 3bc81f4..0000000 --- a/compass-tasks/hdsdiscovery/vendors/hp/plugins/mac.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""HP Switch Mac module.""" -from compass.hdsdiscovery.base import BaseSnmpMacPlugin - -CLASS_NAME = 'Mac' - - -class Mac(BaseSnmpMacPlugin): - """Process MAC address by HP switch.""" - pass diff --git a/compass-tasks/hdsdiscovery/vendors/huawei/__init__.py b/compass-tasks/hdsdiscovery/vendors/huawei/__init__.py deleted file mode 100644 index 4ee55a4..0000000 --- a/compass-tasks/hdsdiscovery/vendors/huawei/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/compass-tasks/hdsdiscovery/vendors/huawei/huawei.py b/compass-tasks/hdsdiscovery/vendors/huawei/huawei.py deleted file mode 100644 index 19fd043..0000000 --- a/compass-tasks/hdsdiscovery/vendors/huawei/huawei.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Huawei Switch.""" -from compass.hdsdiscovery import base - - -# Vendor_loader will load vendor instance by CLASS_NAME -CLASS_NAME = "Huawei" - - -class Huawei(base.BaseSnmpVendor): - """Huawei switch.""" - - def __init__(self): - base.BaseSnmpVendor.__init__(self, ["huawei"]) - self.__name = "huawei" - - @property - def name(self): - """Return switch name.""" - return self.__name diff --git a/compass-tasks/hdsdiscovery/vendors/huawei/plugins/__init__.py b/compass-tasks/hdsdiscovery/vendors/huawei/plugins/__init__.py deleted file mode 100644 index 4ee55a4..0000000 --- a/compass-tasks/hdsdiscovery/vendors/huawei/plugins/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/compass-tasks/hdsdiscovery/vendors/huawei/plugins/mac.py b/compass-tasks/hdsdiscovery/vendors/huawei/plugins/mac.py deleted file mode 100644 index 49d3863..0000000 --- a/compass-tasks/hdsdiscovery/vendors/huawei/plugins/mac.py +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Huawei Switch Mac module.""" -import logging - -from compass.hdsdiscovery.base import BaseSnmpMacPlugin -from compass.hdsdiscovery import utils - - -CLASS_NAME = "Mac" - - -class Mac(BaseSnmpMacPlugin): - """Processes MAC address.""" - - def __init__(self, host, credential): - super(Mac, self).__init__( - host, credential, - 'HUAWEI-L2MAM-MIB::hwDynFdbPort') - - def scan(self): - """Implemnets the scan method in BasePlugin class. - - .. note:: - In this mac module, mac addesses were retrieved by - snmpwalk commandline. - """ - results = utils.snmpwalk_by_cl(self.host, self.credential, self.oid) - - if not results: - logging.info("[Huawei][mac] No results returned from SNMP walk!") - return None - - mac_list = [] - - for entity in results: - # The format of 'iid' is like '248.192.1.214.34.15.31.1.48' - # The first 6 numbers will be the MAC address - # The 7th number is its vlan ID - numbers = entity['iid'].split('.') - mac = self.get_mac_address(numbers[:6]) - vlan = numbers[6] - port = self.get_port(entity['value']) - - tmp = {} - tmp['port'] = port - tmp['mac'] = mac - tmp['vlan'] = vlan - mac_list.append(tmp) - - return mac_list diff --git a/compass-tasks/hdsdiscovery/vendors/ovswitch/__init__.py b/compass-tasks/hdsdiscovery/vendors/ovswitch/__init__.py deleted file mode 100644 index 4ee55a4..0000000 --- a/compass-tasks/hdsdiscovery/vendors/ovswitch/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/compass-tasks/hdsdiscovery/vendors/ovswitch/ovswitch.py b/compass-tasks/hdsdiscovery/vendors/ovswitch/ovswitch.py deleted file mode 100644 index 4d03328..0000000 --- a/compass-tasks/hdsdiscovery/vendors/ovswitch/ovswitch.py +++ /dev/null @@ -1,76 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Open Vswitch module.""" -import logging -import re - -from compass.hdsdiscovery import base -from compass.hdsdiscovery import utils - - -# Vendor_loader will load vendor instance by CLASS_NAME -CLASS_NAME = "OVSwitch" - - -class OVSwitch(base.BaseVendor): - """Open Vswitch.""" - def __init__(self): - self.__name = "Open vSwitch" - - def is_this_vendor(self, sys_info, host=None, credential=None, **kwargs): - """Determine if the hostname is accociated witH this vendor. - - :param host: swtich's IP address - :param credential: credential to access switch - """ - result = sys_info - if host and credential: - if utils.is_valid_ssh_credential(credential): - user = credential['username'] - pwd = credential['password'] - - else: - msg = ("[OVSwitch]The format of credential %r is not for SSH " - "or incorrect Keywords! " % credential) - logging.info(msg) - return False - - cmd = "ovs-vsctl -V" - result = None - try: - result = utils.ssh_remote_execute(host, user, pwd, cmd) - logging.debug('%s result for %s is %s', cmd, host, result) - if not result: - return False - except Exception as exc: - logging.error("No vendor or connection failed to run %s", cmd) - logging.exception(exc) - return False - - if isinstance(result, str): - result = [result] - - for line in result: - if not line: - continue - if re.search(r"\b" + re.escape(self.__name) + r"\b", line): - return True - - return False - - @property - def name(self): - """Open Vswitch name.""" - return self.__name diff --git a/compass-tasks/hdsdiscovery/vendors/ovswitch/plugins/__init__.py b/compass-tasks/hdsdiscovery/vendors/ovswitch/plugins/__init__.py deleted file mode 100644 index 4ee55a4..0000000 --- a/compass-tasks/hdsdiscovery/vendors/ovswitch/plugins/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/compass-tasks/hdsdiscovery/vendors/ovswitch/plugins/mac.py b/compass-tasks/hdsdiscovery/vendors/ovswitch/plugins/mac.py deleted file mode 100644 index 5f497a0..0000000 --- a/compass-tasks/hdsdiscovery/vendors/ovswitch/plugins/mac.py +++ /dev/null @@ -1,87 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Open Vswitch Mac address module.""" -import logging - -from compass.hdsdiscovery import base -from compass.hdsdiscovery import utils - - -CLASS_NAME = "Mac" - - -class Mac(base.BasePlugin): - """Open Vswitch MAC address module.""" - def __init__(self, host, credential): - self.host = host - self.credential = credential - - def process_data(self, oper="SCAN", **kwargs): - """Dynamically call the function according 'oper' - - :param oper: operation of data processing - """ - func_name = oper.lower() - return getattr(self, func_name)(**kwargs) - - def scan(self, **kwargs): - """Implemnets the scan method in BasePlugin class. - - .. note:: - In this module, mac addesses were retrieved by ssh. - """ - try: - user = self.credential['username'] - pwd = self.credential['password'] - except KeyError: - logging.error("Cannot find username and password in credential") - return None - - cmd = ("BRIDGES=$(ovs-vsctl show |grep Bridge |cut -f 2 -d '\"');" - "for br in $BRIDGES; do" - "PORTS=$(ovs-ofctl show $br |grep addr |cut -f 1 -d ':' " - "|egrep -v 'eth|wlan|LOCAL'|awk -F '(' '{print $1}');" - "for port in $PORTS; do" - "RESULT=$(ovs-appctl fdb/show $br |" - "awk '$1 == '$port' {print $1" "$2" "$3}');" - "echo '$RESULT'" - "done;" - "done;") - output = None - try: - output = utils.ssh_remote_execute(self.host, user, pwd, cmd) - except Exception as error: - logging.exception(error) - return None - - logging.debug("[scan][output] output is %s", output) - if not output: - return None - - fields_arr = ['port', 'vlan', 'mac'] - - result = [] - for line in output: - if not line or line == '\n': - continue - - values_arr = line.split() - temp = {} - for field, value in zip(fields_arr, values_arr): - temp[field] = value - - result.append(temp.copy()) - - return result diff --git a/compass-tasks/hdsdiscovery/vendors/pica8/__init__.py b/compass-tasks/hdsdiscovery/vendors/pica8/__init__.py deleted file mode 100644 index 4ee55a4..0000000 --- a/compass-tasks/hdsdiscovery/vendors/pica8/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/compass-tasks/hdsdiscovery/vendors/pica8/pica8.py b/compass-tasks/hdsdiscovery/vendors/pica8/pica8.py deleted file mode 100644 index 856817e..0000000 --- a/compass-tasks/hdsdiscovery/vendors/pica8/pica8.py +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Vendor: Pica8.""" -from compass.hdsdiscovery import base - - -# Vendor_loader will load vendor instance by CLASS_NAME -CLASS_NAME = 'Pica8' - - -class Pica8(base.BaseSnmpVendor): - """Pica8 switch object.""" - - def __init__(self): - base.BaseSnmpVendor.__init__(self, ['pica8']) - self._name = 'pica8' - - @property - def name(self): - """Get 'name' proptery.""" - return self._name diff --git a/compass-tasks/hdsdiscovery/vendors/pica8/plugins/__init__.py b/compass-tasks/hdsdiscovery/vendors/pica8/plugins/__init__.py deleted file mode 100644 index 4ee55a4..0000000 --- a/compass-tasks/hdsdiscovery/vendors/pica8/plugins/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. diff --git a/compass-tasks/hdsdiscovery/vendors/pica8/plugins/mac.py b/compass-tasks/hdsdiscovery/vendors/pica8/plugins/mac.py deleted file mode 100644 index d5ccfc0..0000000 --- a/compass-tasks/hdsdiscovery/vendors/pica8/plugins/mac.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2014 Huawei Technologies Co. Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Pica8 Switch Mac module.""" -from compass.hdsdiscovery.base import BaseSnmpMacPlugin - - -CLASS_NAME = 'Mac' - - -class Mac(BaseSnmpMacPlugin): - """Process MAC address by Pica8 switch.""" - pass -- cgit 1.2.3-korg