Merge "Switched heat engine from JSON to HOT"

This commit is contained in:
Jenkins 2015-04-10 13:00:56 +00:00 committed by Gerrit Code Review
commit 882328204c
8 changed files with 334 additions and 479 deletions

View File

@ -35,7 +35,7 @@ LOG = logging.getLogger(__name__)
class HeatEngine(e.Engine): class HeatEngine(e.Engine):
def get_type_and_version(self): def get_type_and_version(self):
return "heat.1.2" return "heat.2.0"
def _add_volumes(self, ctx, cluster): def _add_volumes(self, ctx, cluster):
for instance in g.get_instances(cluster): for instance in g.get_instances(cluster):

View File

@ -13,11 +13,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import json
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import six import six
import yaml
from sahara.utils import general as g from sahara.utils import general as g
from sahara.utils.openstack import heat as h from sahara.utils.openstack import heat as h
@ -71,11 +71,11 @@ class ClusterTemplate(object):
} }
def _get_main_template(self): def _get_main_template(self):
return json.dumps({ return yaml.safe_dump({
"AWSTemplateFormatVersion": "2010-09-09", "heat_template_version": "2013-05-23",
"Description": "Data Processing Cluster by Sahara", "description": "Data Processing Cluster by Sahara",
"Resources": self._serialize_resources(), "resources": self._serialize_resources(),
"Outputs": {} "outputs": {}
}) })
def instantiate(self, update_existing, disable_rollback=True): def instantiate(self, update_existing, disable_rollback=True):
@ -136,8 +136,8 @@ class ClusterTemplate(object):
return { return {
security_group_name: { security_group_name: {
"Type": "AWS::EC2::SecurityGroup", "type": "AWS::EC2::SecurityGroup",
"Properties": { "properties": {
"GroupDescription": security_group_description, "GroupDescription": security_group_description,
"SecurityGroupIngress": rules "SecurityGroupIngress": rules
} }
@ -213,8 +213,8 @@ class ClusterTemplate(object):
resources.update({ resources.update({
inst_name: { inst_name: {
"Type": "OS::Nova::Server", "type": "OS::Nova::Server",
"Properties": properties "properties": properties
} }
}) })
@ -235,8 +235,8 @@ class ClusterTemplate(object):
return { return {
port_name: { port_name: {
"Type": "OS::Neutron::Port", "type": "OS::Neutron::Port",
"Properties": properties "properties": properties
} }
} }
@ -246,8 +246,8 @@ class ClusterTemplate(object):
return { return {
floating_ip_name: { floating_ip_name: {
"Type": "OS::Neutron::FloatingIP", "type": "OS::Neutron::FloatingIP",
"Properties": { "properties": {
"floating_network_id": floating_net_id, "floating_network_id": floating_net_id,
"port_id": {"Ref": port_name} "port_id": {"Ref": port_name}
} }
@ -259,14 +259,14 @@ class ClusterTemplate(object):
floating_ip_assoc_name = _get_floating_assoc_name(inst_name) floating_ip_assoc_name = _get_floating_assoc_name(inst_name)
return { return {
floating_ip_name: { floating_ip_name: {
"Type": "OS::Nova::FloatingIP", "type": "OS::Nova::FloatingIP",
"Properties": { "properties": {
"pool": floating_pool_name "pool": floating_pool_name
} }
}, },
floating_ip_assoc_name: { floating_ip_assoc_name: {
"Type": "OS::Nova::FloatingIPAssociation", "type": "OS::Nova::FloatingIPAssociation",
"Properties": { "properties": {
"floating_ip": {"Ref": floating_ip_name}, "floating_ip": {"Ref": floating_ip_name},
"server_id": {"Ref": inst_name} "server_id": {"Ref": inst_name}
} }
@ -292,12 +292,12 @@ class ClusterTemplate(object):
return { return {
volume_name: { volume_name: {
"Type": "OS::Cinder::Volume", "type": "OS::Cinder::Volume",
"Properties": properties "properties": properties
}, },
volume_attach_name: { volume_attach_name: {
"Type": "OS::Cinder::VolumeAttachment", "type": "OS::Cinder::VolumeAttachment",
"Properties": { "properties": {
"instance_uuid": {"Ref": inst_name}, "instance_uuid": {"Ref": inst_name},
"volume_id": {"Ref": volume_name}, "volume_id": {"Ref": volume_name},
"mountpoint": None "mountpoint": None
@ -316,8 +316,8 @@ class ClusterTemplate(object):
server_group_name = _get_aa_group_name(self.cluster.name) server_group_name = _get_aa_group_name(self.cluster.name)
return { return {
server_group_name: { server_group_name: {
"Type": "OS::Nova::ServerGroup", "type": "OS::Nova::ServerGroup",
"Properties": { "properties": {
"name": server_group_name, "name": server_group_name,
"policies": ["anti-affinity"] "policies": ["anti-affinity"]
} }

View File

@ -1,96 +1,76 @@
{ description: Data Processing Cluster by Sahara
"AWSTemplateFormatVersion" : "2010-09-09", heat_template_version: '2013-05-23'
"Description" : "Data Processing Cluster by Sahara", outputs: {}
resources:
cluster-aa-group:
properties:
name: cluster-aa-group
policies: [anti-affinity]
type: OS::Nova::ServerGroup
cluster-master-001:
properties:
admin_user: root
flavor: '42'
image: '1'
key_name: user_key
name: cluster-master-001
networks:
- port: {Ref: cluster-master-001-port}
user_data: 'line1
"Resources" : { line2'
"cluster-aa-group" : { type: OS::Nova::Server
"Type" : "OS::Nova::ServerGroup", cluster-master-001-floating:
"Properties" : { properties:
"name" : "cluster-aa-group", floating_network_id: floating
"policies": ["anti-affinity"] port_id: {Ref: cluster-master-001-port}
} type: OS::Neutron::FloatingIP
}, cluster-master-001-port:
"cluster-worker-001-port" : { properties: {network_id: private_net, replacement_policy: AUTO}
"Type" : "OS::Neutron::Port", type: OS::Neutron::Port
"Properties" : { cluster-worker-001:
"network_id" : "private_net", properties:
"replacement_policy": "AUTO" admin_user: root
} flavor: '42'
}, image: '1'
"cluster-worker-001-floating" : { key_name: user_key
"Type" : "OS::Neutron::FloatingIP" , name: cluster-worker-001
"Properties" : { networks:
"floating_network_id" : "floating", - port: {Ref: cluster-worker-001-port}
"port_id" : { "Ref" : "cluster-worker-001-port" } scheduler_hints:
} group: {Ref: cluster-aa-group}
}, user_data: 'line2
"cluster-worker-001" : {
"Type" : "OS::Nova::Server",
"Properties" : {
"name" : "cluster-worker-001",
"flavor" : "42",
"image" : "1",
"admin_user": "root",
"networks" : [{ "port" : { "Ref" : "cluster-worker-001-port" }}],
"key_name" : "user_key",
"scheduler_hints" : {"group": {"Ref": "cluster-aa-group"}},
"user_data": "line2\nline3"
}
},
"cluster-worker-002-port" : {
"Type" : "OS::Neutron::Port",
"Properties" : {
"network_id" : "private_net",
"replacement_policy": "AUTO"
}
},
"cluster-worker-002-floating" : {
"Type" : "OS::Neutron::FloatingIP" ,
"Properties" : {
"floating_network_id" : "floating",
"port_id" : { "Ref" : "cluster-worker-002-port" }
}
},
"cluster-worker-002" : {
"Type" : "OS::Nova::Server",
"Properties" : {
"name" : "cluster-worker-002",
"flavor" : "42",
"image" : "1",
"admin_user": "root",
"networks" : [{ "port" : { "Ref" : "cluster-worker-002-port" }}],
"key_name" : "user_key",
"scheduler_hints" : {"group": {"Ref": "cluster-aa-group"}},
"user_data": "line2\nline3"
}
},
"cluster-master-001-port" : {
"Type" : "OS::Neutron::Port",
"Properties" : {
"network_id" : "private_net",
"replacement_policy": "AUTO"
}
},
"cluster-master-001-floating" : {
"Type" : "OS::Neutron::FloatingIP" ,
"Properties" : {
"floating_network_id" : "floating",
"port_id" : { "Ref" : "cluster-master-001-port" }
}
},
"cluster-master-001" : {
"Type" : "OS::Nova::Server",
"Properties" : {
"name" : "cluster-master-001",
"flavor" : "42",
"image" : "1",
"admin_user": "root",
"networks" : [{ "port" : { "Ref" : "cluster-master-001-port" }}],
"key_name" : "user_key",
"user_data" : "line1\nline2"
}
}
},
"Outputs" : {} line3'
} type: OS::Nova::Server
cluster-worker-001-floating:
properties:
floating_network_id: floating
port_id: {Ref: cluster-worker-001-port}
type: OS::Neutron::FloatingIP
cluster-worker-001-port:
properties: {network_id: private_net, replacement_policy: AUTO}
type: OS::Neutron::Port
cluster-worker-002:
properties:
admin_user: root
flavor: '42'
image: '1'
key_name: user_key
name: cluster-worker-002
networks:
- port: {Ref: cluster-worker-002-port}
scheduler_hints:
group: {Ref: cluster-aa-group}
user_data: 'line2
line3'
type: OS::Nova::Server
cluster-worker-002-floating:
properties:
floating_network_id: floating
port_id: {Ref: cluster-worker-002-port}
type: OS::Neutron::FloatingIP
cluster-worker-002-port:
properties: {network_id: private_net, replacement_policy: AUTO}
type: OS::Neutron::Port

View File

@ -1,93 +1,64 @@
{ description: Data Processing Cluster by Sahara
"AWSTemplateFormatVersion" : "2010-09-09", heat_template_version: '2013-05-23'
"Description" : "Data Processing Cluster by Sahara", outputs: {}
resources:
cluster-master-001:
properties:
admin_user: root
flavor: '42'
image: '1'
key_name: user_key
name: cluster-master-001
networks:
- port: {Ref: cluster-master-001-port}
user_data: 'line1
"Resources" : { line2'
"cluster-worker-001-port" : { type: OS::Nova::Server
"Type" : "OS::Neutron::Port", cluster-master-001-floating:
"Properties" : { properties:
"network_id" : "private_net", floating_network_id: floating
"replacement_policy": "AUTO" port_id: {Ref: cluster-master-001-port}
} type: OS::Neutron::FloatingIP
}, cluster-master-001-port:
"cluster-worker-001-floating" : { properties: {network_id: private_net, replacement_policy: AUTO}
"Type" : "OS::Neutron::FloatingIP" , type: OS::Neutron::Port
"Properties" : { cluster-worker-001:
"floating_network_id" : "floating", properties:
"port_id" : { "Ref" : "cluster-worker-001-port" } admin_user: root
} flavor: '42'
}, image: '1'
"cluster-worker-001" : { key_name: user_key
"Type" : "OS::Nova::Server", name: cluster-worker-001
"Properties" : { networks:
"name" : "cluster-worker-001", - port: {Ref: cluster-worker-001-port}
"flavor" : "42", user_data: 'line2
"image" : "1",
"admin_user": "root",
"networks" : [{ "port" : { "Ref" : "cluster-worker-001-port" }}],
"key_name" : "user_key",
"user_data": "line2\nline3"
}
},
"cluster-worker-001-volume-0" : {
"Type" : "OS::Cinder::Volume",
"Properties" : {
"name" : "cluster-worker-001-volume-0",
"size" : "10",
"volume_type" : "vol_type"
}
},
"cluster-worker-001-volume-attachment-0" : {
"Type" : "OS::Cinder::VolumeAttachment",
"Properties" : {
"instance_uuid" : { "Ref" : "cluster-worker-001" },
"volume_id" : { "Ref" : "cluster-worker-001-volume-0" },
"mountpoint" : null
}
},
"cluster-worker-001-volume-1" : {
"Type" : "OS::Cinder::Volume",
"Properties" : {
"name" : "cluster-worker-001-volume-1",
"size" : "10",
"volume_type": "vol_type"
}
},
"cluster-worker-001-volume-attachment-1" : {
"Type" : "OS::Cinder::VolumeAttachment",
"Properties" : {
"instance_uuid" : { "Ref" : "cluster-worker-001" },
"volume_id" : { "Ref" : "cluster-worker-001-volume-1" },
"mountpoint" : null
}
},
"cluster-master-001-port" : {
"Type" : "OS::Neutron::Port",
"Properties" : {
"network_id" : "private_net",
"replacement_policy": "AUTO"
}
},
"cluster-master-001-floating" : {
"Type" : "OS::Neutron::FloatingIP" ,
"Properties" : {
"floating_network_id" : "floating",
"port_id" : { "Ref" : "cluster-master-001-port" }
}
},
"cluster-master-001" : {
"Type" : "OS::Nova::Server",
"Properties" : {
"name" : "cluster-master-001",
"flavor" : "42",
"image" : "1",
"admin_user": "root",
"networks" : [{ "port" : { "Ref" : "cluster-master-001-port" }}],
"key_name" : "user_key",
"user_data": "line1\nline2"
}
}
},
"Outputs" : {} line3'
} type: OS::Nova::Server
cluster-worker-001-floating:
properties:
floating_network_id: floating
port_id: {Ref: cluster-worker-001-port}
type: OS::Neutron::FloatingIP
cluster-worker-001-port:
properties: {network_id: private_net, replacement_policy: AUTO}
type: OS::Neutron::Port
cluster-worker-001-volume-0:
properties: {name: cluster-worker-001-volume-0, size: '10', volume_type: vol_type}
type: OS::Cinder::Volume
cluster-worker-001-volume-1:
properties: {name: cluster-worker-001-volume-1, size: '10', volume_type: vol_type}
type: OS::Cinder::Volume
cluster-worker-001-volume-attachment-0:
properties:
instance_uuid: {Ref: cluster-worker-001}
mountpoint: null
volume_id: {Ref: cluster-worker-001-volume-0}
type: OS::Cinder::VolumeAttachment
cluster-worker-001-volume-attachment-1:
properties:
instance_uuid: {Ref: cluster-worker-001}
mountpoint: null
volume_id: {Ref: cluster-worker-001-volume-1}
type: OS::Cinder::VolumeAttachment

View File

@ -1,63 +1,34 @@
{ description: Data Processing Cluster by Sahara
"AWSTemplateFormatVersion" : "2010-09-09", heat_template_version: '2013-05-23'
"Description" : "Data Processing Cluster by Sahara", outputs: {}
resources:
cluster-master-001:
properties: {admin_user: root, flavor: '42', image: '1', key_name: user_key, name: cluster-master-001,
user_data: 'line1
"Resources" : { line2'}
"cluster-worker-001" : { type: OS::Nova::Server
"Type" : "OS::Nova::Server", cluster-worker-001:
"Properties" : { properties: {admin_user: root, flavor: '42', image: '1', key_name: user_key, name: cluster-worker-001,
"name" : "cluster-worker-001", user_data: 'line2
"flavor" : "42",
"image" : "1",
"admin_user": "root",
"key_name" : "user_key",
"user_data": "line2\nline3"
}
},
"cluster-worker-001-volume-0" : {
"Type" : "OS::Cinder::Volume",
"Properties" : {
"name" : "cluster-worker-001-volume-0",
"size" : "10",
"volume_type": null
}
},
"cluster-worker-001-volume-attachment-0" : {
"Type" : "OS::Cinder::VolumeAttachment",
"Properties" : {
"instance_uuid" : { "Ref" : "cluster-worker-001" },
"volume_id" : { "Ref" : "cluster-worker-001-volume-0" },
"mountpoint" : null
}
},
"cluster-worker-001-volume-1" : {
"Type" : "OS::Cinder::Volume",
"Properties" : {
"name" : "cluster-worker-001-volume-1",
"size" : "10",
"volume_type": null
}
},
"cluster-worker-001-volume-attachment-1" : {
"Type" : "OS::Cinder::VolumeAttachment",
"Properties" : {
"instance_uuid" : { "Ref" : "cluster-worker-001" },
"volume_id" : { "Ref" : "cluster-worker-001-volume-1" },
"mountpoint" : null
}
},
"cluster-master-001" : {
"Type" : "OS::Nova::Server",
"Properties" : {
"name" : "cluster-master-001",
"flavor" : "42",
"image" : "1",
"admin_user": "root",
"key_name" : "user_key",
"user_data": "line1\nline2"
}
}
},
"Outputs" : {} line3'}
} type: OS::Nova::Server
cluster-worker-001-volume-0:
properties: {name: cluster-worker-001-volume-0, size: '10', volume_type: null}
type: OS::Cinder::Volume
cluster-worker-001-volume-1:
properties: {name: cluster-worker-001-volume-1, size: '10', volume_type: null}
type: OS::Cinder::Volume
cluster-worker-001-volume-attachment-0:
properties:
instance_uuid: {Ref: cluster-worker-001}
mountpoint: null
volume_id: {Ref: cluster-worker-001-volume-0}
type: OS::Cinder::VolumeAttachment
cluster-worker-001-volume-attachment-1:
properties:
instance_uuid: {Ref: cluster-worker-001}
mountpoint: null
volume_id: {Ref: cluster-worker-001-volume-1}
type: OS::Cinder::VolumeAttachment

View File

@ -1,89 +1,50 @@
{ description: Data Processing Cluster by Sahara
"AWSTemplateFormatVersion" : "2010-09-09", heat_template_version: '2013-05-23'
"Description" : "Data Processing Cluster by Sahara", outputs: {}
resources:
cluster-master-001:
properties: {admin_user: root, flavor: '42', image: '1', key_name: user_key, name: cluster-master-001,
user_data: 'line1
"Resources" : { line2'}
"cluster-worker-001-floating-assoc" : { type: OS::Nova::Server
"Type" : "OS::Nova::FloatingIPAssociation", cluster-master-001-floating:
"Properties" : { properties: {pool: floating}
"floating_ip" : { "Ref" : "cluster-worker-001-floating" }, type: OS::Nova::FloatingIP
"server_id" : { "Ref" : "cluster-worker-001" } cluster-master-001-floating-assoc:
} properties:
}, floating_ip: {Ref: cluster-master-001-floating}
"cluster-worker-001-floating" : { server_id: {Ref: cluster-master-001}
"Type" : "OS::Nova::FloatingIP", type: OS::Nova::FloatingIPAssociation
"Properties" : { cluster-worker-001:
"pool" : "floating" properties: {admin_user: root, flavor: '42', image: '1', key_name: user_key, name: cluster-worker-001,
} user_data: 'line2
},
"cluster-worker-001" : {
"Type" : "OS::Nova::Server",
"Properties" : {
"name" : "cluster-worker-001",
"flavor" : "42",
"image" : "1",
"admin_user": "root",
"key_name" : "user_key",
"user_data": "line2\nline3"
}
},
"cluster-worker-001-volume-0" : {
"Type" : "OS::Cinder::Volume",
"Properties" : {
"name" : "cluster-worker-001-volume-0",
"size" : "10",
"volume_type": null
}
},
"cluster-worker-001-volume-attachment-0" : {
"Type" : "OS::Cinder::VolumeAttachment",
"Properties" : {
"instance_uuid" : { "Ref" : "cluster-worker-001" },
"volume_id" : { "Ref" : "cluster-worker-001-volume-0" },
"mountpoint" : null
}
},
"cluster-worker-001-volume-1" : {
"Type" : "OS::Cinder::Volume",
"Properties" : {
"name" : "cluster-worker-001-volume-1",
"size" : "10",
"volume_type": null
}
},
"cluster-worker-001-volume-attachment-1" : {
"Type" : "OS::Cinder::VolumeAttachment",
"Properties" : {
"instance_uuid" : { "Ref" : "cluster-worker-001" },
"volume_id" : { "Ref" : "cluster-worker-001-volume-1" },
"mountpoint" : null
}
},
"cluster-master-001-floating-assoc" : {
"Type" : "OS::Nova::FloatingIPAssociation",
"Properties" : {
"floating_ip" : { "Ref" : "cluster-master-001-floating" },
"server_id" : { "Ref" : "cluster-master-001" }
}
},
"cluster-master-001-floating" : {
"Type" : "OS::Nova::FloatingIP",
"Properties" : {
"pool" : "floating"
}
},
"cluster-master-001" : {
"Type" : "OS::Nova::Server",
"Properties" : {
"name" : "cluster-master-001",
"flavor" : "42",
"image" : "1",
"admin_user": "root",
"key_name" : "user_key",
"user_data": "line1\nline2"
}
}
},
"Outputs" : {} line3'}
} type: OS::Nova::Server
cluster-worker-001-floating:
properties: {pool: floating}
type: OS::Nova::FloatingIP
cluster-worker-001-floating-assoc:
properties:
floating_ip: {Ref: cluster-worker-001-floating}
server_id: {Ref: cluster-worker-001}
type: OS::Nova::FloatingIPAssociation
cluster-worker-001-volume-0:
properties: {name: cluster-worker-001-volume-0, size: '10', volume_type: null}
type: OS::Cinder::Volume
cluster-worker-001-volume-1:
properties: {name: cluster-worker-001-volume-1, size: '10', volume_type: null}
type: OS::Cinder::Volume
cluster-worker-001-volume-attachment-0:
properties:
instance_uuid: {Ref: cluster-worker-001}
mountpoint: null
volume_id: {Ref: cluster-worker-001-volume-0}
type: OS::Cinder::VolumeAttachment
cluster-worker-001-volume-attachment-1:
properties:
instance_uuid: {Ref: cluster-worker-001}
mountpoint: null
volume_id: {Ref: cluster-worker-001-volume-1}
type: OS::Cinder::VolumeAttachment

View File

@ -1,110 +1,83 @@
{ description: Data Processing Cluster by Sahara
"AWSTemplateFormatVersion" : "2010-09-09", heat_template_version: '2013-05-23'
"Description" : "Data Processing Cluster by Sahara", outputs: {}
resources:
cluster-master-001:
properties:
admin_user: root
flavor: '42'
image: '1'
key_name: user_key
name: cluster-master-001
networks:
- port: {Ref: cluster-master-001-port}
user_data: 'line1
"Resources" : { line2'
"cluster-worker-001-port" : { type: OS::Nova::Server
"Type" : "OS::Neutron::Port", cluster-master-001-floating:
"Properties" : { properties:
"network_id" : "private_net", floating_network_id: floating
"replacement_policy": "AUTO" port_id: {Ref: cluster-master-001-port}
} type: OS::Neutron::FloatingIP
}, cluster-master-001-port:
"cluster-worker-001-floating" : { properties: {network_id: private_net, replacement_policy: AUTO}
"Type" : "OS::Neutron::FloatingIP" , type: OS::Neutron::Port
"Properties" : { cluster-master-001-volume-0:
"floating_network_id" : "floating", properties: {name: cluster-master-001-volume-0, size: '10', volume_type: null}
"port_id" : { "Ref" : "cluster-worker-001-port" } type: OS::Cinder::Volume
} cluster-master-001-volume-attachment-0:
}, properties:
"cluster-worker-001" : { instance_uuid: {Ref: cluster-master-001}
"Type" : "OS::Nova::Server", mountpoint: null
"Properties" : { volume_id: {Ref: cluster-master-001-volume-0}
"name" : "cluster-worker-001", type: OS::Cinder::VolumeAttachment
"flavor" : "42", cluster-worker-001:
"image" : "1", properties:
"admin_user": "root", admin_user: root
"networks" : [{ "port" : { "Ref" : "cluster-worker-001-port" }}], flavor: '42'
"key_name" : "user_key", image: '1'
"user_data": "line2\nline3" key_name: user_key
} name: cluster-worker-001
}, networks:
"cluster-worker-001-volume-0" : { - port: {Ref: cluster-worker-001-port}
"Type" : "OS::Cinder::Volume", user_data: 'line2
"Properties" : {
"name" : "cluster-worker-001-volume-0",
"size" : "10",
"scheduler_hints": {"local_to_instance": {"Ref": "cluster-worker-001"}},
"volume_type" : "vol_type"
}
},
"cluster-worker-001-volume-attachment-0" : {
"Type" : "OS::Cinder::VolumeAttachment",
"Properties" : {
"instance_uuid" : { "Ref" : "cluster-worker-001" },
"volume_id" : { "Ref" : "cluster-worker-001-volume-0" },
"mountpoint" : null
}
},
"cluster-worker-001-volume-1" : {
"Type" : "OS::Cinder::Volume",
"Properties" : {
"name" : "cluster-worker-001-volume-1",
"size" : "10",
"scheduler_hints": {"local_to_instance": {"Ref": "cluster-worker-001"}},
"volume_type": "vol_type"
}
},
"cluster-worker-001-volume-attachment-1" : {
"Type" : "OS::Cinder::VolumeAttachment",
"Properties" : {
"instance_uuid" : { "Ref" : "cluster-worker-001" },
"volume_id" : { "Ref" : "cluster-worker-001-volume-1" },
"mountpoint" : null
}
},
"cluster-master-001-port" : {
"Type" : "OS::Neutron::Port",
"Properties" : {
"network_id" : "private_net",
"replacement_policy": "AUTO"
}
},
"cluster-master-001-floating" : {
"Type" : "OS::Neutron::FloatingIP" ,
"Properties" : {
"floating_network_id" : "floating",
"port_id" : { "Ref" : "cluster-master-001-port" }
}
},
"cluster-master-001" : {
"Type" : "OS::Nova::Server",
"Properties" : {
"name" : "cluster-master-001",
"flavor" : "42",
"image" : "1",
"admin_user": "root",
"networks" : [{ "port" : { "Ref" : "cluster-master-001-port" }}],
"key_name" : "user_key",
"user_data": "line1\nline2"
}
},
"cluster-master-001-volume-0": {
"Type": "OS::Cinder::Volume",
"Properties": {
"name": "cluster-master-001-volume-0",
"size": "10",
"volume_type": null
}
},
"cluster-master-001-volume-attachment-0": {
"Type": "OS::Cinder::VolumeAttachment",
"Properties": {
"instance_uuid": {"Ref": "cluster-master-001"},
"volume_id": {"Ref": "cluster-master-001-volume-0"},
"mountpoint": null}
}
},
"Outputs" : {} line3'
} type: OS::Nova::Server
cluster-worker-001-floating:
properties:
floating_network_id: floating
port_id: {Ref: cluster-worker-001-port}
type: OS::Neutron::FloatingIP
cluster-worker-001-port:
properties: {network_id: private_net, replacement_policy: AUTO}
type: OS::Neutron::Port
cluster-worker-001-volume-0:
properties:
name: cluster-worker-001-volume-0
scheduler_hints:
local_to_instance: {Ref: cluster-worker-001}
size: '10'
volume_type: vol_type
type: OS::Cinder::Volume
cluster-worker-001-volume-1:
properties:
name: cluster-worker-001-volume-1
scheduler_hints:
local_to_instance: {Ref: cluster-worker-001}
size: '10'
volume_type: vol_type
type: OS::Cinder::Volume
cluster-worker-001-volume-attachment-0:
properties:
instance_uuid: {Ref: cluster-worker-001}
mountpoint: null
volume_id: {Ref: cluster-worker-001-volume-0}
type: OS::Cinder::VolumeAttachment
cluster-worker-001-volume-attachment-1:
properties:
instance_uuid: {Ref: cluster-worker-001}
mountpoint: null
volume_id: {Ref: cluster-worker-001-volume-1}
type: OS::Cinder::VolumeAttachment

View File

@ -13,9 +13,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import json
import testtools import testtools
import yaml
from sahara.service.heat import templates as h from sahara.service.heat import templates as h
from sahara.tests.unit import base from sahara.tests.unit import base
@ -110,10 +109,10 @@ class TestClusterTemplate(base.SaharaWithDbTestCase):
main_template = heat_template._get_main_template() main_template = heat_template._get_main_template()
self.assertEqual( self.assertEqual(
json.loads(f.get_file_text( yaml.load(f.get_file_text(
"tests/unit/resources/" "tests/unit/resources/"
"test_serialize_resources_use_neutron.heat")), "test_serialize_resources_use_neutron.heat")),
json.loads(main_template) yaml.load(main_template)
) )
def test_load_template_use_nova_network_without_autoassignment(self): def test_load_template_use_nova_network_without_autoassignment(self):
@ -132,10 +131,10 @@ class TestClusterTemplate(base.SaharaWithDbTestCase):
main_template = heat_template._get_main_template() main_template = heat_template._get_main_template()
self.assertEqual( self.assertEqual(
json.loads(f.get_file_text( yaml.load(f.get_file_text(
"tests/unit/resources/test_serialize_" "tests/unit/resources/test_serialize_"
"resources_use_nn_without_autoassignment.heat")), "resources_use_nn_without_autoassignment.heat")),
json.loads(main_template) yaml.load(main_template)
) )
def test_load_template_use_nova_network_with_autoassignment(self): def test_load_template_use_nova_network_with_autoassignment(self):
@ -154,10 +153,10 @@ class TestClusterTemplate(base.SaharaWithDbTestCase):
main_template = heat_template._get_main_template() main_template = heat_template._get_main_template()
self.assertEqual( self.assertEqual(
json.loads(f.get_file_text( yaml.load(f.get_file_text(
"tests/unit/resources/" "tests/unit/resources/"
"test_serialize_resources_use_nn_with_autoassignment.heat")), "test_serialize_resources_use_nn_with_autoassignment.heat")),
json.loads(main_template) yaml.load(main_template)
) )
def test_load_template_with_anti_affinity_single_ng(self): def test_load_template_with_anti_affinity_single_ng(self):
@ -191,10 +190,10 @@ class TestClusterTemplate(base.SaharaWithDbTestCase):
main_template = aa_heat_template._get_main_template() main_template = aa_heat_template._get_main_template()
self.assertEqual( self.assertEqual(
json.loads(f.get_file_text( yaml.load(f.get_file_text(
"tests/unit/resources/" "tests/unit/resources/"
"test_serialize_resources_aa.heat")), "test_serialize_resources_aa.heat")),
json.loads(main_template) yaml.load(main_template)
) )
def test_load_template_with_volume_local_to_instance(self): def test_load_template_with_volume_local_to_instance(self):
@ -229,10 +228,10 @@ class TestClusterTemplate(base.SaharaWithDbTestCase):
main_template = heat_template._get_main_template() main_template = heat_template._get_main_template()
self.assertEqual( self.assertEqual(
json.loads(f.get_file_text( yaml.load(f.get_file_text(
"tests/unit/resources/" "tests/unit/resources/"
"test_serialize_resources_volume_local_to_instance.heat")), "test_serialize_resources_volume_local_to_instance.heat")),
json.loads(main_template)) yaml.load(main_template))
def get_ud_generator(s): def get_ud_generator(s):