Hello Everyone,
Does someone know the powershell command equivalent for the "Show Policy usage" in the Cisco UCS GUI?
I didn't find any hint in several whitepapers nor on internet search engines.
Thank you!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hi Johannes,
There is no direct cmdlet available in UCS Manager PowerTool to get the Policy usage. However you can fetch that information by writing a script using the UCS Manager PowerTool libraries.
Here are the steps that needs to be performed to get the policy usage.
1. Connect to the UCS Manager using the Connect-Ucs cmdlet and save the Session handle in an object.
$handle = Connect-Ucs <UCS Manager Name>
2. Fetch the policy object for which you need the policy usage. For ex for Host Firmware Packages you can use the below snippet. You can save the output to a object.
$fwPolicy = Get-UcsFirmwareComputeHostPack -Name "default"
3. You need to invoke a method in the UCS Manager PowerTool Library and save the output to an object.
Method Name: ConfigFindDependencies
Parameters: Valid Session Handle, DN of the Policy to be queried, in return config (true or false)
$policyUsage = [Cisco.Ucsm.MethodFactory]::ConfigFindDependencies($handle,$fwPolicy.Dn,"true")
4. $policyUsage.OutConfigs.GetChild() will have details of the Policy usage.
AgentPolicyName :
AssignState : assigned
AssocState : associated
BiosProfileName :
BootPolicyName :
ConfigQualifier : {}
ConfigState : applied
Descr :
DynamicConPolicyName :
ExtIPPoolName :
ExtIPState : static
HostFwPolicyName :
IdentPoolName :
KvmMgmtPolicyName :
LocalDiskPolicyName :
MaintPolicyName :
MgmtAccessPolicyName :
MgmtFwPolicyName :
Name : XXXXXXXX
OperBiosProfileName :
OperBootPolicyName : org-root/boot-policy-default
OperDynamicConPolicyName :
OperExtIPPoolName :
OperHostFwPolicyName : org-root/fw-host-pack-default
OperIdentPoolName :
OperKvmMgmtPolicyName : org-root/kvm-mgmt-policy-default
OperLocalDiskPolicyName : org-root/local-disk-config-default
OperMaintPolicyName : org-root/maint-default
OperMgmtAccessPolicyName :
OperMgmtFwPolicyName :
OperPowerPolicyName : org-root/power-policy-default
OperScrubPolicyName : org-root/scrub-default
OperSolPolicyName :
OperSrcTemplName :
OperState : ok
OperStatsPolicyName : org-root/thr-policy-default
OperVconProfileName :
OperVmediaPolicyName :
Owner : management
PnDn : sys/chassis-1/blade-3
PolicyLevel : 0
PolicyOwner : local
PowerPolicyName : default
PropAcl : 0
ResolveRemote : yes
Sacl :
ScrubPolicyName :
SolPolicyName :
SrcTemplName :
StatsPolicyName : default
SvnicConfig : yes
Type : instance
UsrLbl :
Uuid : derived
UuidSuffix : 0000-000000000000
VconProfileName :
VmediaPolicyName :
Ucs : XXXXXXX
Dn : XXXXXXX
Rn : XXXXXXX
Status :
XtraProperty : {}
You can use step 3 for getting policy usage for any policy type you want.
Let me know if you need further help on this.
Thanks,
Sumanth
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Great! Thank you!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hi Suman,
Could you help me with the python version of this function.
below code isnt working for me.
from ucsmsdk.ucsmethodfactory import config_find_dependencies
me = config_find_dependencies(handle,check,"true")
print me.out_configs.get_child()
Regards,
VM
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hi VM,
Pleas find the snippet below:
from ucsmsdk.ucsmethodfactory import config_find_dependencies
from ucsmsdk.ucshandle import UcsHandle
handle = UcsHandle("ip", "username", "password")
handle.login()
elem = config_find_dependencies(cookie=handle.cookie, dn="org-root/fw-host-pack-default", in_return_configs="true")
response = handle.post_elem(elem)
mos = response.out_configs.child
for mo in mos:
print mo
handle.logout()
Hope this helps.
Thanks
Rahul
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HI Rahul,
Yes it certianly helped .. Thank you for your response.
Regards,
VM
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comments
0 comments
Please sign in to leave a comment.