cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BenceBertalan
Paper Tape
Posts: 2
Registered: ‎03-17-2017
Location: HU
Views: 3,003
Message 1 of 6

xClarity Administrator - Scripting

Here You can post all the questions related to Scripting xClarity Administrator (PowerShell, Python, REST).

BenceBertalan
Paper Tape
Posts: 2
Registered: ‎03-17-2017
Location: HU
Views: 2,997
Message 2 of 6

Re: xClarity Administrator - Scripting

My first two question to the Lenovo Support would be:

 

  • When I try to deploy and ESXi server using the Lenovo xClarity PowerShell module, everything works fine, except for the VLAN setup for the Management interface. I've set up the VLAN in the scipt using the example on the xClarity Doumentation, but it's simply not applying on the server. (The "Use VLANs" Global Option is enabled aswell)
  • Please, give me an example on how to logon to the REST api... What is the format? 
    I've tried in many ways, but it still wants to take me to the Logon site, which (for a script) is not the best

 

Thank You!

Lenovo Employee BigJay
Lenovo Employee
Posts: 15
Registered: ‎06-03-2015
Location: US
Views: 2,861
Message 3 of 6

Re: xClarity Administrator - Scripting

Please check your selectedMAC section.  Setting VLAN tag and use of Auto for MAC address is mutually exclusive.  Therefore if you want to set a VLAN tag, the selectedMAC address has to be set to s sepcific MAC address value.  If you tried to deploy with both Auto set for MAC adderess and tried to set VLAN tagging and ran the job within the GUI, it would notify you within the GUI, that this combination is invlaid.

 

Please see the notes in the right pane below:

 

selectedMACRequiredStringThe MAC address of the host server to which the IP address is to be bound.

The MAC address is set to AUTO by default. This setting automatically detects the Ethernet ports that can be configured and used for deployment. The first MAC address (port) that is detected is used by default. If connectivity is detected on a different MAC address, the Lenovo XClarity Administrator host is automatically restarted to use the newly detected MAC address for deployment.

VLAN mode is supported only for servers that have MAC addresses in their inventory. If AUTO is the only the MAC address that is available for a server, then VLANs cannot be used to deploy operating systems to that server.

Tip: To obtain the MAC address, use the macaddress value field in GET /hostPlatforms.

 

http://flexsystem.lenovofiles.com/help/topic/com.lenovo.lxca_restapis.doc/rest_api_host_platforms_pu...

tuczap
What's DOS?
Posts: 1
Registered: ‎05-18-2017
Location: PL
Views: 2,731
Message 4 of 6

Re: xClarity Administrator - Scripting

I can't call xClarity REST API from Powershell - it tells me:

 

<body class="oneui augusta xhmcLogin">
    <!--[if lt IE 9]>
        <p>When using Microsoft<sup>TM</sup> Internet Explorer you must use version 9 or greater</p>
    <![endif]-->

  <div id="augustaApplication"></div>
  <div id="loadingNode" class='dijitContentPaneLoading'>
    <div class='dijitInline dijitIconLoading'></div>
    <span id="loadingMessage"></span>
  </div>
</body>

My code is:

add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
        }
    }
"@

[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

Invoke-RestMethod -Uri https://10.203.49.208/aicc

Most part of the script is omitting the certificate check and only last cmdlet is actually calling the REST API - which doesn't work. Full output from the script is:

 

<!DOCTYPE html>
<!--
/*
* © Copyright Lenovo 2015.
*
* LIMITED AND RESTRICTED RIGHTS NOTICE:
*
* If data or software is delivered pursuant a General Services Administration
* "GSA" contract, use, reproduction, or disclosure is subject to
* restrictions set forth in Contract No. GS-35F-05925.
*/
-->
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta http-equiv="Cache-Control" content="NO-CACHE" />
  <meta http-equiv="Pragma" content="NO-CACHE" />
  <meta http-equiv="Expires" content="-1" />
  <!-- Edge mode tells Internet Explorer to display content in the highest mode available. -->
  <!-- So the page renders for ie 8, 9, 10. -->
  <link rel="shortcut icon" href="lxca/images/icons/favicon.ico" type="image/x-icon" />
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">

  <!-- load styles -->
  <link rel="stylesheet" href="dijit/themes/claro/claro.css" />
  <link rel="stylesheet" href="idx/themes/oneui/oneui.css" />
  <link rel="stylesheet" href="idx/themes/oneui/oneui2.css" />
  <link rel="stylesheet" href="lxca/css/augustaLogin.css" />

  <!-- include i18n for nls tests -->
  <script type="text/javascript" src="lxca/core/utils/i18n/i18n.js"></script>
  
  <!-- Create the dojoConfig object -->
  <script type="text/javascript" src="lxca/core/dojoConfig.js"></script>

  <!-- Load dojo source code -->
  <script type="text/javascript" src="dojo/dojo.js"></script>
  <script type="text/javascript">
    require([ "lxca/core/branding/branding"], function(Branding) {
      if(document.getElementById("loadingMessage")){
        document.getElementById("loadingMessage").innerHTML = Branding.getGlobalizedBrandedString("pageLoadingMessage");
      }
    });
  </script>


  <!-- Load configuration parameters -->
  <script type="text/javascript" src="lxca/core/globals/globalVars.js"></script>

  <!-- Load the code that intercepts XHR calls and adds the csrf token if needed -->
  <script type="text/javascript" src="lxca/core/xhrIntercept.js"></script>

  <!-- Load the modules we need and start the app -->
  <script type="text/javascript">
  require([
           "dojo/dom",
           "dojo/dom-construct",
           "lxca/coreUI/login/LoginPageInit",
           "lxca/core/utils/logger/logger",
           "dojo/domReady!"
         ], function(
           dom,
           domConstruct,
           LoginPageInit,
           logger,
           ready
         ) {
    window.onerror=function(message, url, lineNumber){
      // strip out ip address or hostname from 'file' for security reasons before logging it.
      url = url.substring(url.indexOf("/ui"));
      logger.error("ERROR: encountered at: [file] " + url + " , [line] " + lineNumber + " , [err] " + message);
    }
    
    // call the page widgets
    var moduleName = "login.html", application;

    // start trace login logic
    logger.trace(moduleName, "Loading login");

    // launch login widget
    application = new LoginPageInit();

    // clear loading node from dom
    domConstruct.destroy(dom.byId("loadingNode"));

    // end trace login logic
    logger.trace(moduleName, "Ending login");
  });
  </script>
</head>
<body class="oneui augusta xhmcLogin">
    <!--[if lt IE 9]>
        <p>When using Microsoft<sup>TM</sup> Internet Explorer you must use version 9 or greater</p>
    <![endif]-->

  <div id="augustaApplication"></div>
  <div id="loadingNode" class='dijitContentPaneLoading'>
    <div class='dijitInline dijitIconLoading'></div>
    <span id="loadingMessage"></span>
  </div>
</body>
</html>

I'm running this script on Windows Server 2016 which has IE11 (I've tested REST API directly in browser and it works) so I don't know why it tells me that I have to run IE9 or greater...

dscotti
Ctrl-Alt-Del
Posts: 10
Registered: ‎12-22-2016
Location: US
Views: 1,660
Message 5 of 6

Re: xClarity Administrator - Scripting

I am working on a powershell script to deploy esxi 6 u3 on 48 ThinkSystem servers. The hardware is a mix of SR630 and SR650's.  

 

It seems the the New-LXCADeployTask does not have an option to set the host name.  Am I totally missing something or what? I can give it an ip/subnet/gateway/vlanid/dns servers and MTU but not a host name? Am I the only one who is missing this functionality? 

Vincent_DD
What's DOS?
Posts: 1
Registered: ‎06-18-2018
Location: BE
Views: 1,293
Message 6 of 6

Re: xClarity Administrator - Scripting

I've hit the same issue. Apparently, XClarity doesn't use the Invoke-RestMethod, but requires its own Invoke-LXCARestMethod instead.

 

First, connect to XClarity:

Connect-LXCA $URL -Credential $Cred -SkipCertificateCheck

 Next, use the following to list, for example, all the resourceGroups.

 Invoke-LXCARestMethod -ResourceUrl "/resourceGroups" -Method GET

 

Hope this helps!

Check out current deals!


Shop current deals