CiscoDevNet / intersight-powershell

Cisco Intersight PowerShell
Apache License 2.0
16 stars 4 forks source link

Set-IntersightServerProfile no longer allows Activate #141

Closed chadmorrison7 closed 3 months ago

chadmorrison7 commented 8 months ago

Used to be able to use Set-IntersightServerProfile to activate a server profile but according the documentation the Activate Action is no longer valid for Server Profiles with only Deploy and Unassign as valid options. The Activate action worked as of 3/14/2024.

This is the code that used to work and running this same process with the Action of Deploy $name = "systemname" $serverprofile = Get-IntersightServerProfile -Name $name $serverprofile | Set-IntersightServerProfile -Action Activate

Version used

Expected behavior This used to starting the Activation of the Server Profile which can still be done if you go to the Server Profile in the Intersight GUI, but it gets this error currently.... Set-IntersightServerProfile: Error calling UpdateServerProfile: {"code":"InvalidRequest","message":"Action 'Activate' is not allowed in current state","messageId":"gershwin_user_action_is_not_allowed","messageParams":{"1":"Activate"}

Screenshots image

How are you all activating Server Profiles for automation outside of using the GUI?

vvb commented 8 months ago

The "Activate" action is supported. The text in the screenshot seems to be lacking some Actions and this would need to be a documentation fix from our end. The error you have received while activating suggests that Activate wasn't allowed in the state the Profile was. I need to check the states in which Activate action would fail, but I am guessing one state it will fail is if the SP deployment workflow hasn't completed. This would be the same irrespective of if this is triggered using PowerShell or GUI.

Can you hack on this a bit more and come back with more details.

chadmorrison7 commented 8 months ago

Thanks. I am running it again. The state of the Server Profile in the GUI shows Inconsistent due to not being Activated. I am able to go to the GUI at that point and Select Activate with no issues, but if I use the Set-IntersightServerProfile -Actions Activate at that same point or even give it another 5 to 10 minutes, I get the error every time. Even running the Get-IntersightServerProfile right before to make sure it has the refresh of the Server Profile status does not work. I even upgraded to the latest version of the Powershell modules - 1.0.11.15473 image image

Update: Also the Server Profile activates if I use the Rest Client on the Intersight website to Activate. image

vvb commented 8 months ago

Maybe you could use the -Json argument to log the request and response that PowerShell is sending. This will make it clear if PowerShell is doing something more than what you are doing in apidocs.

chadmorrison7 commented 8 months ago

Here is what the -Json added... C:\Users\user> $serverprofile | Set-IntersightServerProfile -Action Activate -Json { "ServerAssignmentMode": "Static", "ServerPreAssignBySlot": { "ClassId": "server.ServerAssignTypeSlot", "ObjectType": "server.ServerAssignTypeSlot", "ChassisId": 0, "DomainName": "", "SlotId": 0 }, "AssignedServer": {"ClassId":"mo.MoRef","ObjectType":"compute.Blade","Moid":"658decb26176753601007a53","link":"https://www.intersight.com/api/v1/compute/Blades/658decb26176753601007a53"}, "Organization": {"ClassId":"mo.MoRef","ObjectType":"organization.Organization","Moid":"5ddeede46972652d3103474c","link":"https://www.intersight.com/api/v1/organization/Organizations/5ddeede46972652d3103474c"}, "TargetPlatform": "FIAttached", "UuidAddressType": "NONE", "Action": "Activate", "ConfigContext": { "ClassId": "policy.ConfigContext", "ObjectType": "policy.ConfigContext", "ControlAction": "No-op", "ErrorState": "", "InconsistencyReason": [ "Not-activated" ] }, "PolicyBucket": [ {"ClassId":"mo.MoRef","ObjectType":"bios.Policy","Moid":"63efa48b6275722d30ad9e3a","link":"https://www.intersight.com/api/v1/bios/Policies/63efa48b6275722d30ad9e3a"}, {"ClassId":"mo.MoRef","ObjectType":"boot.PrecisionPolicy","Moid":"6580cc3d6275723001832c7a","link":"https://www.intersight.com/api/v1/boot/PrecisionPolicies/6580cc3d6275723001832c7a"}, {"ClassId":"mo.MoRef","ObjectType":"power.Policy","Moid":"6435c2796275723001d03633","link":"https://www.intersight.com/api/v1/power/Policies/6435c2796275723001d03633"}, {"ClassId":"mo.MoRef","ObjectType":"thermal.Policy","Moid":"64909b0b6275723001cdea97","link":"https://www.intersight.com/api/v1/thermal/Policies/64909b0b6275723001cdea97"}, {"ClassId":"mo.MoRef","ObjectType":"vmedia.Policy","Moid":"6436dbc7627572300111a1e1","link":"https://www.intersight.com/api/v1/vmedia/Policies/6436dbc7627572300111a1e1"}, {"ClassId":"mo.MoRef","ObjectType":"access.Policy","Moid":"6435c2bc6275723001d04858","link":"https://www.intersight.com/api/v1/access/Policies/6435c2bc6275723001d04858"}, {"ClassId":"mo.MoRef","ObjectType":"iam.EndPointUserPolicy","Moid":"6436dc63627572300111c06a","link":"https://www.intersight.com/api/v1/iam/EndPointUserPolicies/6436dc63627572300111c06a"}, {"ClassId":"mo.MoRef","ObjectType":"snmp.Policy","Moid":"64358cfe6275723001c250a9","link":"https://www.intersight.com/api/v1/snmp/Policies/64358cfe6275723001c250a9"}, {"ClassId":"mo.MoRef","ObjectType":"syslog.Policy","Moid":"64358c386275723001c21c9a","link":"https://www.intersight.com/api/v1/syslog/Policies/64358c386275723001c21c9a"}, {"ClassId":"mo.MoRef","ObjectType":"kvm.Policy","Moid":"6436c67e62757230010c3db4","link":"https://www.intersight.com/api/v1/kvm/Policies/6436c67e62757230010c3db4"}, {"ClassId":"mo.MoRef","ObjectType":"vnic.SanConnectivityPolicy","Moid":"6435b840f746dd89019c01bb","link":"https://www.intersight.com/api/v1/vnic/SanConnectivityPolicies/6435b840f746dd89019c01bb"}, {"ClassId":"mo.MoRef","ObjectType":"vnic.LanConnectivityPolicy","Moid":"65f319e1c04e31eb0152bade","link":"https://www.intersight.com/api/v1/vnic/LanConnectivityPolicies/65f319e1c04e31eb0152bade"} ], "Type": "instance", "Name": "servername", "SrcTemplate": {"ClassId":"mo.MoRef","ObjectType":"server.ProfileTemplate","Moid":"658b03d677696e3101fe2ea4","link":"https://www.intersight.com/api/v1/server/ProfileTemplates/658b03d677696e3101fe2ea4"}, "Moid": "65f9b07977696e31015a9ddf" } Set-IntersightServerProfile: Error calling UpdateServerProfile: {"code":"InvalidRequest","message":"Action 'Activate' is not allowed in current state","messageId":"gershwin_user_action_is_not_allowed","messageParams":{"1":"Activate"},"traceId":"l37RfdlRFKlVIZw-ogrUhW_9_RX0yH0ztcoAjqy40dCoNBjhPEdCUw=="}

Ghufz commented 8 months ago

Can you try this, it seems some extra property is being set when we pipe the get output, please try with Moid and Action parameter

Set-IntersightServerProfile -Moid $serverprofile.Moid -Action Activate
chadmorrison7 commented 8 months ago

@Ghufz - That seems to work! Thanks! Not sure why the other method no longer works just for Activate as it still works with Unassign and Deploy.

Ghufz commented 8 months ago

Other method of cmdlet invocation sets some other properties as part of piped object which causes the issue. I am analyzing the issue.

Ghufz commented 3 months ago

This issue has been fixed in Intersight.PowerShell version https://www.powershellgallery.com/packages/Intersight.PowerShell/1.0.11.17769