From e4f0ceef05b0f2890e112e41962e6072c7f0b05d Mon Sep 17 00:00:00 2001 From: Liam Young Date: Fri, 13 Nov 2020 11:15:26 +0000 Subject: [PATCH] More tidy up --- LICENSE | 25 +++++++++ copyright | 16 ------ perf.py | 53 ------------------ src/LICENSE | 25 +++++++++ src/lib/charms/layer/magpie_tools.py | 14 ++++- src/reactive/magpie.py | 14 +++++ src/tests/01-basic-deployment.py | 21 ------- src/tests/02-test-peers.py | 83 ---------------------------- 8 files changed, 77 insertions(+), 174 deletions(-) delete mode 100644 copyright delete mode 100644 perf.py delete mode 100755 src/tests/01-basic-deployment.py delete mode 100755 src/tests/02-test-peers.py diff --git a/LICENSE b/LICENSE index f433b1a..d645695 100644 --- a/LICENSE +++ b/LICENSE @@ -175,3 +175,28 @@ of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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/copyright b/copyright deleted file mode 100644 index e900b97..0000000 --- a/copyright +++ /dev/null @@ -1,16 +0,0 @@ -Format: http://dep.debian.net/deps/dep5/ - -Files: * -Copyright: Copyright 2015, Canonical Ltd., All Rights Reserved. -License: Apache License 2.0 - 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/perf.py b/perf.py deleted file mode 100644 index 9d89be8..0000000 --- a/perf.py +++ /dev/null @@ -1,53 +0,0 @@ -import sys -import subprocess -import threading - -class Iperf(): - """ - Install and start a server automatically - """ - try: - if not nextline: - mtu = None - except NameError: - mtu = None - # The following is a mess - since I'm installing iperf3 in the function - # Surely there is another easier way to get this into the charm? - def __init__(self): - #try: - # subprocess.check_call(['pgrep', 'iperf'], stderr=subprocess.STDOUT) - # if a: - thread = threading.Thread(target=self.start_server, args=()) - thread.start() - #except: - # pass - #hookenv.log(sys.exc_info()[0], 'INFO') - - def start_server(self): - process = subprocess.Popen(['iperf', '-s', '-m'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - while True: - nextline = process.stdout.readline() - nextline = nextline.decode("utf-8") - if nextline == '' and process.poll() is not None: - break - if "bits" in nextline: - self.speed = nextline.rsplit(' ', 2)[1] - sys.stdout.write(self.speed) - sys.stdout.write("\n") - if "MTU" in nextline: - self.mtu = nextline.rsplit(' ', 4)[1] - sys.stdout.write(self.mtu) - sys.stdout.flush() - #output = process.communicate()[0] - #exitCode = process.returncode - # - #output = exitCode - - #if (exitCode == 0): - # pass - #elif exitCode: - # raise Exception(command, exitCode, output) - - -perf = Iperf() -#print (perf.mtu) diff --git a/src/LICENSE b/src/LICENSE index f433b1a..d645695 100644 --- a/src/LICENSE +++ b/src/LICENSE @@ -175,3 +175,28 @@ of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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/src/lib/charms/layer/magpie_tools.py b/src/lib/charms/layer/magpie_tools.py index 25b460b..efce64c 100644 --- a/src/lib/charms/layer/magpie_tools.py +++ b/src/lib/charms/layer/magpie_tools.py @@ -1,4 +1,16 @@ -#!/usr/bin/env python +# Copyright 2020 Canonical 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. import os import subprocess diff --git a/src/reactive/magpie.py b/src/reactive/magpie.py index d3e273c..dbc1aff 100644 --- a/src/reactive/magpie.py +++ b/src/reactive/magpie.py @@ -1,3 +1,17 @@ +# Copyright 2020 Canonical 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. + # pylint: disable=unused-argument from charms.reactive import when, when_not, set_state, remove_state from charmhelpers.core import hookenv diff --git a/src/tests/01-basic-deployment.py b/src/tests/01-basic-deployment.py deleted file mode 100755 index d225b37..0000000 --- a/src/tests/01-basic-deployment.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 - -import unittest -import amulet - - -class TestDeploy(unittest.TestCase): - """ - Trivial deployment test for Magpie - """ - - def test_deploy(self): - self.d = amulet.Deployment(series='xenial') - self.d.add('magpie', charm='~admcleod/magpie') - self.d.setup(timeout=900) - self.d.sentry.wait_for_messages({'magpie': 'Waiting for peers...'}, - timeout=3600) - - -if __name__ == '__main__': - unittest.main() diff --git a/src/tests/02-test-peers.py b/src/tests/02-test-peers.py deleted file mode 100755 index 1d0b620..0000000 --- a/src/tests/02-test-peers.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python3 - -import re -import unittest -import amulet - - -class TestDeploy(unittest.TestCase): - """ - Deploy 2 peers and make sure their status messages contain "or" or "failed" - This does not test the substrate - only that the charms deploy and relate. - """ - - @classmethod - def setUpClass(cls): - cls.d = amulet.Deployment(series='xenial') - cls.d.add('magpie', charm='~admcleod/magpie', units=2) - cls.d.setup(timeout=900) - cls.magpie_0 = cls.d.sentry['magpie'][0] - cls.magpie_1 = cls.d.sentry['magpie'][1] - - def test_deploy(self): - self.d.sentry.wait_for_messages({'magpie': re.compile('ok|failed')}, - timeout=60) - - # following test is commented out until this bug is resolved; - # https://bugs.launchpad.net/juju/+bug/1623480 - # def test_check_local_hostname(self): - # self.d.sentry.wait_for_messages({'magpie': {re.compile('.*hostname - # ok.*'}}, timeout=60) - - def test_break_dns_single(self): - print('Test break dns single...') - """ - Break DNS on one unit, make sure DNS check fails, fix DNS, toggle - back - """ - self.d.sentry.wait_for_messages({'magpie': 'icmp ok, dns ok'}, - timeout=60) - self.magpie_0.run("sudo mv /etc/resolv.conf /etc/resolv.conf.bak") - self.magpie_0.run("hooks/update-status") - self.d.sentry.wait_for_messages({'magpie': - {re.compile('.*dns failed*')}}, - timeout=60) - self.magpie_0.run("sudo mv /etc/resolv.conf.bak /etc/resolv.conf") - self.magpie_0.run("hooks/update-status") - self.d.sentry.wait_for_messages({'magpie': 'icmp ok, dns ok'}, - timeout=60) - - def test_break_dns_all(self): - print('Test break dns all...') - """ - Set DNS with action to 255.255.255.255 - All units should fail DNS. - """ - self.d.configure('magpie', {'dns_server': '255.255.255.255'}) - self.magpie_0.run("hooks/update-status") - self.magpie_1.run("hooks/update-status") - self.d.sentry.wait_for_messages({'magpie': - re.compile('icmp ok,.*dns failed.*')}) - self.d.configure('magpie', {'dns_server': ''}) - self.magpie_0.run("hooks/update-status") - self.magpie_1.run("hooks/update-status") - self.d.sentry.wait_for_messages({'magpie': 'icmp ok, dns ok'}) - - def test_break_ping_single(self): - print('Test break ping single') - """ - Take primary interface down and make sure ICMP fails. - """ - stoprestart = "(sudo service networking stop; sleep 60; service \ - networking start) & " - self.magpie_1.run(stoprestart) - self.magpie_1.run("hooks/update-status") - self.d.sentry.wait_for_messages({'magpie': - {re.compile('icmp failed.*')}}, - timeout=120) - self.magpie_1.run("hooks/update-status") - self.d.sentry.wait_for_messages({'magpie': {re.compile('icmp ok.*')}}, - timeout=120) - - -if __name__ == '__main__': - unittest.main()