more pep fixups.
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
parent
f7c6773542
commit
524d214b84
@ -291,7 +291,8 @@ class RpmHelper(object):
|
|||||||
* packages is a list of:
|
* packages is a list of:
|
||||||
- pkg name (httpd), or
|
- pkg name (httpd), or
|
||||||
- pkg name with version spec (httpd-2.2.22), 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:
|
if rpms:
|
||||||
cmd = "rpm -U --force --nosignature "
|
cmd = "rpm -U --force --nosignature "
|
||||||
@ -319,7 +320,8 @@ class RpmHelper(object):
|
|||||||
* use Yum to downgrade packages
|
* use Yum to downgrade packages
|
||||||
* packages is a list of:
|
* packages is a list of:
|
||||||
- pkg name with version spec (httpd-2.2.22), 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:
|
if rpms:
|
||||||
cls.install(packages)
|
cls.install(packages)
|
||||||
@ -364,7 +366,8 @@ class PackagesHandler(object):
|
|||||||
|
|
||||||
def _handle_yum_packages(self, packages):
|
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:
|
Arguments:
|
||||||
packages -- a package entries map of the form:
|
packages -- a package entries map of the form:
|
||||||
@ -395,7 +398,8 @@ class PackagesHandler(object):
|
|||||||
# FIXME:print non-error, but skipping pkg
|
# FIXME:print non-error, but skipping pkg
|
||||||
pass
|
pass
|
||||||
elif not RpmHelper.yum_package_available(pkg):
|
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:
|
elif not ver:
|
||||||
installs.append(pkg)
|
installs.append(pkg)
|
||||||
else:
|
else:
|
||||||
@ -412,7 +416,8 @@ class PackagesHandler(object):
|
|||||||
|
|
||||||
def _handle_rpm_packages(sef, packages):
|
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:
|
Arguments:
|
||||||
packages -- a package entries map of the form:
|
packages -- a package entries map of the form:
|
||||||
@ -466,6 +471,7 @@ class PackagesHandler(object):
|
|||||||
else:
|
else:
|
||||||
handler(self, package_entries)
|
handler(self, package_entries)
|
||||||
|
|
||||||
|
|
||||||
class FilesHandler(object):
|
class FilesHandler(object):
|
||||||
def __init__(self, files):
|
def __init__(self, files):
|
||||||
self._files = files
|
self._files = files
|
||||||
@ -720,9 +726,9 @@ class Metadata(object):
|
|||||||
"""
|
"""
|
||||||
Process the resource metadata
|
Process the resource metadata
|
||||||
"""
|
"""
|
||||||
# FIXME: when config sets are implemented, this should select the correct
|
# FIXME: when config sets are implemented, this should select the
|
||||||
# config set from the metadata, and send each config in the config set to
|
# correct config set from the metadata, and send each config in the
|
||||||
# process_config
|
# config set to process_config
|
||||||
if not self._is_valid_metadata():
|
if not self._is_valid_metadata():
|
||||||
raise Exception("invalid metadata")
|
raise Exception("invalid metadata")
|
||||||
else:
|
else:
|
||||||
|
@ -43,6 +43,8 @@ db_opts = [
|
|||||||
#conf.db_backend = 'heat.db.sqlalchemy.api'
|
#conf.db_backend = 'heat.db.sqlalchemy.api'
|
||||||
IMPL = heat.utils.LazyPluggable('db_backend',
|
IMPL = heat.utils.LazyPluggable('db_backend',
|
||||||
sqlalchemy='heat.db.sqlalchemy.api')
|
sqlalchemy='heat.db.sqlalchemy.api')
|
||||||
|
|
||||||
|
|
||||||
def configure(conf):
|
def configure(conf):
|
||||||
global SQL_CONNECTION
|
global SQL_CONNECTION
|
||||||
global SQL_IDLE_TIMEOUT
|
global SQL_IDLE_TIMEOUT
|
||||||
@ -50,7 +52,6 @@ def configure(conf):
|
|||||||
SQL_IDLE_TIMEOUT = conf.sql_idle_timeout
|
SQL_IDLE_TIMEOUT = conf.sql_idle_timeout
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def raw_template_get(context, template_id):
|
def raw_template_get(context, template_id):
|
||||||
return IMPL.raw_template_get(context, template_id)
|
return IMPL.raw_template_get(context, template_id)
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ from migrate.versioning import util as migrate_util
|
|||||||
|
|
||||||
_REPOSITORY = None
|
_REPOSITORY = None
|
||||||
|
|
||||||
|
|
||||||
@migrate_util.decorator
|
@migrate_util.decorator
|
||||||
def patched_with_engine(f, *a, **kw):
|
def patched_with_engine(f, *a, **kw):
|
||||||
url = a[0]
|
url = a[0]
|
||||||
|
@ -26,6 +26,7 @@ _MAKER = None
|
|||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class DBError(Error):
|
class DBError(Error):
|
||||||
"""Wraps an implementation specific exception."""
|
"""Wraps an implementation specific exception."""
|
||||||
def __init__(self, inner_exception=None):
|
def __init__(self, inner_exception=None):
|
||||||
@ -45,6 +46,7 @@ def _wrap_db_error(f):
|
|||||||
_wrap.func_name = f.func_name
|
_wrap.func_name = f.func_name
|
||||||
return _wrap
|
return _wrap
|
||||||
|
|
||||||
|
|
||||||
def get_session(autocommit=True, expire_on_commit=False):
|
def get_session(autocommit=True, expire_on_commit=False):
|
||||||
"""Return a SQLAlchemy session."""
|
"""Return a SQLAlchemy session."""
|
||||||
global _ENGINE, _MAKER
|
global _ENGINE, _MAKER
|
||||||
|
@ -163,7 +163,6 @@ class Stack(object):
|
|||||||
self.t['stack_status'] = new_status
|
self.t['stack_status'] = new_status
|
||||||
self.update_parsed_template()
|
self.update_parsed_template()
|
||||||
|
|
||||||
|
|
||||||
def create_blocking(self):
|
def create_blocking(self):
|
||||||
'''
|
'''
|
||||||
create all the resources in the order specified by get_create_order
|
create all the resources in the order specified by get_create_order
|
||||||
|
@ -23,6 +23,7 @@ from heat.openstack.common import importutils
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def create_connection(new=True):
|
def create_connection(new=True):
|
||||||
"""Create a connection to the message bus used for rpc.
|
"""Create a connection to the message bus used for rpc.
|
||||||
|
|
||||||
|
@ -24,12 +24,14 @@ from heat.db.sqlalchemy.session import get_engine
|
|||||||
|
|
||||||
_DB = None
|
_DB = None
|
||||||
|
|
||||||
|
|
||||||
def reset_db():
|
def reset_db():
|
||||||
engine = get_engine()
|
engine = get_engine()
|
||||||
engine.dispose()
|
engine.dispose()
|
||||||
conn = engine.connect()
|
conn = engine.connect()
|
||||||
conn.connection.executescript(_DB)
|
conn.connection.executescript(_DB)
|
||||||
|
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
import mox # Fail fast if you don't have mox. Workaround for bug 810424
|
import mox # Fail fast if you don't have mox. Workaround for bug 810424
|
||||||
|
|
||||||
|
@ -47,14 +47,16 @@ def setUp_credential_file():
|
|||||||
f.write('junk, just junk')
|
f.write('junk, just junk')
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
def tearDown_credential_file():
|
def tearDown_credential_file():
|
||||||
shutil.rmtree('/tmp/incredible', ignore_errors=True)
|
shutil.rmtree('/tmp/incredible', ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
@with_setup(setUp_credential_file, tearDown_credential_file)
|
@with_setup(setUp_credential_file, tearDown_credential_file)
|
||||||
@attr(tag=['unit', 'cfn-hup'])
|
@attr(tag=['unit', 'cfn-hup'])
|
||||||
@attr(speed='fast')
|
@attr(speed='fast')
|
||||||
def test_hup_conf1():
|
def test_hup_conf1():
|
||||||
good= """
|
good = """
|
||||||
[main]
|
[main]
|
||||||
stack=stack-test
|
stack=stack-test
|
||||||
credential-file=/tmp/incredible
|
credential-file=/tmp/incredible
|
||||||
@ -72,7 +74,7 @@ interval=3
|
|||||||
@attr(tag=['unit', 'cfn-hup'])
|
@attr(tag=['unit', 'cfn-hup'])
|
||||||
@attr(speed='fast')
|
@attr(speed='fast')
|
||||||
def test_hup_default():
|
def test_hup_default():
|
||||||
good= """
|
good = """
|
||||||
[main]
|
[main]
|
||||||
stack=stack-testr
|
stack=stack-testr
|
||||||
credential-file=/tmp/incredible
|
credential-file=/tmp/incredible
|
||||||
@ -88,7 +90,7 @@ credential-file=/tmp/incredible
|
|||||||
@attr(tag=['unit', 'cfn-hup'])
|
@attr(tag=['unit', 'cfn-hup'])
|
||||||
@attr(speed='fast')
|
@attr(speed='fast')
|
||||||
def test_hup_hook():
|
def test_hup_hook():
|
||||||
good= """
|
good = """
|
||||||
[main]
|
[main]
|
||||||
stack=stackname_is_fred
|
stack=stackname_is_fred
|
||||||
credential-file=/tmp/incredible
|
credential-file=/tmp/incredible
|
||||||
@ -129,7 +131,6 @@ class MetadataTest(unittest.TestCase):
|
|||||||
self.m.UnsetStubs()
|
self.m.UnsetStubs()
|
||||||
shutil.rmtree('/tmp/_files_test_', ignore_errors=True)
|
shutil.rmtree('/tmp/_files_test_', ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
@attr(tag=['unit', 'cfn-metadata'])
|
@attr(tag=['unit', 'cfn-metadata'])
|
||||||
@attr(speed='fast')
|
@attr(speed='fast')
|
||||||
def test_metadata_files(self):
|
def test_metadata_files(self):
|
||||||
@ -138,7 +139,7 @@ class MetadataTest(unittest.TestCase):
|
|||||||
"config" : {
|
"config" : {
|
||||||
"files" : {
|
"files" : {
|
||||||
"/tmp/_files_test_/epel.repo" : {
|
"/tmp/_files_test_/epel.repo" : {
|
||||||
"source" : "https://raw.github.com/heat-api/heat/master/README.rst",
|
"source" : "https://raw.github.com/heat-api/heat/master/README.rst",
|
||||||
"mode" : "000644"
|
"mode" : "000644"
|
||||||
},
|
},
|
||||||
"/tmp/_files_test_/_with/some/dirs/to/make/small.conf" : {
|
"/tmp/_files_test_/_with/some/dirs/to/make/small.conf" : {
|
||||||
@ -180,7 +181,8 @@ https://raw.github.com/heat-api/heat/master/README.rst'],
|
|||||||
os.chown('/tmp/_files_test_/epel.repo', -1, -1)
|
os.chown('/tmp/_files_test_/epel.repo', -1, -1)
|
||||||
os.chmod('/tmp/_files_test_/node.json', 384)
|
os.chmod('/tmp/_files_test_/node.json', 384)
|
||||||
os.chmod('/tmp/_files_test_/epel.repo', 420)
|
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)
|
os.chmod('/tmp/_files_test_/_with/some/dirs/to/make/small.conf', 511)
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ from heat.engine import resources
|
|||||||
import heat.db as db_api
|
import heat.db as db_api
|
||||||
from heat.engine import parser
|
from heat.engine import parser
|
||||||
|
|
||||||
|
|
||||||
@attr(tag=['unit', 'resource'])
|
@attr(tag=['unit', 'resource'])
|
||||||
@attr(speed='fast')
|
@attr(speed='fast')
|
||||||
class ResourcesTest(unittest.TestCase):
|
class ResourcesTest(unittest.TestCase):
|
||||||
@ -34,7 +35,7 @@ class ResourcesTest(unittest.TestCase):
|
|||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
parameters = {}
|
parameters = {}
|
||||||
params['KeyStoneCreds'] = None
|
params['KeyStoneCreds'] = None
|
||||||
t['Parameters']['KeyName']['Value'] = 'test'
|
t['Parameters']['KeyName']['Value'] = 'test'
|
||||||
stack = parser.Stack('test_stack', t, 0, params)
|
stack = parser.Stack('test_stack', t, 0, params)
|
||||||
|
|
||||||
@ -53,8 +54,9 @@ class ResourcesTest(unittest.TestCase):
|
|||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
|
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',\
|
instance = resources.Instance('test_resource_name',\
|
||||||
t['Resources']['WebServer'], stack)
|
t['Resources']['WebServer'], stack)
|
||||||
|
|
||||||
@ -66,7 +68,6 @@ class ResourcesTest(unittest.TestCase):
|
|||||||
AndReturn(self.fc.servers.list()[1])
|
AndReturn(self.fc.servers.list()[1])
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
|
|
||||||
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
|
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
|
||||||
instance.create()
|
instance.create()
|
||||||
|
|
||||||
@ -85,7 +86,7 @@ class ResourcesTest(unittest.TestCase):
|
|||||||
|
|
||||||
params = {}
|
params = {}
|
||||||
parameters = {}
|
parameters = {}
|
||||||
params['KeyStoneCreds'] = None
|
params['KeyStoneCreds'] = None
|
||||||
t['Parameters']['KeyName']['Value'] = 'test'
|
t['Parameters']['KeyName']['Value'] = 'test'
|
||||||
stack = parser.Stack('test_stack', t, 0, params)
|
stack = parser.Stack('test_stack', t, 0, params)
|
||||||
|
|
||||||
@ -104,8 +105,9 @@ class ResourcesTest(unittest.TestCase):
|
|||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
|
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',\
|
instance = resources.Instance('test_resource_name',\
|
||||||
t['Resources']['WebServer'], stack)
|
t['Resources']['WebServer'], stack)
|
||||||
|
|
||||||
@ -117,7 +119,6 @@ class ResourcesTest(unittest.TestCase):
|
|||||||
AndReturn(self.fc.servers.list()[1])
|
AndReturn(self.fc.servers.list()[1])
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
|
|
||||||
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
|
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
|
||||||
instance.create()
|
instance.create()
|
||||||
|
|
||||||
@ -131,9 +132,7 @@ class ResourcesTest(unittest.TestCase):
|
|||||||
assert(instance.instance_id == None)
|
assert(instance.instance_id == None)
|
||||||
assert(instance.state == instance.DELETE_COMPLETE)
|
assert(instance.state == instance.DELETE_COMPLETE)
|
||||||
|
|
||||||
|
|
||||||
# allows testing of the test directly, shown below
|
# allows testing of the test directly, shown below
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.argv.append(__file__)
|
sys.argv.append(__file__)
|
||||||
nose.main()
|
nose.main()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user