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:
|
||||
- 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:
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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]
|
||||
@ -55,7 +56,7 @@ except ImportError:
|
||||
from migrate import exceptions as versioning_exceptions
|
||||
except ImportError:
|
||||
sys.exit(_("python-migrate is not installed. Exiting."))
|
||||
|
||||
|
||||
#_REPOSITORY = None
|
||||
|
||||
|
||||
@ -86,7 +87,7 @@ def db_version():
|
||||
engine = get_engine()
|
||||
meta.reflect(bind=engine)
|
||||
try:
|
||||
for table in ('stack', 'resource', 'event',
|
||||
for table in ('stack', 'resource', 'event',
|
||||
'parsed_template', 'raw_template'):
|
||||
assert table in meta.tables
|
||||
return db_version_control(1)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -47,14 +47,16 @@ 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')
|
||||
def test_hup_conf1():
|
||||
good= """
|
||||
good = """
|
||||
[main]
|
||||
stack=stack-test
|
||||
credential-file=/tmp/incredible
|
||||
@ -72,7 +74,7 @@ interval=3
|
||||
@attr(tag=['unit', 'cfn-hup'])
|
||||
@attr(speed='fast')
|
||||
def test_hup_default():
|
||||
good= """
|
||||
good = """
|
||||
[main]
|
||||
stack=stack-testr
|
||||
credential-file=/tmp/incredible
|
||||
@ -88,7 +90,7 @@ credential-file=/tmp/incredible
|
||||
@attr(tag=['unit', 'cfn-hup'])
|
||||
@attr(speed='fast')
|
||||
def test_hup_hook():
|
||||
good= """
|
||||
good = """
|
||||
[main]
|
||||
stack=stackname_is_fred
|
||||
credential-file=/tmp/incredible
|
||||
@ -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):
|
||||
@ -138,7 +139,7 @@ class MetadataTest(unittest.TestCase):
|
||||
"config" : {
|
||||
"files" : {
|
||||
"/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"
|
||||
},
|
||||
"/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.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()
|
||||
|
||||
|
@ -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):
|
||||
@ -34,10 +35,10 @@ class ResourcesTest(unittest.TestCase):
|
||||
|
||||
params = {}
|
||||
parameters = {}
|
||||
params['KeyStoneCreds'] = None
|
||||
params['KeyStoneCreds'] = None
|
||||
t['Parameters']['KeyName']['Value'] = 'test'
|
||||
stack = parser.Stack('test_stack', t, 0, params)
|
||||
|
||||
|
||||
self.m.StubOutWithMock(db_api, 'resource_get_by_name_and_stack')
|
||||
db_api.resource_get_by_name_and_stack(None, 'test_resource_name',\
|
||||
stack).AndReturn(None)
|
||||
@ -52,12 +53,13 @@ class ResourcesTest(unittest.TestCase):
|
||||
userdata = t['Resources']['WebServer']['Properties']['UserData']
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
||||
t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
|
||||
t['Resources']['WebServer']['Properties']['InstanceType'] = '256 MB Server'
|
||||
|
||||
t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
|
||||
t['Resources']['WebServer']['Properties']['InstanceType'] = \
|
||||
'256 MB Server'
|
||||
instance = resources.Instance('test_resource_name',\
|
||||
t['Resources']['WebServer'], stack)
|
||||
|
||||
|
||||
server_userdata = instance._build_userdata(json.dumps(userdata))
|
||||
self.m.StubOutWithMock(self.fc.servers, 'create')
|
||||
self.fc.servers.create(image=1, flavor=1, key_name='test',\
|
||||
@ -65,11 +67,10 @@ class ResourcesTest(unittest.TestCase):
|
||||
userdata=server_userdata).\
|
||||
AndReturn(self.fc.servers.list()[1])
|
||||
self.m.ReplayAll()
|
||||
|
||||
|
||||
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
|
||||
instance.create()
|
||||
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
||||
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
|
||||
@ -85,10 +86,10 @@ class ResourcesTest(unittest.TestCase):
|
||||
|
||||
params = {}
|
||||
parameters = {}
|
||||
params['KeyStoneCreds'] = None
|
||||
params['KeyStoneCreds'] = None
|
||||
t['Parameters']['KeyName']['Value'] = 'test'
|
||||
stack = parser.Stack('test_stack', t, 0, params)
|
||||
|
||||
|
||||
self.m.StubOutWithMock(db_api, 'resource_get_by_name_and_stack')
|
||||
db_api.resource_get_by_name_and_stack(None, 'test_resource_name',\
|
||||
stack).AndReturn(None)
|
||||
@ -103,12 +104,13 @@ class ResourcesTest(unittest.TestCase):
|
||||
userdata = t['Resources']['WebServer']['Properties']['UserData']
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
||||
t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
|
||||
t['Resources']['WebServer']['Properties']['InstanceType'] = '256 MB Server'
|
||||
|
||||
t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
|
||||
t['Resources']['WebServer']['Properties']['InstanceType'] = \
|
||||
'256 MB Server'
|
||||
instance = resources.Instance('test_resource_name',\
|
||||
t['Resources']['WebServer'], stack)
|
||||
|
||||
|
||||
server_userdata = instance._build_userdata(json.dumps(userdata))
|
||||
self.m.StubOutWithMock(self.fc.servers, 'create')
|
||||
self.fc.servers.create(image=1, flavor=1, key_name='test',\
|
||||
@ -116,13 +118,12 @@ class ResourcesTest(unittest.TestCase):
|
||||
userdata=server_userdata).\
|
||||
AndReturn(self.fc.servers.list()[1])
|
||||
self.m.ReplayAll()
|
||||
|
||||
|
||||
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
|
||||
instance.create()
|
||||
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
||||
|
||||
instance.instance_id = 1234
|
||||
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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user