From ee6b7a8b06e9882ec4f446bf609e3410b66a5503 Mon Sep 17 00:00:00 2001 From: QI ZHANG Date: Wed, 11 Mar 2015 17:59:57 +0800 Subject: [PATCH] update stack_create to accept a specific region name --- .../migrate_repo/versions/001_first_version.py | 1 + senlin/db/sqlalchemy/models.py | 1 + senlin/drivers/heat_v1.py | 9 +++++++++ senlin/engine/service.py | 2 +- senlin/openstack/orchestration/v1/stack.py | 2 -- senlin/profiles/base.py | 2 ++ senlin/profiles/os/heat/stack.py | 1 + 7 files changed, 15 insertions(+), 3 deletions(-) diff --git a/senlin/db/sqlalchemy/migrate_repo/versions/001_first_version.py b/senlin/db/sqlalchemy/migrate_repo/versions/001_first_version.py index 4b17b497b..6eae6bcd8 100644 --- a/senlin/db/sqlalchemy/migrate_repo/versions/001_first_version.py +++ b/senlin/db/sqlalchemy/migrate_repo/versions/001_first_version.py @@ -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), diff --git a/senlin/db/sqlalchemy/models.py b/senlin/db/sqlalchemy/models.py index 1d7259b87..0f6913e79 100644 --- a/senlin/db/sqlalchemy/models.py +++ b/senlin/db/sqlalchemy/models.py @@ -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)) diff --git a/senlin/drivers/heat_v1.py b/senlin/drivers/heat_v1.py index b54c3fcab..84f845109 100644 --- a/senlin/drivers/heat_v1.py +++ b/senlin/drivers/heat_v1.py @@ -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) diff --git a/senlin/engine/service.py b/senlin/engine/service.py index dde31c35c..8d675ceae 100644 --- a/senlin/engine/service.py +++ b/senlin/engine/service.py @@ -196,7 +196,7 @@ class EngineService(service.Service): kwargs = { 'spec': spec, 'permission': perm, - 'tags': tags, + 'tags': tags } profile = plugin(type, name, **kwargs) profile.validate() diff --git a/senlin/openstack/orchestration/v1/stack.py b/senlin/openstack/orchestration/v1/stack.py index 631f747d0..2f98728e8 100644 --- a/senlin/openstack/orchestration/v1/stack.py +++ b/senlin/openstack/orchestration/v1/stack.py @@ -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 diff --git a/senlin/profiles/base.py b/senlin/profiles/base.py index 64f739e24..8c9bf62d5 100644 --- a/senlin/profiles/base.py +++ b/senlin/profiles/base.py @@ -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, diff --git a/senlin/profiles/os/heat/stack.py b/senlin/profiles/os/heat/stack.py index cbe2a26fc..13d874d83 100644 --- a/senlin/profiles/os/heat/stack.py +++ b/senlin/profiles/os/heat/stack.py @@ -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],