cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

Create backup configuration using Invoke-XML (and a quick-tip)

87
Views
0
Helpful
0
Comments
Advisor
This document was generated from CDN thread

Created by: Jan Egil Ring on 27-09-2011 04:19:08 AM
Hi,
First a quick tip regarding strings in PowerShell. To make scripts easier to read, we can put the XML-string to send to Invoke-XmlCommand in a here-string:
$ip = "10.10.10.10"
$xml = @"
<configConfMo inHierarchical='false'>
<inConfig>
<aaaProviderGroup dn='sys/ldap-ext/providergroup-contoso.local' name='contoso.local'><aaaProviderRef name="$IP" /></aaaProviderGroup>
</inConfig>
</configConfMo>
"@
Invoke-XmlCommand -XMLStringList $xml
On to the question, I`m trying to create a backup configuration using Invoke-XmlCommand:
$xml = @"
<configConfMo inHierarchical='false'>
<inConfig>
<mgmtBackup hostname = '10.10.10.10' adminState = 'enabled' childAction = 'deleteNonPresent' descr = '' name = 'Scheduled' postAction = 'remove' preservePooledValues = 'no' proto = 'ftp' pwd = 'password' remoteFile = '/Cisco UCS/system-backup.bak' type = 'config-all' user = 'ucs.backup'></mgmtBackup>
</inConfig>
</configConfMo>
"@
Invoke-XmlCommand -XMLStringList $xml
The command doesn`t return any data, and the backup configuration isn`t created. I guess the parameters I`m passing is incorrect, how can I find the correct parameters? And is there any way to get a response from Invoke-XmlCommand when the command didn`t succeed, such as a return code?

Subject: RE: Create backup configuration using Invoke-XML (and a quick-tip)
Replied by: John McDonough on 27-09-2011 08:53:58 AM
Jan,

For the backup object you have specified an attribute that is not user configurable, childAction.  I ran your setting through the UCS Manager and captured the traffic and captured this configConfMo object

This is what I sent

<configConfMo cookie="1317127772/a58edda9-d781-4363-903c-c8ff47f4e3d9" inHierarchical="false">
    <inConfig>
        <mgmtBackup
        adminState="enabled"
        hostname="10.10.10.10"
        descr=""
        preservePooledValues="no"
        proto="ftp"
        pwd="password"
        remoteFile="/Cisco UCS/system-backup.bak"
        rn="backup-10.10.10.10"
        type="config-all"
        user="user.backup">
        </mgmtBackup>
    </inConfig>
</configConfMo>


And this is what I got back

<configConfMo dn="" cookie="1317127772/a58edda9-d781-4363-903c-c8ff47f4e3d9" response="yes">
  <outConfig>
    <mgmtBackup
      adminState="enabled"
      descr=""
      dn="sys/backup-10.10.10.10"
      fsmDescr=""
      fsmPrev="nop"
      fsmProgr="100"
      fsmRmtInvErrCode="none"
      fsmRmtInvErrDescr=""
      fsmRmtInvRslt=""
      fsmStageDescr=""
      fsmStamp="never"
      fsmStatus="backupBegin"
      fsmTry="0" hostname="10.10.10.10"
      intId="2357186"
      job="immediate"
      name=""
      postAction="remove"
      preservePooledValues="no"
      proto="ftp" pwd=""
      remoteFile="/Cisco UCS/system-backup.bak"
      status="created"
      type="config-all"
      user="user.backup"/>
  </outConfig>
</configConfMo>

This failed for me because I don't have a 10.10.10.10 ftp host but should work for you, hope that helps.

John

Subject: RE: Create backup configuration using Invoke-XML (and a quick-tip)
Replied by: Jan Egil Ring on 27-09-2011 09:25:38 AM
Thanks John, this worked like a charm.

So capturing the traffic is the current way to find errors?
An overview of configurable settings would be nice

Maybe the next version of the UCS PowerShell Toolkit will have a much broader coverage, so that we won`t need to work this much with XML-strings....

Subject: RE: Create backup configuration using Invoke-XML (and a quick-tip)
Replied by: John McDonough on 27-09-2011 10:11:23 AM
The next release of the PowerShell library will have a significant number of cmdlets, probably in the 1300+ range, hope that isn't too scary.  However the benefit is that there will be cmdlets for every conceivable activity. It should be released soon.

I typically capture traffic when I'm working on a script, take a look at the documents here, http://developer.cisco.com/web/unifiedcomputing/docs

As well download the UCS Emulator to get a copy of the object model documents, if you have not already done so.

John

Subject: RE: Create backup configuration using Invoke-XML (and a quick-tip)
Replied by: Philip Sautter on 27-09-2011 12:53:06 PM
John,

I'm very happy to hear that the next release of the UCSPS module will have a lot more functionality.  Is there a tentative release date for the next version?

Phil

Subject: RE: Create backup configuration using Invoke-XML (and a quick-tip)
Replied by: Jan Egil Ring on 28-09-2011 02:52:22 PM
I agree with Philip, this is excellent news. I`d also be interested if some form of beta or pre-release version is available.
CreatePlease to create content