update stack_create to accept a specific region name

This commit is contained in:
QI ZHANG 2015-03-11 17:59:57 +08:00
parent c48f381643
commit ee6b7a8b06
7 changed files with 15 additions and 3 deletions

View File

@ -25,6 +25,7 @@ def upgrade(migrate_engine):
primary_key=True, nullable=False),
sqlalchemy.Column('name', sqlalchemy.String(255)),
sqlalchemy.Column('type', sqlalchemy.String(255)),
sqlalchemy.Column('identifier', sqlalchemy.String(255)),
sqlalchemy.Column('spec', types.Dict),
sqlalchemy.Column('permission', sqlalchemy.String(32)),
sqlalchemy.Column('tags', types.Dict),

View File

@ -218,6 +218,7 @@ class Profile(BASE, SenlinBase, SoftDelete):
id = sqlalchemy.Column('id', sqlalchemy.String(36), primary_key=True,
default=lambda: str(uuid.uuid4()))
name = sqlalchemy.Column(sqlalchemy.String(255))
identifier = sqlalchemy.Column(sqlalchemy.String(255))
type = sqlalchemy.Column(sqlalchemy.String(255))
spec = sqlalchemy.Column(types.Dict)
permission = sqlalchemy.Column(sqlalchemy.String(32))

View File

@ -12,6 +12,8 @@
from senlin.common import sdk
from senlin.drivers import base
from openstack.auth import service_filter
from openstack.orchestration import orchestration_service
from senlin.openstack.orchestration.v1 import stack
@ -24,6 +26,13 @@ class HeatClient(base.DriverBase):
self.auth = self.session.authenticator
def stack_create(self, **params):
if params["identifier"]:
default = orchestration_service.OrchestrationService()
preference = service_filter.ServiceFilter('orchestration', region=params["identifier"])
service = preference.join(default)
else:
service = orchestration_service.OrchestrationService()
stack.Stack.service = service
obj = stack.Stack.new(**params)
try:
return obj.create(self.session)

View File

@ -196,7 +196,7 @@ class EngineService(service.Service):
kwargs = {
'spec': spec,
'permission': perm,
'tags': tags,
'tags': tags
}
profile = plugin(type, name, **kwargs)
profile.validate()

View File

@ -12,7 +12,6 @@
from openstack import exceptions
from openstack.orchestration import orchestration_service
from openstack import resource
from openstack import utils
@ -21,7 +20,6 @@ class Stack(resource.Resource):
resource_key = 'stack'
resources_key = 'stacks'
base_path = '/stacks'
service = orchestration_service.OrchestrationService()
# capabilities
allow_list = True

View File

@ -41,6 +41,7 @@ class Profile(object):
self.name = name
self.type = type_name
self.id = kwargs.get('id', None)
self.identifier = kwargs.get('identifier', None)
self.context = kwargs.get('context', None)
@ -65,6 +66,7 @@ class Profile(object):
'spec': record.spec,
'permission': record.permission,
'tags': record.tags,
'identifier': record.identifier,
'created_time': record.created_time,
'updated_time': record.updated_time,
'deleted_time': record.deleted_time,

View File

@ -147,6 +147,7 @@ class StackProfile(base.Profile):
kwargs = {
'stack_name': obj.name,
'identifier': self.identifier,
'template': self.spec_data[self.TEMPLATE],
'timeout_mins': self.spec_data[self.TIMEOUT],
'disable_rollback': self.spec_data[self.DISABLE_ROLLBACK],