Defaulting to the mysql db_backend, removing anydbm
This commit is contained in:
parent
1c96afa502
commit
dc696e5e9c
|
@ -178,7 +178,7 @@ class HeatEngineConfigOpts(cfg.CommonConfigOpts):
|
||||||
help='port for os volume api to listen'),
|
help='port for os volume api to listen'),
|
||||||
]
|
]
|
||||||
db_opts = [
|
db_opts = [
|
||||||
cfg.StrOpt('db_backend', default='heat.db.anydbm.api', help='The backend to use for db'),
|
cfg.StrOpt('db_backend', default='heat.db.sqlalchemy.api', help='The backend to use for db'),
|
||||||
cfg.StrOpt('sql_connection',
|
cfg.StrOpt('sql_connection',
|
||||||
default='mysql://heat:heat@localhost/heat',
|
default='mysql://heat:heat@localhost/heat',
|
||||||
help='The SQLAlchemy connection string used to connect to the '
|
help='The SQLAlchemy connection string used to connect to the '
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
||||||
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import anydbm
|
|
||||||
import json
|
|
||||||
|
|
||||||
class Dummy:
|
|
||||||
id = 0
|
|
||||||
|
|
||||||
def raw_template_get(context, template_id):
|
|
||||||
return 'test return value'
|
|
||||||
|
|
||||||
def raw_template_get_all(context):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def raw_template_create(context, values):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def parsed_template_get_all(context):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def parsed_template_create(context, values):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def state_get(context, state_id):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def state_get_all(context):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def state_create(context, values):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def resource_get(context, resource_id):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def resource_get_all(context):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def resource_create(context, values):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def stack_get(context, stack_id):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def stack_get_all(context):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def stack_create(context, values):
|
|
||||||
return Dummy()
|
|
||||||
|
|
||||||
def event_get(context, event_id):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def event_get_all(context):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def event_get_all_by_stack(context, stack_id):
|
|
||||||
events = {'events': []}
|
|
||||||
try:
|
|
||||||
d = anydbm.open('/var/lib/heat/%s.events.db' % stack_id, 'r')
|
|
||||||
except:
|
|
||||||
return events
|
|
||||||
|
|
||||||
for k, v in d.iteritems():
|
|
||||||
if k != 'lastid':
|
|
||||||
events['events'].append(json.loads(v))
|
|
||||||
|
|
||||||
d.close()
|
|
||||||
return events
|
|
||||||
|
|
||||||
def event_create(context, event):
|
|
||||||
'''
|
|
||||||
EventId The unique ID of this event.
|
|
||||||
Timestamp Time the status was updated.
|
|
||||||
'''
|
|
||||||
name = event['stack_name']
|
|
||||||
d = anydbm.open('/var/lib/heat/%s.events.db' % name, 'c')
|
|
||||||
if d.has_key('lastid'):
|
|
||||||
newid = int(d['lastid']) + 1
|
|
||||||
else:
|
|
||||||
newid = 1
|
|
||||||
event['event_id'] = '%d' % newid
|
|
||||||
d['lastid'] = event['event_id']
|
|
||||||
d[event['event_id']] = json.dumps(event)
|
|
||||||
|
|
||||||
d.close()
|
|
|
@ -89,6 +89,7 @@ class EngineManager(manager.Manager):
|
||||||
stack = parser.Stack(stack_name, template, params)
|
stack = parser.Stack(stack_name, template, params)
|
||||||
rt = {}
|
rt = {}
|
||||||
rt['template'] = template
|
rt['template'] = template
|
||||||
|
rt['stack_name'] = stack_name
|
||||||
new_rt = db_api.raw_template_create(None, rt)
|
new_rt = db_api.raw_template_create(None, rt)
|
||||||
s = {}
|
s = {}
|
||||||
s['name'] = stack_name
|
s['name'] = stack_name
|
||||||
|
|
|
@ -413,6 +413,7 @@ class Instance(Resource):
|
||||||
rs['nova_instance'] = self.instance_id
|
rs['nova_instance'] = self.instance_id
|
||||||
rs['stack_id'] = self.stack.id
|
rs['stack_id'] = self.stack.id
|
||||||
rs['name'] = self.name
|
rs['name'] = self.name
|
||||||
|
rs['stack_name'] = self.stack.name
|
||||||
new_rs = db_api.resource_create(None, rs)
|
new_rs = db_api.resource_create(None, rs)
|
||||||
self.id = new_rs.id
|
self.id = new_rs.id
|
||||||
# just record the first ipaddress
|
# just record the first ipaddress
|
||||||
|
|
Loading…
Reference in New Issue