Log In
Developer Network
Technologies
Join the Network
Member Services
Events & Community
Unified Computing UCS Manager Developer Center
Overview
UCS Manager XML Schema
UCS Automation Tool (goUCS)
Server and Host Management API
UCS Standalone C-Series Servers
Cisco Standalone C-Series CIMC XML API
goUCS Automation Tool
Cisco Standalone C-Series HUU Utilities
Documentation
Community
Testing
UCS Management Ecosystem
Management with HP Software
HP Operations Manager (HPOM)
HP Operations Orchestration (HPOO)
Management with Microsoft Software
Microsoft System Center
Cisco UCS PowerTool for UCSM
SDK
System Management Resources
Altiris
UCS Management with VMware Software
OpenStack
UCS Labs
Labs Wiki
VM-FEX
Overview
Getting Started
Resources
Flexpod
Overview
Getting Started
Resources
Everything
This Site
Blogs
Cisco UCS for RackTables
Jeffrey Silberman
25 Oct 2012
Cisco UCS PowerTool Examples
Eric Williams
20 Jul 2012
ANNOUNCEMENT: goUCS version 2.0 Released
Eric Williams
08 Mar 2012
Getting to Know your UCS Fabric Interconnect Neighbors
John McDonough
10 Nov 2011
SCOM MP version 2.0 for Cisco UCS is now available
Chakri Avala
01 Sep 2011
Showing 1 - 5 of 16 results.
Items per Page 5
Page
(Changing the value of this field will reload the page.)
1
2
3
4
of 4
First
Previous
Next
Last
Forums
Message Boards Home
Recent Posts
Statistics
Answer
(
Unmark
)
Mark as an Answer
« Back to Microsoft Discussions
Automatic reply: New Message from Muhammad Afzal in Unified Computing UCS M
Threads [
Previous
|
Next
]
Muhammad Afzal
Posts:
2
Join Date:
11/7/12
Recent Posts
UCS XML API in C#
ucs
.net
xml api
xml
ucs xml api
c
ucs manager
visual studio
c code
Answer
11/16/12 1:08 AM
Mark as an Answer
Submit
Reply with Quote
Quick Reply
While looking into UCS XML API documentation, I wrote a simple c# code as a test to consume UCS XML API in c# console application. I thought it would be worth sharing.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Xml;
namespace UCSAPIConsoleApp {
class Program
{
static void Main(string[] args)
{
string sAuthCookie, sUsername, sPassword, sURI;
try
{
Console.Write("Enter UCS URI(http:///nuova: ");
sURI = Console.ReadLine();
Console.Write("Enter username: ");
sUsername = Console.ReadLine();
Console.Write("Enter password: ");
sPassword = Console.ReadLine();
XmlDocument doc = new XmlDocument();
doc.LoadXml(HTTPRequestResponse(sURI, ""));
XmlNode xmln = doc.SelectSingleNode("/aaaLogin");
sAuthCookie = xmln.Attributes["outCookie"].Value.ToString();
Console.WriteLine("Auth Cookie:{0}", sAuthCookie);
Console.WriteLine("=============================================================");
doc.LoadXml(HTTPRequestResponse(sURI, ""));
xmln = doc.SelectSingleNode("/configResolveDn/outConfig/computeBlade");
for (int i = 0; i < xmln.Attributes.Count; i++)
Console.WriteLine("{0}={1}", xmln.Attributes
.Name, xmln.Attributes
.Value);
doc.LoadXml(HTTPRequestResponse(sURI, ""));
xmln = doc.SelectSingleNode("/aaaLogout");
Console.WriteLine("=============================================================");
Console.WriteLine("Logout={0}", xmln.Attributes["outStatus"].Value.ToString());
Console.ReadKey();
}
catch (Exception ex)
{
Console.WriteLine("Error occurred while execution:{0}", ex.Message);
}
}
private static string HTTPRequestResponse(string sURL, string strXML)
{
byte[] XMLbuffer = Encoding.UTF8.GetBytes(strXML);
try
{
HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create(sURL);
WebReq.Method = "POST";
WebReq.ContentType = "text/xml";
WebReq.ContentLength = XMLbuffer.Length;
Stream PostData = WebReq.GetRequestStream();
PostData.Write(XMLbuffer, 0, XMLbuffer.Length);
PostData.Close();
using (HttpWebResponse WebResponse = (HttpWebResponse)WebReq.GetResponse())
{
Stream response = WebResponse.GetResponseStream();
return new StreamReader(response).ReadToEnd();
}
}
catch(Exception ex)
{
Console.WriteLine("Exception occurred: {0}", ex.Message);
return null;
}
}
}
}
OUTPUT:
Auth Cookie:1353028019/a171253a-ebeb-4b21-b01d-4b357b611cba
=============================================================
adminPower=policy
adminState=in-service
assignedToDn=org-root/ls-11
association=none
availability=unavailable
availableMemory=4096
chassisId=1
checkPoint=discovered
connPath=A,B
connStatus=A,B
descr=
discovery=complete
dn=sys/chassis-1/blade-1
fltAggr=0
fsmDescr=
fsmFlags=
fsmPrev=DiscoverSuccess
fsmProgr=100
fsmRmtInvErrCode=none
fsmRmtInvErrDescr=
fsmRmtInvRslt=
fsmStageDescr=
fsmStamp=2012-11-16T01:51:21.487
fsmStatus=nop
fsmTry=0
intId=31838
lc=undiscovered
lcTs=1970-01-01T01:00:00.000
lowVoltageMemory=not-applicable
managingInst=A
memorySpeed=not-applicable
mfgTime=not-applicable
model=N20-B6620-1
name=
numOfAdaptors=1
numOfCores=6
numOfCoresEnabled=6
numOfCpus=1
numOfEthHostIfs=1
numOfFcHostIfs=0
numOfThreads=6
operPower=off
operQualifier=
operState=unassociated
operability=operable
originalUuid=1b4e28ba-2fa1-11d2-0101-b9a761bde3fb
presence=equipped
revision=0
serial=1045
serverId=1/1
slotId=1
totalMemory=4096
usrLbl=
uuid=1b4e28ba-2fa1-11d2-0101-b9a761bde3fb
vendor=Cisco Systems Inc
=============================================================
Logout=success
Sign in to vote.
Flag
Please sign in to flag this as inappropriate.
Top
John Kennedy
Posts:
3
Join Date:
2/12/11
Recent Posts
Automatic reply: New Message from Muhammad Afzal in Unified Computing UCS M
Answer
11/15/12 11:11 PM as a reply to Muhammad Afzal.
Mark as an Answer
Submit
Reply with Quote
Quick Reply
I am out of the office until the 20th of November, 2012. For FlexPod issues, please contact Arun Garg (arung@cisco.com<https://mail.cisco.com/ecp/Organize/arung@cisco.com>) or Chris O'Brien (chrobrie@cisco.com). Thanks for your patience - JFK
Sign in to vote.
Flag
Please sign in to flag this as inappropriate.
Top
Collateral
No files available