summaryrefslogtreecommitdiff
path: root/trove/common
diff options
context:
space:
mode:
Diffstat (limited to 'trove/common')
-rw-r--r--trove/common/cfg.py5
-rw-r--r--trove/common/remote.py13
-rw-r--r--trove/common/template.py57
3 files changed, 75 insertions, 0 deletions
diff --git a/trove/common/cfg.py b/trove/common/cfg.py
index 58992135..b53936d9 100644
--- a/trove/common/cfg.py
+++ b/trove/common/cfg.py
@@ -50,6 +50,7 @@ common_opts = [
help='Remote implementation for using fake integration code'),
cfg.StrOpt('nova_compute_url', default='http://localhost:8774/v2'),
cfg.StrOpt('cinder_url', default='http://localhost:8776/v2'),
+ cfg.StrOpt('heat_url', default='http://localhost:8004/v1'),
cfg.StrOpt('swift_url', default='http://localhost:8080/v1/AUTH_'),
cfg.StrOpt('trove_auth_url', default='http://0.0.0.0:5000/v2.0'),
cfg.StrOpt('host', default='0.0.0.0'),
@@ -100,6 +101,7 @@ common_opts = [
help='default driver to use for quota checks'),
cfg.StrOpt('taskmanager_queue', default='taskmanager'),
cfg.BoolOpt('use_nova_server_volume', default=False),
+ cfg.BoolOpt('use_heat', default=False),
cfg.StrOpt('fake_mode_events', default='simulated'),
cfg.StrOpt('device_path', default='/dev/vdb'),
cfg.StrOpt('mount_point', default='/var/lib/mysql'),
@@ -107,6 +109,7 @@ common_opts = [
cfg.StrOpt('block_device_mapping', default='vdb'),
cfg.IntOpt('server_delete_time_out', default=2),
cfg.IntOpt('volume_time_out', default=2),
+ cfg.IntOpt('heat_time_out', default=60),
cfg.IntOpt('reboot_time_out', default=60 * 2),
cfg.StrOpt('service_options', default=['mysql']),
cfg.IntOpt('dns_time_out', default=60 * 2),
@@ -169,6 +172,8 @@ common_opts = [
default='trove.common.remote.nova_client'),
cfg.StrOpt('remote_cinder_client',
default='trove.common.remote.cinder_client'),
+ cfg.StrOpt('remote_heat_client',
+ default='trove.common.remote.heat_client'),
cfg.StrOpt('remote_swift_client',
default='trove.common.remote.swift_client'),
cfg.StrOpt('exists_notification_transformer',
diff --git a/trove/common/remote.py b/trove/common/remote.py
index 3fdf2a9f..f6b91d75 100644
--- a/trove/common/remote.py
+++ b/trove/common/remote.py
@@ -18,6 +18,7 @@
from trove.common import cfg
from trove.openstack.common.importutils import import_class
from cinderclient.v2 import client as CinderClient
+from heatclient.v1 import client as HeatClient
from novaclient.v1_1.client import Client
from swiftclient.client import Connection
@@ -28,6 +29,7 @@ PROXY_AUTH_URL = CONF.trove_auth_url
VOLUME_URL = CONF.cinder_url
OBJECT_STORE_URL = CONF.swift_url
USE_SNET = CONF.backup_use_snet
+HEAT_URL = CONF.heat_url
def dns_client(context):
@@ -68,6 +70,16 @@ def cinder_client(context):
return client
+def heat_client(context):
+ endpoint = "%s/%s/" % (HEAT_URL, context.tenant)
+ client = HeatClient.Client(username=context.user,
+ password="radmin",
+ token=context.auth_token,
+ os_no_client_auth=True,
+ endpoint=endpoint)
+ return client
+
+
def swift_client(context):
client = Connection(preauthurl=OBJECT_STORE_URL + context.tenant,
preauthtoken=context.auth_token,
@@ -81,3 +93,4 @@ create_guest_client = import_class(CONF.remote_guest_client)
create_nova_client = import_class(CONF.remote_nova_client)
create_swift_client = import_class(CONF.remote_swift_client)
create_cinder_client = import_class(CONF.remote_cinder_client)
+create_heat_client = import_class(CONF.remote_heat_client)
diff --git a/trove/common/template.py b/trove/common/template.py
index f1ed754d..8edb355b 100644
--- a/trove/common/template.py
+++ b/trove/common/template.py
@@ -45,3 +45,60 @@ class SingleInstanceConfigTemplate(object):
self.config_contents = self.template.render(
flavor=self.flavor_dict)
return self.config_contents
+
+
+class HeatTemplate(object):
+ template_contents = """HeatTemplateFormatVersion: '2012-12-12'
+Description: Instance creation
+Parameters:
+ KeyName: {Type: String}
+ Flavor: {Type: String}
+ VolumeSize: {Type: Number}
+ ServiceType: {Type: String}
+ InstanceId: {Type: String}
+Resources:
+ BaseInstance:
+ Type: AWS::EC2::Instance
+ Metadata:
+ AWS::CloudFormation::Init:
+ config:
+ files:
+ /etc/guest_info:
+ content:
+ Fn::Join:
+ - ''
+ - ["[DEFAULT]\\nguest_id=", {Ref: InstanceId},
+ "\\nservice_type=", {Ref: ServiceType}]
+ mode: '000644'
+ owner: root
+ group: root
+ Properties:
+ ImageId:
+ Fn::Join:
+ - ''
+ - ["ubuntu_", {Ref: ServiceType}]
+ InstanceType: {Ref: Flavor}
+ KeyName: {Ref: KeyName}
+ UserData:
+ Fn::Base64:
+ Fn::Join:
+ - ''
+ - ["#!/bin/bash -v\\n",
+ "/opt/aws/bin/cfn-init\\n",
+ "sudo service trove-guest start\\n"]
+ DataVolume:
+ Type: AWS::EC2::Volume
+ Properties:
+ Size: {Ref: VolumeSize}
+ AvailabilityZone: nova
+ Tags:
+ - {Key: Usage, Value: Test}
+ MountPoint:
+ Type: AWS::EC2::VolumeAttachment
+ Properties:
+ InstanceId: {Ref: BaseInstance}
+ VolumeId: {Ref: DataVolume}
+ Device: /dev/vdb"""
+
+ def template(self):
+ return self.template_contents