Fix flake8 errors and turn off hacking
This commit is contained in:
parent
5b3c005aae
commit
a56767a865
@ -24,6 +24,7 @@ from ironicclient import exceptions as ironic_exceptions
|
|||||||
from keystoneclient import client as keystone_client
|
from keystoneclient import client as keystone_client
|
||||||
from novaclient import exceptions as nova_exceptions
|
from novaclient import exceptions as nova_exceptions
|
||||||
from novaclient.v1_1 import client as nova_client
|
from novaclient.v1_1 import client as nova_client
|
||||||
|
from novaclient.v1_1 import floating_ips
|
||||||
import os_client_config
|
import os_client_config
|
||||||
import pbr.version
|
import pbr.version
|
||||||
import troveclient.client as trove_client
|
import troveclient.client as trove_client
|
||||||
@ -38,6 +39,7 @@ __version__ = pbr.version.VersionInfo('shade').version_string()
|
|||||||
class OpenStackCloudException(Exception):
|
class OpenStackCloudException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class OpenStackCloudTimeout(OpenStackCloudException):
|
class OpenStackCloudTimeout(OpenStackCloudException):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -378,7 +380,7 @@ class OpenStackCloud(object):
|
|||||||
self._image_cache = self._get_images_from_cloud()
|
self._image_cache = self._get_images_from_cloud()
|
||||||
return self._image_cache
|
return self._image_cache
|
||||||
|
|
||||||
def get_image_name(self, image_id):
|
def get_image_name(self, image_id, exclude):
|
||||||
image = self.get_image(image_id, exclude)
|
image = self.get_image(image_id, exclude)
|
||||||
if image:
|
if image:
|
||||||
return image.id
|
return image.id
|
||||||
@ -452,7 +454,7 @@ class OpenStackCloud(object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_server_id(self, server_name):
|
def get_server_id(self, server_name):
|
||||||
server = get_server_by_name(server_name)
|
server = self.get_server_by_name(server_name)
|
||||||
if server:
|
if server:
|
||||||
return server.id
|
return server.id
|
||||||
return None
|
return None
|
||||||
@ -498,7 +500,7 @@ class OpenStackCloud(object):
|
|||||||
if not pool_ips:
|
if not pool_ips:
|
||||||
try:
|
try:
|
||||||
new_ip = self.nova_client.floating_ips.create(pool)
|
new_ip = self.nova_client.floating_ips.create(pool)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
raise OpenStackCloudException(
|
raise OpenStackCloudException(
|
||||||
"Unable to create floating ip in pool %s" % pool)
|
"Unable to create floating ip in pool %s" % pool)
|
||||||
pool_ips.append(new_ip.ip)
|
pool_ips.append(new_ip.ip)
|
||||||
@ -591,7 +593,8 @@ class OpenStackCloud(object):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if server.status == 'ACTIVE':
|
if server.status == 'ACTIVE':
|
||||||
return self.add_ips_to_server(server, auto_ip, ips, ip_pool)
|
return self.add_ips_to_server(
|
||||||
|
server, auto_ip, ips, ip_pool)
|
||||||
|
|
||||||
if server.status == 'ERROR':
|
if server.status == 'ERROR':
|
||||||
raise OpenStackCloudException(
|
raise OpenStackCloudException(
|
||||||
@ -605,13 +608,13 @@ class OpenStackCloud(object):
|
|||||||
def delete_server(self, name, wait=False, timeout=180):
|
def delete_server(self, name, wait=False, timeout=180):
|
||||||
server_list = self.nova_client.servers.list(True, {'name': name})
|
server_list = self.nova_client.servers.list(True, {'name': name})
|
||||||
if server_list:
|
if server_list:
|
||||||
server = [x for x in server_list if x.name == module.params['name']]
|
server = [x for x in server_list if x.name == name]
|
||||||
self.nova_client.servers.delete(server.pop())
|
self.nova_client.servers.delete(server.pop())
|
||||||
if not wait:
|
if not wait:
|
||||||
return
|
return
|
||||||
expire = time.time() + timeout
|
expire = time.time() + timeout
|
||||||
while time.time() < expire:
|
while time.time() < expire:
|
||||||
server = nova.servers.list(True, {'name': name})
|
server = self.nova_client.servers.list(True, {'name': name})
|
||||||
if not server:
|
if not server:
|
||||||
return
|
return
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
@ -629,6 +632,7 @@ class OpenStackCloud(object):
|
|||||||
raise OpenStackCloudTimeout(
|
raise OpenStackCloudTimeout(
|
||||||
"Timed out waiting for server to get deleted.")
|
"Timed out waiting for server to get deleted.")
|
||||||
|
|
||||||
|
|
||||||
class OperatorCloud(OpenStackCloud):
|
class OperatorCloud(OpenStackCloud):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -679,7 +683,7 @@ class OperatorCloud(OpenStackCloud):
|
|||||||
machine = self.ironic_client.node.create(**kwargs)
|
machine = self.ironic_client.node.create(**kwargs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise OpenStackCloudException(
|
raise OpenStackCloudException(
|
||||||
"Error registering machine with Ironic: %s" % e.message)
|
"Error registering machine with Ironic: %s" % e.message)
|
||||||
|
|
||||||
created_nics = []
|
created_nics = []
|
||||||
try:
|
try:
|
||||||
@ -692,18 +696,18 @@ class OperatorCloud(OpenStackCloud):
|
|||||||
self.ironic_client.port.delete(uuid)
|
self.ironic_client.port.delete(uuid)
|
||||||
self.ironic_client.node.delete(machine.uuid)
|
self.ironic_client.node.delete(machine.uuid)
|
||||||
raise OpenStackCloudException(
|
raise OpenStackCloudException(
|
||||||
"Error registering NICs with Ironic: %s" % e.message)
|
"Error registering NICs with Ironic: %s" % e.message)
|
||||||
return machine
|
return machine
|
||||||
|
|
||||||
def unregister_machine(self, nics, uuid):
|
def unregister_machine(self, nics, uuid):
|
||||||
for nic in nics:
|
for nic in nics:
|
||||||
try:
|
try:
|
||||||
self.ironic_client.port.delete(
|
self.ironic_client.port.delete(
|
||||||
self.ironic_client.port.get_by_address(nic['mac']))
|
self.ironic_client.port.get_by_address(nic['mac']))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise OpenStackCloudException(e.message)
|
raise OpenStackCloudException(e.message)
|
||||||
try:
|
try:
|
||||||
self.ironic_client.node.delete(uuid)
|
self.ironic_client.node.delete(uuid)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise OpenStackCloudException(
|
raise OpenStackCloudException(
|
||||||
"Error unregistering machine from Ironic: %s" % e.message)
|
"Error unregistering machine from Ironic: %s" % e.message)
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import re
|
|
||||||
import types
|
import types
|
||||||
|
|
||||||
NON_CALLABLES = (basestring, bool, dict, int, list, types.NoneType)
|
NON_CALLABLES = (basestring, bool, dict, int, list, types.NoneType)
|
||||||
|
@ -50,4 +50,4 @@ class TestCase(testtools.TestCase):
|
|||||||
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
|
stderr = self.useFixture(fixtures.StringStream('stderr')).stream
|
||||||
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
|
self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
|
||||||
|
|
||||||
self.log_fixture = self.useFixture(fixtures.FakeLogger())
|
self.log_fixture = self.useFixture(fixtures.FakeLogger())
|
||||||
|
@ -25,4 +25,4 @@ from shade.tests import base
|
|||||||
class TestShade(base.TestCase):
|
class TestShade(base.TestCase):
|
||||||
|
|
||||||
def test_something(self):
|
def test_something(self):
|
||||||
pass
|
pass
|
||||||
|
5
tox.ini
5
tox.ini
@ -25,8 +25,9 @@ commands = {posargs}
|
|||||||
commands = python setup.py testr --coverage --testr-args='{posargs}'
|
commands = python setup.py testr --coverage --testr-args='{posargs}'
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# We're not inside of OpenStack, so H305 makes no sense
|
# Infra does not follow hacking, nor the broken E12* things
|
||||||
ignore = H305
|
ignore = E123,E125,H
|
||||||
|
select = H231
|
||||||
show-source = True
|
show-source = True
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
||||||
|
Loading…
Reference in New Issue
Block a user