-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathoneview_logical_switch.yml
99 lines (93 loc) · 3.77 KB
/
oneview_logical_switch.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
###
# Copyright (2016-2017) 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.
###
---
# This resource is only available on C7000 enclosures
- hosts: all
vars:
config: '{{ playbook_dir }}/oneview_config.json'
# The following variables must be set to run this example.
logical_switch_group_name: '<lsg_name>' # Logical Switch Group which the logical switch is derived from
ip_address_switch_1: '<lsg1_ip>' # IP address/hostname of Switch 1
ip_address_switch_2: '<lsg2_ip>' # IP address/hostname of Switch 2
ssh_username: '<lsg1&2_user_name>' # SSH Username
ssh_password: '<lsg1&2_password>' # SSH Password
scopes:
- '/rest/scopes/d1f79dea-6393-4bb0-9723-8adc9b96de94'
credential_configuration:
connectionProperties:
- propertyName: 'SshBasicAuthCredentialUser'
value: '{{ ssh_username }}'
valueFormat: 'Unknown'
valueType: 'String'
- propertyName: 'SshBasicAuthCredentialPassword'
value: '{{ ssh_password }}'
valueFormat: 'SecuritySensitive'
valueType: 'String'
tasks:
- name: Create a Logical Switch
oneview_logical_switch:
config: "{{ config }}"
state: present
data:
logicalSwitch:
name: 'Test Logical Switch'
# You can choose set the Logical Switch Group by logicalSwitchGroupName or logicalSwitchGroupUri
logicalSwitchGroupName: '{{ logical_switch_group_name }}' # option 1
# logicalSwitchGroupUri: '/rest/logical-switch-groups/dce11b79-6fce-48af-84fb-a315b9644571' # option 2
switchCredentialConfiguration:
- snmpV1Configuration:
communityString: 'public'
logicalSwitchManagementHost: '{{ ip_address_switch_1 }}'
snmpVersion: 'SNMPv1'
snmpPort: 161
- snmpV1Configuration:
communityString: 'public'
logicalSwitchManagementHost: '{{ ip_address_switch_2 }}'
snmpVersion: 'SNMPv1'
snmpPort: 161
logicalSwitchCredentials:
- '{{ credential_configuration }}'
- '{{ credential_configuration }}'
delegate_to: localhost
- name: Update the Logical Switch name, scopes and credentials
oneview_logical_switch:
config: "{{ config }}"
state: updated
data:
logicalSwitch:
name: 'Test Logical Switch'
newName: 'Test Logical Switch - Renamed'
logicalSwitchCredentials:
- '{{ credential_configuration }}'
- '{{ credential_configuration }}'
scopeUris: "{{ scopes }}" # This feature is available only till OneView 3.10
delegate_to: localhost
- name: Reclaim the top-of-rack switches in the logical switch
oneview_logical_switch:
config: "{{ config }}"
state: refreshed
data:
logicalSwitch:
name: 'Test Logical Switch - Renamed'
delegate_to: localhost
- name: Delete the Logical Switch
oneview_logical_switch:
config: "{{ config }}"
state: absent
data:
logicalSwitch:
name: 'Test Logical Switch - Renamed'
delegate_to: localhost