+ def add_volume(self, name, size=10):
+ """add to the template a volume description"""
+ log.debug("adding Cinder::Volume '%s' size '%d' ", name, size)
+
+ self.resources[name] = {
+ 'type': 'OS::Cinder::Volume',
+ 'properties': {'name': name,
+ 'size': size}
+ }
+
+ self._template['outputs'][name] = {
+ 'description': 'Volume %s ID' % name,
+ 'value': {'get_resource': name}
+ }
+
+ def add_volume_attachment(self, server_name, volume_name, mountpoint=None):
+ """add to the template an association of volume to instance"""
+ log.debug("adding Cinder::VolumeAttachment server '%s' volume '%s' ", server_name,
+ volume_name)
+
+ name = "%s-%s" % (server_name, volume_name)
+
+ volume_id = op_utils.get_volume_id(volume_name)
+ if not volume_id:
+ volume_id = {'get_resource': volume_name}
+ self.resources[name] = {
+ 'type': 'OS::Cinder::VolumeAttachment',
+ 'properties': {'instance_uuid': {'get_resource': server_name},
+ 'volume_id': volume_id}
+ }
+
+ if mountpoint:
+ self.resources[name]['properties']['mountpoint'] = mountpoint
+
+ def add_network(self, name, physical_network='physnet1', provider=None,
+ segmentation_id=None, port_security_enabled=None, network_type=None):
+ """add to the template a Neutron Net"""
+ log.debug("adding Neutron::Net '%s'", name)
+ if provider is None:
+ self.resources[name] = {
+ 'type': 'OS::Neutron::Net',
+ 'properties': {
+ 'name': name,
+ }
+ }
+ else:
+ self.resources[name] = {
+ 'type': 'OS::Neutron::ProviderNet',
+ 'properties': {
+ 'name': name,
+ 'network_type': 'flat' if network_type is None else network_type,
+ 'physical_network': physical_network,
+ },
+ }
+ if segmentation_id:
+ self.resources[name]['properties']['segmentation_id'] = segmentation_id
+ if network_type is None:
+ self.resources[name]['properties']['network_type'] = 'vlan'
+ # if port security is not defined then don't add to template:
+ # some deployments don't have port security plugin installed
+ if port_security_enabled is not None:
+ self.resources[name]['properties']['port_security_enabled'] = port_security_enabled
+