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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
➜ robedwa@ROBEDWA-M-800R:~ python:‹system: 2.7.10›
╰ ➤ python
Python 2.7.10 (default, Sep 23 2015, 04:34:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cecs
>>> help(cecs)
Help on package cecs:
NAME
cecs
FILE
/Users/robedwa/Documents/Development/Projects/UCSD/Python/cecs/cecs/__init__.py
DESCRIPTION
Python module of different functions for manipulating UCS Director
via the API.
PACKAGE CONTENTS
command_line
icfDevelopment
menu stuff
obtain_credentials
tests (package)
FUNCTIONS
CreateVDC(env, APIVDCDetails)
Creates a vDC defined by the provided data.
:param: APIVDCDetails
:return: boolean
ExportVDC(env, vdcName)
Exports a vDC.
:param vdcName: Name of the vDC that you want to export
:return: String
GetAllVDCs(env)
Returns all VDCs for the logged-in user group
:param None
:return: APITabularReport
GetCatalog(env, group='all')
Returns the catalogs for the specified user group or all groups.
:param: GroupName
:return: APITabularReport
GetCatalogDetail(env, catalog)
GetCloudSummary(env, icfCloudId)
Returns the details of the Cisco Intercloud Fabric clouds that match the specified cloud identifier.
:param icfCloudId: Cisco Intercloud Fabric cloud identifier.
:return: APITabularReport
GetClouds(env)
Returns a list of all Cisco Intercloud Fabric clouds.
:param: None
:return: APITabularReport
GetIconURL(imageId)
Returns the icon image URL of the specified icon identifier. Only ICF API!
:param: imageId
:return: FormLOVPair[]
GetMgmtPortProfiles(env, vmManager, dataCenter)
Returns a list of all management port profiles for the specified VM Manager and data center.
:param vmManager: VM Manager identifier.
:param dataCenter: Data center identifier.
:return: APITabularReport
GetResIP(env)
Returns a list of all reserved IP addresses.
:param None
:return: APITabularReport
GetStaticIPPool(env)
Returns a list of all static IP address pools.
:param id
:return: APITabularReport
GetStaticIPPoolPolicies(env)
Returns a list of all static IP address pool policies.
:param None
:return: APITabularReport
GetTunnelProfiles(env)
Returns a list of all tunnel profiles.
:param: None
:return: APITabularReport
GetVMvNics(env, vmId)
Returns a list of the vNICs configured on the specified VM.
:param vmId: VM identifier available from the VM report screen.
:return: APITabularReport
GetWorkflowInput(env, name)
GetWorkflowInputDetail(env, name)
GetvCenter(env, vCenterAccountName)
Returns a list of all VMware vCenter servers or of all data centers that match the VMware vCenter account name.
:param: None or vCenterAccountName
:return: APITabularReport
ImportVDC(env, vdcName)
Imports a vDC.
:param vdcName: Name of the vDC that you want to import
:return: VDC
VMNameToID(env, vm_name)
Will return the 'vmid' when the VM Name is passed. Currently on UCSD but will be expanded to ICF
:param api: The specific API call required
:param: VM_Name
:return: vmid
apiCall(env, api, param0=None, param1=None, param2=None, param3=None, param4=None)
Craetes the URL format to make the call to UCS Director or Intercloud Fabric
Rest API. This is a hacked way to achieve overloading
:param env: Specify if the API call should be against UCSD or ICFB
:param api: The specific API call required
:param param0: The initial parameter required to create the request structure
:param param1: The 2nd if required
:param param2: The 3rd if required
:return: JSON response from API call
getAllVMs(env)
group_name(name)
obtain_apikey(env, username, password)
Return the API Key
:param :
:return:
report_tabular(group, report)
#################### Reports ###################################################
Help on package cecs:
NAME
cecs
FILE
/Users/robedwa/Documents/Development/Projects/UCSD/Python/cecs/cecs/__init__.py
DESCRIPTION
Python module of different functions for manipulating UCS Director
via the API.
PACKAGE CONTENTS
command_line
icfDevelopment
menu stuff
obtain_credentials
tests (package)
FUNCTIONS
CreateVDC(env, APIVDCDetails)
Creates a vDC defined by the provided data.
:param: APIVDCDetails
:return: boolean
ExportVDC(env, vdcName)
Exports a vDC.
:param vdcName: Name of the vDC that you want to export
:return: String
GetAllVDCs(env)
Returns all VDCs for the logged-in user group
:param None
:return: APITabularReport
GetCatalog(env, group='all')
Returns the catalogs for the specified user group or all groups.
:param: GroupName
:return: APITabularReport
GetCatalogDetail(env, catalog)
GetCloudSummary(env, icfCloudId)
Returns the details of the Cisco Intercloud Fabric clouds that match the specified cloud identifier.
:param icfCloudId: Cisco Intercloud Fabric cloud identifier.
:return: APITabularReport
GetClouds(env)
Returns a list of all Cisco Intercloud Fabric clouds.
:param: None
:return: APITabularReport
GetIconURL(imageId)
Returns the icon image URL of the specified icon identifier. Only ICF API!
:param: imageId
:return: FormLOVPair[]
GetMgmtPortProfiles(env, vmManager, dataCenter)
Returns a list of all management port profiles for the specified VM Manager and data center.
:param vmManager: VM Manager identifier.
:param dataCenter: Data center identifier.
:return: APITabularReport
GetResIP(env)
Returns a list of all reserved IP addresses.
:param None
:return: APITabularReport
GetStaticIPPool(env)
Returns a list of all static IP address pools.
:param id
:return: APITabularReport
GetStaticIPPoolPolicies(env)
Returns a list of all static IP address pool policies.
:param None
:return: APITabularReport
GetTunnelProfiles(env)
Returns a list of all tunnel profiles.
:param: None
:return: APITabularReport
GetVMvNics(env, vmId)
Returns a list of the vNICs configured on the specified VM.
:param vmId: VM identifier available from the VM report screen.
:return: APITabularReport
GetWorkflowInput(env, name)
GetWorkflowInputDetail(env, name)
GetvCenter(env, vCenterAccountName)
Returns a list of all VMware vCenter servers or of all data centers that match the VMware vCenter account name.
:param: None or vCenterAccountName
:return: APITabularReport
ImportVDC(env, vdcName)
Imports a vDC.
:param vdcName: Name of the vDC that you want to import
:return: VDC
VMNameToID(env, vm_name)
Will return the 'vmid' when the VM Name is passed. Currently on UCSD but will be expanded to ICF
:param api: The specific API call required
:param: VM_Name
:return: vmid
apiCall(env, api, param0=None, param1=None, param2=None, param3=None, param4=None)
Craetes the URL format to make the call to UCS Director or Intercloud Fabric
Rest API. This is a hacked way to achieve overloading
:param env: Specify if the API call should be against UCSD or ICFB
:param api: The specific API call required
:param param0: The initial parameter required to create the request structure
:param param1: The 2nd if required
:param param2: The 3rd if required
:return: JSON response from API call
getAllVMs(env)
group_name(name)
obtain_apikey(env, username, password)
Return the API Key
:param :
:return:
report_tabular(group, report)
#################### Reports ###################################################
sr_details(srnumber)
Return the details of the Service Request Specified - Workflow Based Only
:param srnumber: The Service Request ID
:return: JSON of the SR Status
sr_get(env)
Return the service request for the logged in user (Both UCSD & ICFB)
:return: APITabularReport (JSON)
sr_log(srnumber, severity)
Return the logs from the specified Service Request
:param srnumber: The Service Request ID
:param severity: Log severity (debug, info, warning, error)
:return: JSON of the logs
ucsdCall(api, param0=None, param1=None, param2=None, param3=None, param4=None)
NOTE: This is deprecated and will be removed once all functions have been migrated!
Craetes the URL format to make the call to UCS Director Rest API.
This is a hacked version of overloading (not sure how else to achieve)
:param api: The specific API call required
:param param0: The initial parameter required to create the request structure
:return: JSON response (in Python dictionary) from API call
version(env)
Return the version of the application
:param env: The server that requires querying (ucsd or icfb)
:return: FQDN: <version number>
vm_action(env, vm_name, action, comment)
This will alter the status (on, off etc.) of a VM. It has to work out the
vmid based on the VM name that is passed.
DATA
Version = '0.1.12'
__version__ = '0.1.12'
config = ConfigObj({'UCSD': {'apikey': 'B01BB65B70EB481C9...A98033922'...
filename = '/Users/robedwa/.cecs.cfg'
getstring = 'formatType=json&opName=%s'
headers = {'X-Cloupia-Request-Key': ' '}
home = '/Users/robedwa'
icfb_key = '6B75494C86E041CDA4AA390A98033922'
icfb_section = {'apikey': '6B75494C86E041CDA4AA390A98033922', 'hostnam...
icfbserver = 'sandboxicf.cisco.com'
parameter_lead = '&opData='
ucsd_key = 'B01BB65B70EB481C9D8184055FD59B58'
ucsd_section = {'apikey': 'B01BB65B70EB481C9D8184055FD59B58', 'hostnam...
ucsdserver = 'infrastructure.ukidcv.cisco.com'
url = 'https://%s/app/api/rest?'
VERSION
0.1.12
|