Skip to content

Commit d987be7

Browse files
committed
Added some additional policy methods
1 parent e43df8d commit d987be7

File tree

2 files changed

+123
-6
lines changed

2 files changed

+123
-6
lines changed

functions/newfunctions_ucs.py

Lines changed: 106 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ def createWwpnPool(self, fabric, blockstart, blockend):
255255
def removeWwpnPool(self, mo):
256256
pass
257257

258-
##############
259-
# POLICIES #
260-
##############
258+
#####################
259+
# GLOBAL POLICIES #
260+
#####################
261261

262262
def setPowerPolicy(self, redundancy):
263263
try:
@@ -286,6 +286,10 @@ def setChassisDiscoveryPolicy(self, links):
286286
except UcsException:
287287
print "Error setting Chassis Discovery policy"
288288

289+
##################
290+
# QOS POLICIES #
291+
##################
292+
289293
def setGlobalQosPolicy(self, qosconfig):
290294
try:
291295

@@ -395,3 +399,102 @@ def createQosPolicy(self, classname, hostcontrol):
395399
}, True)
396400
except UcsException:
397401
print "QoS Policy already exists"
402+
403+
###########################
404+
# ORG-SPECIFIC POLICIES #
405+
###########################
406+
407+
def getLocalDiskPolicy(self, name):
408+
pass
409+
410+
def createLocalDiskPolicy(self, name, mode):
411+
try:
412+
self.handle.AddManagedObject(self.org, "storageLocalDiskConfigPolicy",
413+
{
414+
"Name":name,
415+
"Descr":name,
416+
"PolicyOwner":"local",
417+
"ProtectConfig":"yes",
418+
"Dn":self.orgNameDN + "local-disk-config-" + name,
419+
"Mode":mode,
420+
"FlexFlashState":"disable",
421+
"FlexFlashRAIDReportingState":"disable"
422+
})
423+
except UcsException:
424+
print "Local Disk Configuration Policy already exists"
425+
426+
def removeLocalDiskPolicy(self, name):
427+
pass
428+
429+
def getHostFWPackage(self, name):
430+
pass
431+
432+
def createHostFWPackage(self, name):
433+
try:
434+
self.handle.AddManagedObject(self.org, "firmwareComputeHostPack",
435+
{
436+
"Name":name,
437+
"BladeBundleVersion":"",
438+
"RackBundleVersion":"",
439+
"PolicyOwner":"local",
440+
"Dn":self.orgNameDN + "fw-host-pack-" + name,
441+
"Mode":"staged",
442+
"IgnoreCompCheck":"yes",
443+
"StageSize":"0",
444+
"Descr":"Host Firmware Package",
445+
"UpdateTrigger":"immediate"
446+
})
447+
except UcsException:
448+
print "Host Firmware Package already exists"
449+
450+
def removeHostFWPackage(self, name):
451+
pass
452+
453+
def getMaintPolicy(self, name):
454+
pass
455+
456+
def createMaintPolicy(self, name, policy):
457+
try:
458+
self.handle.AddManagedObject(self.org, "lsmaintMaintPolicy",
459+
{
460+
"Descr":name,
461+
"SchedName":"",
462+
"Name":name,
463+
"Dn":self.orgNameDN + "maint-" + name,
464+
"PolicyOwner":"local",
465+
"UptimeDisr":policy
466+
})
467+
except UcsException:
468+
print "Maintenance Policy already exists"
469+
470+
def removeMaintPolicy(self, name):
471+
pass
472+
473+
def createNetControlPolicy(self, name):
474+
try:
475+
mo = self.handle.AddManagedObject(self.org, "nwctrlDefinition",
476+
{
477+
"Name":name,
478+
"Cdp":"enabled",
479+
"Dn":self.orgNameDN + "nwctrl-" + name,
480+
"PolicyOwner":"local",
481+
"MacRegisterMode":"only-native-vlan",
482+
"UplinkFailAction":"link-down",
483+
"Descr":name
484+
})
485+
mo_1 = self.handle.AddManagedObject(mo, "dpsecMac",
486+
{
487+
"Name":"",
488+
"Dn":self.orgNameDN + "nwctrl-" + name + "/mac-sec",
489+
"Forge":"allow",
490+
"PolicyOwner":"local",
491+
"Descr":""
492+
}, True)
493+
except UcsException:
494+
print "Network Control Policy already exists"
495+
496+
#TODO: Tabling this for now. This is a complicated thing to do.
497+
def createBootPolicy(name):
498+
pass
499+
500+

workers/ucs.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/usr/bin/env python
22
""" UCS worker class for pyflex
33
4+
In the future, this will really be the core renderer. All of the
5+
work of deleting config that shouldn't be there, or creating it
6+
when it should, will be handled here.
7+
48
"""
59
from worker import FlexWorker
610
#from functions.functions_ucs import UcsFunctions
@@ -92,11 +96,21 @@ def startworker(self):
9296
for fabric in wwpnpools: #TODO: This loop is here for the future, but obviously since the name is statically set, this only works with a single pool per fabric, currently.
9397
newfxns.createWwpnPool(fabric, wwpnpools[fabric]['blockbegin'], wwpnpools[fabric]['blockend'])
9498

95-
99+
""" GLOBAL POLICIES """
96100

97101
newfxns.setPowerPolicy("grid")
98102
newfxns.setChassisDiscoveryPolicy(str(self.config['ucs']['links']))
99-
newfxns.setGlobalQosPolicy(self.config['qos'])
100103

104+
""" QOS """
105+
106+
newfxns.setGlobalQosPolicy(self.config['qos'])
101107
for classname, hostcontrol in self.config['qos']['classes'].iteritems():
102-
newfxns.createQosPolicy(classname, hostcontrol)
108+
newfxns.createQosPolicy(classname, hostcontrol)
109+
110+
""" ORG-SPECIFIC POLICIES """
111+
112+
newfxns.createLocalDiskPolicy("NO_LOCAL", "no-local-storage")
113+
newfxns.createLocalDiskPolicy("RAID1", "raid-mirrored")
114+
newfxns.createHostFWPackage("HOST_FW_PKG")
115+
newfxns.createMaintPolicy("MAINT_USERACK", "user-ack")
116+
newfxns.createNetControlPolicy("NTKCTRL-CDP")

0 commit comments

Comments
 (0)