Skip to content

Commit 08023a8

Browse files
author
earthmant
committed
add volume bootable handling from bootable property.
add ipv6 example
1 parent 1b2455f commit 08023a8

6 files changed

Lines changed: 199 additions & 5 deletions

File tree

blueprints/ipv6.yaml

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
tosca_definitions_version: cloudify_dsl_1_3
2+
3+
imports:
4+
- http://www.getcloudify.org/spec/cloudify/4.4/types.yaml
5+
- http://www.getcloudify.org/spec/openstack-plugin/2.9.6/plugin.yaml
6+
7+
inputs:
8+
9+
username:
10+
description: OS_USERNAME as specified in Openstack RC file.
11+
12+
password:
13+
description: Openstack user password.
14+
15+
tenant_name:
16+
description: OS_TENANT_NAME as specified in Openstack RC file.
17+
18+
auth_url:
19+
description: OS_AUTH_URL as specified in Openstack RC file.
20+
21+
region:
22+
description: OS_REGION_NAME as specified in Openstack RC file.
23+
24+
external_network_name:
25+
description: Openstack tenant external network name.
26+
27+
key_name:
28+
type: string
29+
30+
ipv4_nameservers:
31+
default:
32+
- 8.8.4.4
33+
- 8.8.8.8
34+
35+
ipv4_subnet_cidr:
36+
default: 192.168.120.0/24
37+
38+
ipv4_allocation_pools:
39+
default:
40+
- start: 192.168.120.2
41+
end: 192.168.120.254
42+
43+
ipv6_nameservers:
44+
default:
45+
- 2001:4860:4860::8888
46+
- 2001:4860:4860::8844
47+
48+
ipv6_subnet_cidr:
49+
default: 2605:1c00:50f2:2207::/64
50+
51+
ipv6_allocation_pools:
52+
default:
53+
- start: 2605:1c00:50f2:2207::64
54+
end: 2605:1c00:50f2:2207:ffff:ffff:ffff:ff
55+
56+
large_image_flavor:
57+
type: string
58+
59+
cloudify_image_username:
60+
default: centos
61+
62+
centos_core_image:
63+
type: string
64+
65+
dsl_definitions:
66+
67+
client_config: &client_config
68+
username: { get_input: username }
69+
password: { get_input: password }
70+
tenant_name: { get_input: tenant_name }
71+
auth_url: { get_input: auth_url }
72+
region: { get_input: region }
73+
74+
node_templates:
75+
76+
external_network:
77+
type: cloudify.openstack.nodes.Network
78+
properties:
79+
openstack_config: *client_config
80+
use_external_resource: true
81+
resource_id: { get_input: external_network_name }
82+
83+
router:
84+
type: cloudify.openstack.nodes.Router
85+
properties:
86+
openstack_config: *client_config
87+
relationships:
88+
- type: cloudify.relationships.connected_to
89+
target: external_network
90+
91+
network:
92+
type: cloudify.openstack.nodes.Network
93+
properties:
94+
openstack_config: *client_config
95+
96+
ipv4_subnet:
97+
type: cloudify.openstack.nodes.Subnet
98+
properties:
99+
openstack_config: *client_config
100+
subnet:
101+
ip_version: 4
102+
cidr: { get_input: ipv4_subnet_cidr }
103+
dns_nameservers: { get_input: ipv4_nameservers }
104+
allocation_pools: { get_input: ipv4_allocation_pools }
105+
relationships:
106+
- type: cloudify.relationships.contained_in
107+
target: network
108+
- type: cloudify.openstack.subnet_connected_to_router
109+
target: router
110+
111+
ipv6_subnet:
112+
type: cloudify.openstack.nodes.Subnet
113+
properties:
114+
openstack_config: *client_config
115+
subnet:
116+
ip_version: 6
117+
cidr: { get_input: ipv6_subnet_cidr }
118+
dns_nameservers: { get_input: ipv6_nameservers }
119+
allocation_pools: { get_input: ipv6_allocation_pools }
120+
relationships:
121+
- type: cloudify.relationships.contained_in
122+
target: network
123+
124+
cloudify_security_group:
125+
type: cloudify.openstack.nodes.SecurityGroup
126+
properties:
127+
openstack_config: *client_config
128+
rules:
129+
- remote_ip_prefix: 0.0.0.0/0
130+
port_range_min: null
131+
port_range_max: null
132+
protocol: icmp
133+
- remote_ip_prefix: 0.0.0.0/0
134+
port_range_min: 22
135+
port_range_max: 22
136+
protocol: tcp
137+
138+
ipv4_port:
139+
type: cloudify.openstack.nodes.Port
140+
properties:
141+
openstack_config: *client_config
142+
relationships:
143+
- type: cloudify.relationships.contained_in
144+
target: network
145+
- type: cloudify.relationships.depends_on
146+
target: ipv4_subnet
147+
- type: cloudify.openstack.port_connected_to_security_group
148+
target: cloudify_security_group
149+
150+
ipv6_port:
151+
type: cloudify.openstack.nodes.Port
152+
properties:
153+
openstack_config: *client_config
154+
relationships:
155+
- type: cloudify.relationships.contained_in
156+
target: network
157+
- type: cloudify.relationships.depends_on
158+
target: ipv6_subnet
159+
- type: cloudify.openstack.port_connected_to_security_group
160+
target: cloudify_security_group
161+
162+
host:
163+
type: cloudify.openstack.nodes.Server
164+
properties:
165+
openstack_config: *client_config
166+
agent_config:
167+
install_method: none
168+
server:
169+
key_name: { get_input: key_name }
170+
image: { get_input: centos_core_image }
171+
flavor: { get_input: large_image_flavor }
172+
relationships:
173+
- type: cloudify.openstack.server_connected_to_port
174+
target: ipv4_port
175+
- type: cloudify.openstack.server_connected_to_port
176+
target: ipv6_port

cinder_plugin/tests/test_volume.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def test_create_new(self):
5656

5757
creating_volume_m = mock.Mock()
5858
creating_volume_m.id = volume_id
59+
creating_volume_m.bootable = False
5960
creating_volume_m.status = volume.VOLUME_STATUS_CREATING
6061
available_volume_m = mock.Mock()
6162
available_volume_m.id = volume_id
@@ -82,6 +83,8 @@ def test_create_new(self):
8283
self.assertEqual(
8384
volume.VOLUME_OPENSTACK_TYPE,
8485
ctx_m.instance.runtime_properties[OPENSTACK_TYPE_PROPERTY])
86+
self.assertFalse(
87+
ctx_m.instance.runtime_properties[volume.VOLUME_BOOTABLE])
8588

8689
def test_create_use_existing(self):
8790
volume_id = '00000000-0000-0000-0000-000000000000'

cinder_plugin/volume.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,28 @@
4848

4949
VOLUME_OPENSTACK_TYPE = 'volume'
5050
VOLUME_OPENSTACK_ID_KEY = 'name'
51+
VOLUME_BOOTABLE = 'bootable'
5152

5253
RUNTIME_PROPERTIES_KEYS = COMMON_RUNTIME_PROPERTIES_KEYS
5354

5455

5556
def _set_volume_runtime_properties(volume):
57+
5658
try:
5759
ctx.instance.runtime_properties[OPENSTACK_AZ_PROPERTY] = \
5860
volume.availability_zone
5961
except AttributeError:
6062
ctx.logger.error('Volume availability_zone not found.')
6163

64+
try:
65+
ctx.instance.runtime_properties[VOLUME_BOOTABLE] = \
66+
volume.bootable
67+
except AttributeError:
68+
if ctx.node.properties.get('boot', False):
69+
ctx.instance.runtime_properties[VOLUME_BOOTABLE] = True
70+
else:
71+
ctx.instance.runtime_properties[VOLUME_BOOTABLE] = False
72+
6273

6374
@operation
6475
@with_cinder_client

nova_plugin/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
get_server_floating_ip)
6363
from neutron_plugin.network import NETWORK_OPENSTACK_TYPE
6464
from neutron_plugin.port import PORT_OPENSTACK_TYPE
65-
from cinder_plugin.volume import VOLUME_OPENSTACK_TYPE
65+
from cinder_plugin.volume import VOLUME_OPENSTACK_TYPE, VOLUME_BOOTABLE
6666
from openstack_plugin_common.security_group import \
6767
SECURITY_GROUP_OPENSTACK_TYPE
6868
from glance_plugin.image import handle_image_from_relationship
@@ -212,7 +212,7 @@ def _get_boot_volume_relationships(type_name, ctx):
212212
for rel in ctx.instance.relationships
213213
if rel.target.instance.runtime_properties.get(
214214
OPENSTACK_TYPE_PROPERTY) == type_name and
215-
rel.target.node.properties.get('boot', False)]
215+
rel.target.instance.runtime_properties.get(VOLUME_BOOTABLE, False)]
216216

217217
if not targets:
218218
return None

nova_plugin/tests/test_server.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from nova_plugin.tests.test_relationships import RelationshipsTestBase
3131
from nova_plugin.server import _prepare_server_nics
3232
from novaclient import exceptions as nova_exceptions
33-
from cinder_plugin.volume import VOLUME_OPENSTACK_TYPE
33+
from cinder_plugin.volume import VOLUME_OPENSTACK_TYPE, VOLUME_BOOTABLE
3434
from cloudify.exceptions import NonRecoverableError, RecoverableError
3535
from cloudify.state import current_ctx
3636

@@ -1076,7 +1076,8 @@ def _get_ctx_mock(self, instance_id, boot):
10761076
properties={'boot': boot}), instance=MockNodeInstanceContext(
10771077
runtime_properties={
10781078
OPENSTACK_TYPE_PROPERTY: VOLUME_OPENSTACK_TYPE,
1079-
OPENSTACK_ID_PROPERTY: instance_id
1079+
OPENSTACK_ID_PROPERTY: instance_id,
1080+
VOLUME_BOOTABLE: False
10801081
})))]
10811082
ctx = mock.MagicMock()
10821083
ctx.instance = MockNodeInstanceContext(relationships=rel_specs)
@@ -1086,6 +1087,8 @@ def _get_ctx_mock(self, instance_id, boot):
10861087
def test_boot_volume_relationship(self):
10871088
instance_id = 'test-id'
10881089
ctx = self._get_ctx_mock(instance_id, True)
1090+
rel_target = ctx.instance.relationships[0].target
1091+
rel_target.instance.runtime_properties[VOLUME_BOOTABLE] = True
10891092
result = nova_plugin.server._get_boot_volume_relationships(
10901093
VOLUME_OPENSTACK_TYPE, ctx)
10911094
self.assertEqual(

plugin.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,11 @@ node_types:
920920
username, password, tenant_name, auth_url, region.
921921
boot:
922922
type: boolean
923-
default: false
923+
required: false
924924
description: >
925925
If a Server instance is connected to this Volume by a relationship,
926926
this volume will be used as the boot volume for that Server.
927+
This option will be deprecated in the future.
927928
interfaces:
928929
cloudify.interfaces.lifecycle:
929930
create:

0 commit comments

Comments
 (0)