この製品のマニュアルセットは、偏向のない言語を使用するように配慮されています。このマニュアルセットでの偏向のない言語とは、年齢、障害、性別、人種的アイデンティティ、民族的アイデンティティ、性的指向、社会経済的地位、およびインターセクショナリティに基づく差別を意味しない言語として定義されています。製品ソフトウェアのユーザーインターフェイスにハードコードされている言語、RFP のドキュメントに基づいて使用されている言語、または参照されているサードパーティ製品で使用されている言語によりドキュメントに例外が存在する場合があります。シスコのインクルーシブランゲージに対する取り組みの詳細は、こちらをご覧ください。
このドキュメントは、米国シスコ発行ドキュメントの参考和訳です。リンク情報につきましては、日本語版掲載時点で、英語版にアップデートがあり、リンク先のページが移動/変更されている場合がありますことをご了承ください。あくまでも参考和訳となりますので、正式な内容については米国サイトのドキュメントを参照ください。
CloupiaScript を使用してレポートにアクセスできます。レポート データを使用することで、後続タスクについて動的に意思決定できます。
たとえば、関連付けなしの 32GB を超える Cisco UCS B シリーズ ブレード サーバを割り当てるには、次のスクリプトを使用して特定の Cisco UCS Manager で管理されているすべての Cisco UCS サーバのリストを問い合わせます。このスクリプトは値のサブセットを抜粋してフィルタする方法の例です。getReportView(reportContext, reportName) 関数は、reportContext および reportName を引数として取得し、表形式でコンテンツを表示する TableView オブジェクトを返します。
importPackage(java.lang); importPackage(java.util); importPackage(com.cloupia.lib.util.managedreports); function getReport(reportContext, reportName) { var report = null; try { report = ctxt.getAPI().getConfigTableReport(reportContext, reportName); } catch(e) { } if (report == null) { return ctxt.getAPI().getTabularReport(reportName, reportContext); } else { var source = report.getSourceReport(); return ctxt.getAPI().getTabularReport(source, reportContext); } } function getReportView(reportContext, reportName) { var report = getReport(reportContext, reportName); if (report == null) { logger.addError("No such report exists for the specified context "+reportName); return null; } return new TableView(report); } // following are only sample values and need to be modified based on actual UCSM account name var ucsmAccountName = "ucs-account-1"; // report name is obtained from Report Meta. No need to change unless you need to access a different report var reportName = "UcsController.allservers.table_config"; var repContext = util.createContext("ucsm", null, ucsmAccountName); // Enable Developer Menu in UCSD and find reportName in the Report Metadata for the specific report // Creating a ReportContext // @param contextName // Refer to UCSD API Guide for the available contexts // @param cloud // should be null unless contextName is "cloud" or "host node" // @param value // identifier of the object that is going to be referenced Report var report = getReportView(repContext, reportName); // Get only the rows for which Server Type column value is B-Series report = report.filterRowsByColumn("Server Type", "B-Series", false); // now look for unassociated servers only report = report.filterRowsByColumn("Operation State", "unassociated", false); // Make sure servers are actually in available state report = report.filterRowsByColumn("Availability", "available", false); var matchingIds = []; var count = 0; // Now look for Servers with memory of 32 GB or more for (var i=0; i<report.rowCount(); i++) { var memory = Integer.parseInt(report.getColumnValue(i, "Total Memory (MB)")); logger.addDebug("Possible Server "+report.getColumnValue(i, "ID")+", mem="+memory); if (memory >= 32*1024) { matchingIds[count++] = report.getColumnValue(i, "ID"); } } if (count == 0) { ctxt.setFailed("No servers matched the criteria"); ctxt.exit(); } // Now randomly pick one of the item from the filtered list var id = matchingIds[Math.round(Math.random()*count)]; logger.addInfo("Allocated server "+id); // Save the Server-ID to the global inputs ctxt.updateInput("SELECTED_UCS_SERVER_ID", id);
getTabularReport (reportName, reportContext) API を使用して表形式のレポートにアクセスする場合は、次のいずれかの方法でユーザ インターフェイス(UI)にレポートの詳細を表示できます。
[レポートのカスタマイズ(Reports Customization)] タブ:レポートのカスタマイズ タブにアクセスするには を選択します。カスタマイズ タブには、メニュー、コンテキスト、レポート タイプなどのレポートの詳細が表示されます。テーブルの列をカスタマイズするには [テーブルの列のカスタマイズ(Customize Table Columns)] アイコンをクリックし、表示される列の項目のチェックボックスを選択します。たとえば、レポート ID を表示するには [ID] チェックボックスを選択します。
を選択し、[レポートのカスタマイズ(Reports Customization)]レポート メタデータ:開発者メニューが有効の場合のみ、レポート メタデータのリンクが UI に表示されます。
レポートの詳細で重要なものを次に説明します。
API レポート ID:userAPIGetTabularReport API を使用する場合、[APIレポートID(API report ID)] 列を使用して、REST URL で使用される reportID パラメータの値を取得できます。この REST API は、Web ブラウザまたは他の REST クライアント アプリケーションから表形式のレポートを取得するために使用されます。
ID:[ID] 列にはレポート名が表示されます。Cloupia スクリプトで getTabularReport API を使用する場合、reportName パラメータの取得に [ID] 列を使用できます。このパラメータは getConfigTableReport API でも使用されます。
コンテキスト:ReportContext のコンストラクタには contextName および contextValue の 2 つの入力パラメータが必要です。標準のコンテキストには util.createContext("contextName", null, "instanceName") を使用します。たとえば、util.createContext("vm",null, vmId) であれば、vmId には UCS Director の VM を一意に識別する整数値の VM ID 値を指定します。クラウド コンテキストには util.createContext("contextName","cloudInstanceName", null) または util.createContext("contextName",null,"cloudInstanceName") を使用します。たとえば、util.createContext("cloud","All Clouds",null) または util.createContext("cloud", null, "All Clouds") です。
Cloupia スクリプトを使用してユーザにレポートをメール送信できます。レポートを定期的にメール送信する必要がある場合は、ワークフローのワークフロー スケジュールを任意の頻度で設定できます。
ワークフロー入力変数 Email Address で指定されているユーザに対して、電源がオンになっているすべての VM のリストをメール送信するには、次のスクリプトを使用します。
importPackage(java.util); importPackage(java.lang); importPackage(java.io); importPackage(com.cloupia.model.cEvent.notify); importPackage(com.cloupia.model.cIM); importPackage(com.cloupia.lib.util.mail); importPackage(com.cloupia.fw.objstore); importPackage(com.cloupia.lib.util.managedreports); function getMailSettings() { return ObjStoreHelper.getStore((new MailSettings()).getClass()).getSingleton(); } function getReport(reportContext, reportName) { var report = null; try { report = ctxt.getAPI().getConfigTableReport(reportContext, reportName); } catch(e) { } if (report == null) { return ctxt.getAPI().getTabularReport(reportName, reportContext); } else { var source = report.getSourceReport(); return ctxt.getAPI().getTabularReport(source, reportContext); } } function getReportView(reportContext, reportName) { var report = getReport(reportContext, reportName); if (report == null) { logger.addError("No such report exists for the specified context "+reportName); return null; } return new TableView(report); } // Assume the To Email Addres is in the input variable 'Email Address' var toEmail = [ ctxt.getInput("Email Address") ]; var message = new EmailMessageRequest(); message.setToAddrs(toEmail); message.setSubject("VM List Reportl"); message.setFromAddress("no-reply@cisco.com"); var buffer = new StringWriter(); var printer = new PrintWriter(buffer); // Formatter exists in multiple packages, so it needs fully qualified name var formatter = new com.cloupia.lib.util.managedreports.Formatter(new File("."), printer); var reportName = "GLOBAL_VM_LIST_REPORT"; var repContext = util.createContext("global", null, null); var report = getReportView(repContext, reportName); // Filter Active State VMs report = report.filterRowsByColumn("Power State", "ON", false); formatter.printTable(report); printer.close(); var body = "<head><style type='text/css'>"; // Specify CSS for the report body = body + "table { font-family: Verdana, Geneva, sans-serif; font-size: 12px; border: thin solid #039; border-spacing: 0; background: #ffffff; } "; body = body + " th { background-color: #6699FF; color: white; font-family: Verdana, Geneva, sans-serif; font-size: 10px; font-weight: bold; border-color: #CCF; border-style: solid; border-width: 1px 1px 0 0; margin: 0; padding: 5px; } "; body = body + " td { font-family: Verdana, Geneva, sans-serif; font-size: 10px; border-color: #CCF; border-style: solid; border-width: 1px 1px 0 0; margin: 0; padding: 5px; background: #ffffff; }"; body = body + "</style></head>"; body = body+ "<body><h1>List of Powered ON VMs</h1><br>" + buffer.toString(); message.setMessageBody(body); logger.addInfo("Sending email"); // Now, send the report via email. First parameter is just a label used in the internal logs MailManager.sendEmail("VM List Report", getMailSettings(), message);