-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathvolume_api500.rb
173 lines (155 loc) · 4.42 KB
/
volume_api500.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# (c) Copyright 2020 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
my_client = {
url: ENV['ONEVIEWSDK_URL'],
user: ENV['ONEVIEWSDK_USER'],
password: ENV['ONEVIEWSDK_PASSWORD'],
api_version: 600
}
store_serv_properties = {
description: 'Volume store serv',
isShareable: true,
provisioningType: 'Thin',
size: 1024 * 1024 * 1024 # 1GB
}
store_virtual_properties = {
description: 'Volume store virtual',
isShareable: true,
provisioningType: 'Thin',
size: 1024 * 1024 * 1024, # 1GB
dataProtectionLevel: 'NetworkRaid10Mirror2Way'
}
# Example: Create a simple store serv volume
oneview_volume 'CHEF_VOL_01' do
client my_client
data(store_serv_properties)
storage_pool 'CPG-SSD-AO'
storage_system 'ThreePAR-1'
action :create_if_missing
end
# Example: Update a volume
oneview_volume 'CHEF_VOL_01' do
client my_client
data(description: 'Volume store serv Updated')
storage_pool 'CPG-SSD-AO'
storage_system 'ThreePAR-1'
end
# Example: Create a store serv volume from a volume template
oneview_volume 'CHEF_VOL_02' do
client my_client
data(store_serv_properties)
volume_template 'VolumeTemplate_1'
action :create_if_missing
end
# Example: Create a store serv volume with snapshot pool specified
oneview_volume 'CHEF_VOL_03' do
client my_client
data(store_serv_properties)
storage_pool 'CPG-SSD-AO'
snapshot_pool 'CPG-SSD-AO'
storage_system 'ThreePAR-1'
end
# Example: Create a simple store virtual volume
oneview_volume 'CHEF_VIRTUAL_VOL_01' do
client my_client
data(store_virtual_properties)
storage_system 'Cluster-1'
storage_pool 'Cluster-1'
action :create_if_missing
end
# Example: Create a store virtual volume from a volume template
oneview_volume 'CHEF_VIRTUAL_VOL_02' do
client my_client
data(store_virtual_properties)
volume_template 'VolumeTemplateVirtual_1'
action :create_if_missing
end
# Example: Create a snapshot from the volume created by this recipe
oneview_volume 'CHEF_VOL_03' do
client my_client
snapshot_data(
name: 'CHEF_VOL_SNAP_01',
description: 'Volume snapshot'
)
action :create_snapshot
end
# Example: Create a volume from snapshot
oneview_volume 'CHEF_VOL_03' do
client my_client
properties(
name: 'CHEF_VOL_04',
snapshotName: 'CHEF_VOL_SNAP_01',
description: 'Volume store serv',
isShareable: true,
provisioningType: 'Thin',
size: 1024 * 1024 * 1024 # 1GB
)
action :create_from_snapshot
end
# Example: Create a volume from snapshot and a specific volume template
oneview_volume 'CHEF_VOL_03' do
client my_client
properties(
name: 'CHEF_VOL_05',
snapshotName: 'CHEF_VOL_SNAP_01',
description: 'Volume store serv',
isShareable: true,
provisioningType: 'Thin',
size: 1024 * 1024 * 1024 # 1GB
)
volume_template 'VolumeTemplate_1'
action :create_from_snapshot
end
# Example: Delete a volume from appliance only
oneview_volume 'CHEF_VOL_01' do
client my_client
delete_from_appliance_only true
action :delete
end
# Example: Add a volume (created external to OneView) for management by the appliance
oneview_volume 'CHEF_VOL_01' do
client my_client
data(
description: 'Volume added',
isShareable: false
)
storage_system 'ThreePAR-1'
action :add_if_missing
end
# Example: Repair a volume
oneview_volume 'CHEF_VOL_01' do
client my_client
action :repair
end
# Example: Delete a volume snapshot
oneview_volume 'CHEF_VOL_03' do
client my_client
snapshot_data(
name: 'CHEF_VOL_SNAP_01'
)
action :delete_snapshot
end
# Deletes the storeserv volumes from aplliance and storage system:
# Delete action will only need the name and client
(1..5).each do |i|
oneview_volume "CHEF_VOL_0#{i}" do
client my_client
action :delete
end
end
# Deletes the storevirtual volumes from aplliance and storage system:
# Delete action will only need the name and client
(1..2).each do |i|
oneview_volume "CHEF_VIRTUAL_VOL_0#{i}" do
client my_client
action :delete
end
end