-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathmanaged_sans.py
More file actions
124 lines (107 loc) · 4.33 KB
/
Copy pathmanaged_sans.py
File metadata and controls
124 lines (107 loc) · 4.33 KB
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
# -*- coding: utf-8 -*-
###
# (C) Copyright [2019] 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.
###
from pprint import pprint
from hpeOneView.oneview_client import OneViewClient
from config_loader import try_load_from_file
config = {
"ip": "<oneview_ip>",
"credentials": {
"userName": "<username>",
"password": "<password>"
}
}
# Try load config from a file (if there is a config file)
config = try_load_from_file(config)
oneview_client = OneViewClient(config)
managed_sans = oneview_client.managed_sans
imported_san = None
internally_managed_san = None
# You must set the value of the WWN to run the API 300 example
wwn = None
# Get all, with defaults
print("\nGet all Managed SANs")
managed_sans_all = managed_sans.get_all()
if managed_sans_all:
for managed_san in managed_sans_all:
print(' Name: {name} - Manager: {deviceManagerName} - Imported: {imported}'.format(**managed_san))
if managed_san['imported']:
imported_san = managed_sans.get_by_uri(managed_san["uri"])
else:
internally_managed_san = managed_sans.get_by_uri(managed_san["uri"])
# Get a Managed SAN by name
print("\nGet a Managed SAN by name")
managed_san_by_name = managed_sans.get_by_name(managed_san['name'])
pprint(managed_san_by_name.data)
# Get a Managed SAN by URI
print("\nGet a Managed SAN by URI")
managed_san_by_uri = managed_sans.get_by_uri(managed_san['uri'])
pprint(managed_san_by_uri.data)
if internally_managed_san:
# Update the Managed SAN's publicAttributes
print("\nUpdate the Internally Managed SAN's publicAttributes")
public_attributes = {
"publicAttributes": [{
"name": "MetaSan",
"value": "Neon SAN",
"valueType": "String",
"valueFormat": "None"
}]
}
internally_managed_san.update(public_attributes)
pprint(internally_managed_san.data)
# Update the Managed SAN's policy
print("\nUpdate the Internally Managed SAN's policy")
policy = {
"sanPolicy": {
"zoningPolicy": "SingleInitiatorAllTargets",
"zoneNameFormat": "{hostName}_{initiatorWwn}",
"enableAliasing": True,
"initiatorNameFormat": "{hostName}_{initiatorWwn}",
"targetNameFormat": "{storageSystemName}_{targetName}",
"targetGroupNameFormat": "{storageSystemName}_{targetGroupName}"
}
}
internally_managed_san.update(policy)
pprint(internally_managed_san.data)
if imported_san:
# Refresh the Managed SAN
print("\nRefresh the Imported Managed SAN")
refresh_config = {
"refreshState": "RefreshPending"
}
imported_san.update(refresh_config)
pprint(imported_san.data)
# Create a SAN endpoints CSV file
print("\nCreate a SAN endpoints CSV file")
csv_file_response = imported_san.create_endpoints_csv_file()
pprint(csv_file_response)
# Retrieve the endpoints for a SAN
print("\nGet the list of endpoints in the Imported Managed SAN")
endpoints = imported_san.get_endpoints()
pprint(endpoints)
# Create an unexpected zoning report
print("\nCreate an unexpected zoning report")
issues_response = imported_san.create_issues_report()
pprint(issues_response)
else:
print("\nNo Managed SANs found.")
# This method is available for API version 300
if oneview_client.api_version == 300 and wwn is not None:
# Retrieves an association between the provided WWN and the SAN (if any) on which it resides
print("\nGet a list of associations between provided WWNs and the SANs on which they reside")
wwns = managed_sans.get_wwn(wwn)
pprint(wwns)