aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClint Byrum <clint@fewbar.com>2013-05-14 11:19:43 -0700
committerClint Byrum <clint@fewbar.com>2013-06-06 09:25:27 -0700
commitd5e511f945152cc860640b5276272c50830e735d (patch)
treed97078c7b84efe41b5edebcdb29fd2a61bf2c3ff
parent621a4dd9ca7029d1cc3bf46aa595f94d659479d5 (diff)
Add ability to combine roles into one role.
-rw-r--r--glance.yaml1
-rw-r--r--heat.yaml1
-rw-r--r--keystone.yaml1
-rw-r--r--merge.py29
-rw-r--r--quantum.yaml1
-rw-r--r--rabbitmq.yaml1
6 files changed, 31 insertions, 3 deletions
diff --git a/glance.yaml b/glance.yaml
index af75b224..b5c0079f 100644
--- a/glance.yaml
+++ b/glance.yaml
@@ -48,6 +48,7 @@ Resources:
InstanceType: {Ref: InstanceType}
KeyName: {Ref: KeyName}
Metadata:
+ OpenStack::Role: stateless
OpenStack::ImageBuilder::Elements: [ glance ]
heat:
access_key_id:
diff --git a/heat.yaml b/heat.yaml
index 4c64983d..770a6483 100644
--- a/heat.yaml
+++ b/heat.yaml
@@ -83,7 +83,6 @@ Resources:
{Ref: HeatApiImage}
InstanceType: {Ref: InstanceType}
KeyName: {Ref: KeyName}
- UserData: "#!/bin/bash\ntouch /tmp/userdata-finished\necho Userdata finished $(date)\n"
HeatAPI:
Type: OS::Heat::InstanceGroup
Properties:
diff --git a/keystone.yaml b/keystone.yaml
index 5c55c115..e4b96d71 100644
--- a/keystone.yaml
+++ b/keystone.yaml
@@ -38,6 +38,7 @@ Resources:
InstanceType: {Ref: InstanceType}
KeyName: {Ref: KeyName}
Metadata:
+ OpenStack::Role: stateless
OpenStack::ImageBuilder::Elements: [ keystone ]
heat:
access_key_id:
diff --git a/merge.py b/merge.py
index b1443f29..e0a5645c 100644
--- a/merge.py
+++ b/merge.py
@@ -1,7 +1,33 @@
import sys
import yaml
+import argparse
-templates = list(sys.argv[1:])
+parser = argparse.ArgumentParser()
+parser.add_argument('templates', nargs='+')
+parser.add_argument('--master-role', nargs='?',
+ help='Translate slave_roles to this')
+parser.add_argument('--slave-roles', nargs='*',
+ help='Translate all of these to master_role')
+
+args = parser.parse_args()
+
+templates = args.templates
+
+def _translate_role(role):
+ global args
+ if not args.master_role:
+ return role
+ if role == args.master_role:
+ return role
+ if role not in args.slave_roles:
+ return role
+ return args.master_role
+
+def translate_role(role):
+ r = _translate_role(role)
+ if not isinstance(r, basestring):
+ raise Exception('%s -> %r' % (role, r))
+ return r
errors = []
end_template={'HeatTemplateFormatVersion': '2012-12-12',
@@ -39,6 +65,7 @@ for template_path in templates:
# XXX Assuming ImageId is always a Ref
del end_template['Parameters'][rbody['Properties']['ImageId']['Ref']]
role = rbody.get('Metadata', {}).get('OpenStack::Role', r)
+ role = translate_role(role)
if role != r:
resource_changes.append((r, role))
if role in end_template.get('Resources', {}):
diff --git a/quantum.yaml b/quantum.yaml
index c7eaed02..bc08f014 100644
--- a/quantum.yaml
+++ b/quantum.yaml
@@ -51,6 +51,7 @@ Resources:
InstanceType: {Ref: InstanceType}
KeyName: {Ref: KeyName}
Metadata:
+ OpenStack::Role: networking
OpenStack::ImageBuilder::Elements: [ quantum ]
heat:
access_key_id:
diff --git a/rabbitmq.yaml b/rabbitmq.yaml
index 701f2d04..d8fdb5f6 100644
--- a/rabbitmq.yaml
+++ b/rabbitmq.yaml
@@ -24,7 +24,6 @@ Resources:
{Ref: RabbitMQImage}
InstanceType: {Ref: InstanceType}
KeyName: {Ref: KeyName}
- UserData: "#!/bin/bash\ntouch /tmp/userdata-finished\necho Userdata finished $(date)\n"
RabbitMQPasswordHandle:
Type: AWS::CloudFormation::WaitConditionHandle
RabbitMQPassword: