-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathserver_profile.rb
171 lines (155 loc) · 4.77 KB
/
server_profile.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
# (c) Copyright 2021 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.
# NOTES:
# This example requires the following resources to be available in the appliance:
# - FC Network: 'FCNetwork1'
# - FCoE Network: 'FCoENetwork1'
# - Ethernet Network: 'EthernetNetwork1'
# - Server Profile Template: 'ServerProfileTemplate1'
# - Server Hardware Type: 'SY 480 Gen9 1'
# - Server Hardware: 'Encl1, bay 2'
# - Enclosure Group: 'EnclosureGroup1'
my_client = {
url: ENV['ONEVIEWSDK_URL'],
user: ENV['ONEVIEWSDK_USER'],
password: ENV['ONEVIEWSDK_PASSWORD'],
api_version: 3000
}
my_server_hardware_type = 'SY 480 Gen9 1'
my_enclosure_group = 'EG'
server_hardware_name = '0000A66101, bay 5'
# Creates a server profile with the desired Enclosure group and Server hardware type
oneview_server_profile 'ServerProfile1' do
client my_client
enclosure_group my_enclosure_group
server_hardware_type my_server_hardware_type
end
oneview_server_hardware server_hardware_name do
client my_client
power_state 'off'
action :set_power_state
end
# Creates a server profile using a template
# Note that when creating a profile using a template, anything passed into the data property will override
# the template defaults. This may cause the profile to be in an "inconsistent with template" state. Since
# you're using a template, you probably don't want to put much in the data property (if anything); instead,
# update the template.
oneview_server_profile 'ServerProfile2' do
client my_client
data(
description: 'Override Description',
boot: {
order: [],
manageBoot: true
}
)
server_profile_template 'SPT-Test'
server_hardware server_hardware_name
end
# If a profile does get in an inconsistent state, you can update it from it's template. Note that this action
# only works on profiles that already exist. It also does not consider any properties beside the name; it
# purely finds it by name and ensures it is consistent with the template. If the update requires the server to
# go offline, it should fail; you'll need to explicitly power off the server, then try the update again.
oneview_server_profile 'update ServerProfile2 from template' do
client my_client
data(name: 'ServerProfile2')
action :update_from_template
end
# Creates a server profile with the desired Enclosure group and Server hardware type and some connections
oneview_server_profile 'ServerProfile3' do
client my_client
enclosure_group my_enclosure_group
server_hardware_type my_server_hardware_type
data(
macType: 'Virtual',
wwnType: 'Virtual'
)
ethernet_network_connections(
mgmt_untagged: {
name: 'Connection1'
}
)
fc_network_connections(
FC_FA: {
name: 'Connection2',
functionType: 'FibreChannel',
portId: 'Auto'
}
)
fcoe_network_connections(
FcoeTest1: {
name: 'c1',
functionType: 'FibreChannel',
portId: 'None'
}
)
action :create_if_missing
end
# Creates or updates ServerProfile3 with multiple boot connections in the same network
oneview_server_profile 'ServerProfile3' do
client my_client
enclosure_group my_enclosure_group
server_hardware_type my_server_hardware_type
data(
bootMode: {
manageMode: true,
mode: 'BIOS'
},
boot: {
manageBoot: true
}
)
ethernet_network_connections [
{
iscsi_nw: {
name: 'PrimaryBoot',
boot: {
priority: "Primary"
}
}
},
{
iscsi_nw: {
name: 'SecondaryBoot',
boot: {
priority: "Secondary"
}
}
}
]
action :create
end
# Creates on server profile template with the desired Enclosure group and Server hardware type
oneview_server_profile 'ServerProfile4' do
client my_client
enclosure_group my_enclosure_group
server_hardware_type my_server_hardware_type
end
# Clean up the profiles:
oneview_server_profile 'Delete ServerProfile1' do
client my_client
data(name: 'ServerProfile1')
action :delete
end
oneview_server_profile 'Delete ServerProfile2' do
client my_client
data(name: 'ServerProfile2')
action :delete
end
oneview_server_profile 'Delete ServerProfile3' do
client my_client
data(name: 'ServerProfile3')
action :delete
end
oneview_server_profile 'ServerProfile4' do
client my_client
action :delete
end