-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathoneview_ethernet_network.yml
168 lines (156 loc) · 5.46 KB
/
oneview_ethernet_network.yml
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
###
# Copyright (2016-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.
###
---
- hosts: all
vars:
config: "{{ playbook_dir }}/oneview_config.json"
contents: "{{lookup('file', config)}}"
network_name: 'OneViewSDK Test Ethernet Network'
network_scope_uris:
- '/rest/scopes/63d1ca81-95b3-41f1-a1ee-f9e1bc2d635f'
- '/rest/scopes/96661df3-fb4f-4617-a1fb-d6f11adf18d3'
tasks:
- name: Get currentVersion from URL
oneview_version_facts:
config: "{{ config }}"
delegate_to: localhost
when: contents.api_version|length == 0
register: version
- name: Print currentVersion if an apiVersion is not specified in config file
set_fact:
currentVersion: "{{ version.ansible_facts.version.currentVersion | int }}"
when: contents.api_version|length == 0
- name: Print currentVersion if api version is specified in config file
set_fact:
currentVersion: contents.api_version | string
when: contents.api_version|length != 0
- name: Create an Ethernet Network
oneview_ethernet_network:
config: "{{ config }}"
state: present
data:
name: '{{ item.name }}'
vlanId: '{{ item.vlanId }}'
ethernetNetworkType: Tagged
purpose: General
smartLink: false
privateNetwork: false
bandwidth:
maximumBandwidth: 2000
typicalBandwidth: 1000
delegate_to: localhost
with_items:
- { name: '{{ network_name }}', vlanId: '201' }
- { name: 'ovsdk_mgmt_nw', vlanId: '202'}
- name: Update the Ethernet Network changing bandwidth and purpose
oneview_ethernet_network:
config: "{{ config }}"
state: present
data:
name: '{{ network_name }}'
purpose: Management
bandwidth:
maximumBandwidth: 3000
typicalBandwidth: 2000
delegate_to: localhost
- name: Reset to the default network connection template
oneview_ethernet_network:
config: "{{ config }}"
state: default_bandwidth_reset
data:
name: '{{ network_name }}'
delegate_to: localhost
- name: Ensure ethernet network has no scopes
oneview_ethernet_network:
config: "{{ config }}"
state: present
data:
name: "{{ network_name }}"
scopeUris: []
when: currentVersion >= '300' and currentVersion <= '500'
delegate_to: localhost
- name: Ensure Ethernet Network has two scopes
oneview_ethernet_network:
config: "{{ config }}"
state: present
data:
name: "{{ network_name }}"
scopeUris: "{{ network_scope_uris }}"
when: currentVersion >= '300' and currentVersion <= '500'
delegate_to: localhost
- name: Rename the Ethernet Network to 'Updated Ethernet Network'
oneview_ethernet_network:
config: "{{ config }}"
state: present
data:
name: '{{ network_name }}'
newName: 'Updated Ethernet Network'
delegate_to: localhost
- name: Delete the Ethernet Network
oneview_ethernet_network:
config: "{{ config }}"
state: absent
data:
name: 'Updated Ethernet Network'
delegate_to: localhost
register: deleted
- name: Create Ethernet Networks in bulk
oneview_ethernet_network:
config: "{{ config }}"
state: present
data:
vlanIdRange: '1-3,5,7'
purpose: General
namePrefix: TestNetwork
smartLink: false
privateNetwork: false
bandwidth:
maximumBandwidth: 10000
typicalBandwidth: 2000
delegate_to: localhost
register: bulk_ethernet_create
- debug: msg='{{ethernet_network_bulk | map(attribute='name') | list }}'
- debug: msg='{{ ethernet_network_bulk }}'
- name: Delete Ethernet Networks in bulk
oneview_ethernet_network:
config: "{{ config }}"
state: absent
data:
networkUris:
- "{{ ethernet_network_bulk[0].uri }}"
- "{{ ethernet_network_bulk[1].uri }}"
- "{{ ethernet_network_bulk[2].uri }}"
- "{{ ethernet_network_bulk[3].uri }}"
- "{{ ethernet_network_bulk[4].uri }}"
delegate_to: localhost
when: currentVersion >= '1600'
- name: Create Ethernet Networks in bulk for automation
oneview_ethernet_network:
config: "{{ config }}"
state: present
data:
vlanIdRange: '1-3,5,7'
purpose: General
namePrefix: TestNetwork
smartLink: false
privateNetwork: false
bandwidth:
maximumBandwidth: 10000
typicalBandwidth: 2000
delegate_to: localhost
register: bulk_ethernet_create
- debug: msg='{{ethernet_network_bulk | map(attribute='name') | list }}'
- debug: msg='{{ ethernet_network_bulk }}'