more pep fixups.

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
Angus Salkeld 2012-04-27 13:12:33 +10:00
parent f7c6773542
commit 524d214b84
9 changed files with 50 additions and 37 deletions

View File

@ -291,7 +291,8 @@ class RpmHelper(object):
* packages is a list of:
- pkg name (httpd), or
- pkg name with version spec (httpd-2.2.22), or
- pkg name with version-release spec (httpd-2.2.22-1.fc16)
- pkg name with version-release spec
(httpd-2.2.22-1.fc16)
"""
if rpms:
cmd = "rpm -U --force --nosignature "
@ -319,7 +320,8 @@ class RpmHelper(object):
* use Yum to downgrade packages
* packages is a list of:
- pkg name with version spec (httpd-2.2.22), or
- pkg name with version-release spec (httpd-2.2.22-1.fc16)
- pkg name with version-release spec
(httpd-2.2.22-1.fc16)
"""
if rpms:
cls.install(packages)
@ -364,7 +366,8 @@ class PackagesHandler(object):
def _handle_yum_packages(self, packages):
"""
Handle installation, upgrade, or downgrade of a set of packages via yum.
Handle installation, upgrade, or downgrade of a set of
packages via yum.
Arguments:
packages -- a package entries map of the form:
@ -395,7 +398,8 @@ class PackagesHandler(object):
# FIXME:print non-error, but skipping pkg
pass
elif not RpmHelper.yum_package_available(pkg):
logging.warn("Skipping package '%s'. Not available via yum" % pkg)
logging.warn("Skipping package '%s'. Not available via yum" % \
pkg)
elif not ver:
installs.append(pkg)
else:
@ -412,7 +416,8 @@ class PackagesHandler(object):
def _handle_rpm_packages(sef, packages):
"""
Handle installation, upgrade, or downgrade of a set of packages via rpm.
Handle installation, upgrade, or downgrade of a set of
packages via rpm.
Arguments:
packages -- a package entries map of the form:
@ -466,6 +471,7 @@ class PackagesHandler(object):
else:
handler(self, package_entries)
class FilesHandler(object):
def __init__(self, files):
self._files = files
@ -720,9 +726,9 @@ class Metadata(object):
"""
Process the resource metadata
"""
# FIXME: when config sets are implemented, this should select the correct
# config set from the metadata, and send each config in the config set to
# process_config
# FIXME: when config sets are implemented, this should select the
# correct config set from the metadata, and send each config in the
# config set to process_config
if not self._is_valid_metadata():
raise Exception("invalid metadata")
else:

View File

@ -43,6 +43,8 @@ db_opts = [
#conf.db_backend = 'heat.db.sqlalchemy.api'
IMPL = heat.utils.LazyPluggable('db_backend',
sqlalchemy='heat.db.sqlalchemy.api')
def configure(conf):
global SQL_CONNECTION
global SQL_IDLE_TIMEOUT
@ -50,7 +52,6 @@ def configure(conf):
SQL_IDLE_TIMEOUT = conf.sql_idle_timeout
def raw_template_get(context, template_id):
return IMPL.raw_template_get(context, template_id)

View File

@ -23,6 +23,7 @@ from migrate.versioning import util as migrate_util
_REPOSITORY = None
@migrate_util.decorator
def patched_with_engine(f, *a, **kw):
url = a[0]

View File

@ -26,6 +26,7 @@ _MAKER = None
class Error(Exception):
pass
class DBError(Error):
"""Wraps an implementation specific exception."""
def __init__(self, inner_exception=None):
@ -45,6 +46,7 @@ def _wrap_db_error(f):
_wrap.func_name = f.func_name
return _wrap
def get_session(autocommit=True, expire_on_commit=False):
"""Return a SQLAlchemy session."""
global _ENGINE, _MAKER

View File

@ -163,7 +163,6 @@ class Stack(object):
self.t['stack_status'] = new_status
self.update_parsed_template()
def create_blocking(self):
'''
create all the resources in the order specified by get_create_order

View File

@ -23,6 +23,7 @@ from heat.openstack.common import importutils
LOG = logging.getLogger(__name__)
def create_connection(new=True):
"""Create a connection to the message bus used for rpc.

View File

@ -24,12 +24,14 @@ from heat.db.sqlalchemy.session import get_engine
_DB = None
def reset_db():
engine = get_engine()
engine.dispose()
conn = engine.connect()
conn.connection.executescript(_DB)
def setup():
import mox # Fail fast if you don't have mox. Workaround for bug 810424

View File

@ -47,9 +47,11 @@ def setUp_credential_file():
f.write('junk, just junk')
f.close()
def tearDown_credential_file():
shutil.rmtree('/tmp/incredible', ignore_errors=True)
@with_setup(setUp_credential_file, tearDown_credential_file)
@attr(tag=['unit', 'cfn-hup'])
@attr(speed='fast')
@ -129,7 +131,6 @@ class MetadataTest(unittest.TestCase):
self.m.UnsetStubs()
shutil.rmtree('/tmp/_files_test_', ignore_errors=True)
@attr(tag=['unit', 'cfn-metadata'])
@attr(speed='fast')
def test_metadata_files(self):
@ -180,7 +181,8 @@ https://raw.github.com/heat-api/heat/master/README.rst'],
os.chown('/tmp/_files_test_/epel.repo', -1, -1)
os.chmod('/tmp/_files_test_/node.json', 384)
os.chmod('/tmp/_files_test_/epel.repo', 420)
os.chown('/tmp/_files_test_/_with/some/dirs/to/make/small.conf', -1, -1)
os.chown('/tmp/_files_test_/_with/some/dirs/to/make/small.conf',
-1, -1)
os.chmod('/tmp/_files_test_/_with/some/dirs/to/make/small.conf', 511)
self.m.ReplayAll()

View File

@ -16,6 +16,7 @@ from heat.engine import resources
import heat.db as db_api
from heat.engine import parser
@attr(tag=['unit', 'resource'])
@attr(speed='fast')
class ResourcesTest(unittest.TestCase):
@ -54,7 +55,8 @@ class ResourcesTest(unittest.TestCase):
self.m.ReplayAll()
t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
t['Resources']['WebServer']['Properties']['InstanceType'] = '256 MB Server'
t['Resources']['WebServer']['Properties']['InstanceType'] = \
'256 MB Server'
instance = resources.Instance('test_resource_name',\
t['Resources']['WebServer'], stack)
@ -66,7 +68,6 @@ class ResourcesTest(unittest.TestCase):
AndReturn(self.fc.servers.list()[1])
self.m.ReplayAll()
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
instance.create()
@ -105,7 +106,8 @@ class ResourcesTest(unittest.TestCase):
self.m.ReplayAll()
t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
t['Resources']['WebServer']['Properties']['InstanceType'] = '256 MB Server'
t['Resources']['WebServer']['Properties']['InstanceType'] = \
'256 MB Server'
instance = resources.Instance('test_resource_name',\
t['Resources']['WebServer'], stack)
@ -117,7 +119,6 @@ class ResourcesTest(unittest.TestCase):
AndReturn(self.fc.servers.list()[1])
self.m.ReplayAll()
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
instance.create()
@ -131,9 +132,7 @@ class ResourcesTest(unittest.TestCase):
assert(instance.instance_id == None)
assert(instance.state == instance.DELETE_COMPLETE)
# allows testing of the test directly, shown below
if __name__ == '__main__':
sys.argv.append(__file__)
nose.main()