From 969616eb2c4f75d0866be6f851185b2fa5fd7108 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Fri, 14 Nov 2014 15:34:32 +0100 Subject: [PATCH] Enable hacking Change-Id: I7c26e11d83dee13e8bbcb024473d916a27f3e867 --- ironic_discoverd/client.py | 13 +++++++++++++ ironic_discoverd/conf.py | 13 +++++++++++++ ironic_discoverd/discoverd.py | 18 +++++++++++++++++- ironic_discoverd/firewall.py | 13 +++++++++++++ ironic_discoverd/main.py | 19 ++++++++++++++++--- ironic_discoverd/test.py | 15 ++++++++++++++- ironic_discoverd/utils.py | 17 ++++++++++++++++- tox.ini | 8 +++++++- 8 files changed, 109 insertions(+), 7 deletions(-) diff --git a/ironic_discoverd/client.py b/ironic_discoverd/client.py index 74d16bc6f..9e1f10e08 100644 --- a/ironic_discoverd/client.py +++ b/ironic_discoverd/client.py @@ -1,3 +1,16 @@ +# 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 argparse import json diff --git a/ironic_discoverd/conf.py b/ironic_discoverd/conf.py index 33be0b939..e184a49f5 100644 --- a/ironic_discoverd/conf.py +++ b/ironic_discoverd/conf.py @@ -1,3 +1,16 @@ +# 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. + from six.moves import configparser diff --git a/ironic_discoverd/discoverd.py b/ironic_discoverd/discoverd.py index 7b705da8b..642aac52f 100644 --- a/ironic_discoverd/discoverd.py +++ b/ironic_discoverd/discoverd.py @@ -1,8 +1,20 @@ +# 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 logging import time import eventlet - from ironicclient import exceptions from ironic_discoverd import conf @@ -106,6 +118,10 @@ def process(node_info): LOG.error('Node is not on discovery, cannot proceed') return + _process_node(ironic, node, node_info, valid_macs) + + +def _process_node(ironic, node, node_info, valid_macs): patch = [{'op': 'add', 'path': '/extra/newly_discovered', 'value': 'true'}, {'op': 'remove', 'path': '/extra/on_discovery'}] existing = node.properties diff --git a/ironic_discoverd/firewall.py b/ironic_discoverd/firewall.py index 07c31b0c4..d74dd8d20 100644 --- a/ironic_discoverd/firewall.py +++ b/ironic_discoverd/firewall.py @@ -1,3 +1,16 @@ +# 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 logging import subprocess diff --git a/ironic_discoverd/main.py b/ironic_discoverd/main.py index 6a73a555d..02dad1e41 100644 --- a/ironic_discoverd/main.py +++ b/ironic_discoverd/main.py @@ -1,10 +1,23 @@ +# 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 eventlet eventlet.monkey_patch(thread=False) import logging import sys -from flask import Flask, request +from flask import Flask, request # noqa from keystoneclient import exceptions @@ -68,8 +81,8 @@ def main(): logging.basicConfig(level=logging.DEBUG if debug else logging.INFO) logging.getLogger('urllib3.connectionpool').setLevel(logging.WARNING) - logging.getLogger('requests.packages.urllib3.connectionpool') \ - .setLevel(logging.WARNING) + logging.getLogger('requests.packages.urllib3.connectionpool').setLevel( + logging.WARNING) if not conf.getboolean('discoverd', 'authenticate'): LOG.warning('Starting unauthenticated, please check configuration') diff --git a/ironic_discoverd/test.py b/ironic_discoverd/test.py index b5091761b..ecc6b36ee 100644 --- a/ironic_discoverd/test.py +++ b/ironic_discoverd/test.py @@ -1,3 +1,16 @@ +# 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 eventlet eventlet.monkey_patch(thread=False) @@ -6,7 +19,7 @@ import unittest from ironicclient import exceptions from keystoneclient import exceptions as keystone_exc -from mock import patch, Mock, ANY +from mock import patch, Mock, ANY # noqa from ironic_discoverd import client from ironic_discoverd import conf diff --git a/ironic_discoverd/utils.py b/ironic_discoverd/utils.py index beb20556b..67065c6c0 100644 --- a/ironic_discoverd/utils.py +++ b/ironic_discoverd/utils.py @@ -1,3 +1,16 @@ +# 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 logging import re @@ -30,7 +43,9 @@ def is_valid_mac(address): def check_ironic_available(): - """Try to make sure: + """Try to make sure we can reach Ironic. + + Ensure that: 1. Keystone access is configured properly 2. Keystone has already started 3. Ironic has already started diff --git a/tox.ini b/tox.ini index 1ca8404dc..f338b9ab6 100644 --- a/tox.ini +++ b/tox.ini @@ -15,8 +15,14 @@ commands = basepython = python2.7 deps = -rrequirements.txt - flake8 + hacking docutils commands = flake8 ironic_discoverd rst2html.py --strict README.rst /dev/null + +[flake8] +max-complexity=20 + +[hacking] +import_exceptions = ironicclient.exceptions