Misc fixes for charm infra
Update pydev project definition to use python 3. Drop upper bound on flake8. Tidy misc lint across codebase with newer flake8. Change-Id: I9637ac603cb3801c9e3ffa8c2b0897968d42ada5
This commit is contained in:
parent
e5166a2c03
commit
747fa2d68d
@ -1,9 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||
<path>/nova-compute/hooks</path>
|
||||
<path>/nova-compute/unit_tests</path>
|
||||
</pydev_pathproperty>
|
||||
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
|
||||
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python3</pydev_property>
|
||||
|
||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||
|
||||
<path>/nova-compute/hooks</path>
|
||||
|
||||
<path>/nova-compute/unit_tests</path>
|
||||
|
||||
</pydev_pathproperty>
|
||||
|
||||
</pydev_project>
|
||||
|
@ -25,6 +25,7 @@ def _add_path(path):
|
||||
if path not in sys.path:
|
||||
sys.path.insert(1, path)
|
||||
|
||||
|
||||
_add_path(_hooks)
|
||||
|
||||
|
||||
@ -58,5 +59,6 @@ def hugepages_report():
|
||||
return
|
||||
hookenv.action_set(outmap)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
hugepages_report()
|
||||
|
@ -26,6 +26,7 @@ def _add_path(path):
|
||||
if path not in sys.path:
|
||||
sys.path.insert(1, path)
|
||||
|
||||
|
||||
_add_path(_hooks)
|
||||
|
||||
|
||||
@ -65,5 +66,6 @@ def openstack_upgrade():
|
||||
# upgrade) then the config_changed() function is a no-op
|
||||
config_changed()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
openstack_upgrade()
|
||||
|
@ -25,6 +25,7 @@ def _add_path(path):
|
||||
if path not in sys.path:
|
||||
sys.path.insert(1, path)
|
||||
|
||||
|
||||
_add_path(_hooks)
|
||||
|
||||
|
||||
|
@ -26,6 +26,7 @@ def _add_path(path):
|
||||
if path not in sys.path:
|
||||
sys.path.insert(1, path)
|
||||
|
||||
|
||||
_add_path(_hooks)
|
||||
|
||||
|
||||
@ -84,5 +85,6 @@ def main():
|
||||
[config['config_path'], config['config_file']])
|
||||
return audits.action_parse_results(audits.run(config))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
@ -97,32 +97,32 @@ def _get_availability_zone():
|
||||
|
||||
|
||||
def _neutron_security_groups():
|
||||
'''
|
||||
Inspects current cloud-compute relation and determine if nova-c-c has
|
||||
instructed us to use neutron security groups.
|
||||
'''
|
||||
for rid in relation_ids('cloud-compute'):
|
||||
for unit in related_units(rid):
|
||||
groups = [
|
||||
relation_get('neutron_security_groups',
|
||||
rid=rid, unit=unit),
|
||||
relation_get('quantum_security_groups',
|
||||
rid=rid, unit=unit)
|
||||
]
|
||||
if ('yes' in groups or 'Yes' in groups):
|
||||
return True
|
||||
return False
|
||||
'''
|
||||
Inspects current cloud-compute relation and determine if nova-c-c has
|
||||
instructed us to use neutron security groups.
|
||||
'''
|
||||
for rid in relation_ids('cloud-compute'):
|
||||
for unit in related_units(rid):
|
||||
groups = [
|
||||
relation_get('neutron_security_groups',
|
||||
rid=rid, unit=unit),
|
||||
relation_get('quantum_security_groups',
|
||||
rid=rid, unit=unit)
|
||||
]
|
||||
if ('yes' in groups or 'Yes' in groups):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _neutron_plugin():
|
||||
from nova_compute_utils import neutron_plugin
|
||||
return neutron_plugin()
|
||||
from nova_compute_utils import neutron_plugin
|
||||
return neutron_plugin()
|
||||
|
||||
|
||||
def _neutron_url(rid, unit):
|
||||
# supports legacy relation settings.
|
||||
return (relation_get('neutron_url', rid=rid, unit=unit) or
|
||||
relation_get('quantum_url', rid=rid, unit=unit))
|
||||
# supports legacy relation settings.
|
||||
return (relation_get('neutron_url', rid=rid, unit=unit) or
|
||||
relation_get('quantum_url', rid=rid, unit=unit))
|
||||
|
||||
|
||||
def nova_metadata_requirement():
|
||||
|
@ -573,7 +573,7 @@ def public_ssh_key(user='root'):
|
||||
try:
|
||||
with open(os.path.join(home, '.ssh', 'id_rsa.pub')) as key:
|
||||
return key.read().strip()
|
||||
except:
|
||||
except OSError:
|
||||
return None
|
||||
|
||||
|
||||
@ -751,7 +751,7 @@ def _libvirt_network_exec(netname, action):
|
||||
return
|
||||
|
||||
for line in out[2:]:
|
||||
res = re.search("^\s+{} ".format(netname), line)
|
||||
res = re.search(r"^\s+{} ".format(netname), line)
|
||||
if res:
|
||||
check_call(['virsh', 'net-{}'.format(action), netname])
|
||||
return
|
||||
|
@ -10,7 +10,7 @@
|
||||
charm-tools>=2.4.4
|
||||
requests>=2.18.4
|
||||
mock>=1.2
|
||||
flake8>=2.2.4,<=2.4.1
|
||||
flake8>=2.2.4
|
||||
stestr>=2.2.0
|
||||
coverage>=4.5.2
|
||||
pyudev # for ceph-* charm unit tests (need to fix the ceph-* charm unit tests/mocking)
|
||||
|
2
tox.ini
2
tox.ini
@ -116,5 +116,5 @@ commands =
|
||||
functest-run-suite --keep-model --bundle {posargs}
|
||||
|
||||
[flake8]
|
||||
ignore = E402,E226
|
||||
ignore = E402,E226,W504
|
||||
exclude = */charmhelpers
|
||||
|
@ -534,7 +534,7 @@ class NovaComputeUtilsTests(CharmTestCase):
|
||||
@patch('builtins.open')
|
||||
@patch('pwd.getpwnam')
|
||||
def test_public_ssh_key_not_found(self, getpwnam, _open):
|
||||
_open.side_effect = Exception
|
||||
_open.side_effect = OSError
|
||||
getpwnam.return_value = self.fake_user('foo')
|
||||
self.assertEqual(None, utils.public_ssh_key())
|
||||
|
||||
|
@ -101,9 +101,9 @@ class TestConfig(object):
|
||||
return self.config
|
||||
|
||||
def set(self, attr, value):
|
||||
if attr not in self.config:
|
||||
raise KeyError
|
||||
self.config[attr] = value
|
||||
if attr not in self.config:
|
||||
raise KeyError
|
||||
self.config[attr] = value
|
||||
|
||||
|
||||
class TestRelation(object):
|
||||
|
Loading…
Reference in New Issue
Block a user