Skip to main content
  • Place orders quickly and easily
  • View orders and track your shipping status
  • Create and access a list of your products
  • Manage your Dell EMC sites, products, and product-level contacts using Company Administration.

在 Ubuntu 伺服器 14.04 LTS 中使用具有 MAAS 和 Juju 的標籤

Summary: MAAS 根據節點的物理屬性實現標籤系統。關於標籤的 MAAS 文件對此進行了討論

This article may have been automatically translated. If you have any feedback regarding its quality, please let us know using the form at the bottom of this page.

Article Content


Symptoms

本文由 Mark Wenning,Canonical Field Engineer 撰寫。

用於更精細地控制 MAAS 和 Juju 集群的標籤

MAAS 根據節點的物理屬性實現標籤系統。關於標記的 MAAS 文件對此進行了討論,主要是從使用現有硬體標記和 –constraint 的描述選項的角度來看。 

還可以手動創建新標記,以便更輕鬆地部署和管理MAAS和Juju集群。    

例如,如果要在 MAAS 群集上引導 Juju 並強制引導節點位於特定電腦上,則可以先標記該節點,然後使用該標記作為約束進行引導。

$ juju bootstrap --constraints "tags=my-juju-bootstrap-node" –debug

請注意,設置這樣的標記約束后,以下 juju 命令將嘗試使用該約束,直到您取消它:

$ juju set-constraints "tags="

標籤的另一個用途是用相同的標籤標記多個節點,然後僅部署到這些節點:

$ juju deploy mysql –constraints "tags=my-juju-Dell-nodes" --debug

登入 MAAS 命令行介面

您必須先登入 MAAS 區域伺服器,才能使用這些命令:

$ maas login <profile-name> <host-url> <apikey>
  • <設定檔名稱> 可以是您想要的任何名稱,通常這是「Maas」
  • <host-url> 是 MAAS 區域控制器的 URL,加上 api 和版本(即https://192.168.0.2/MAAS/api/1.0)。
  • <apikey> 是構建 MAAS 區域控制器時創建的 MAAS api 或 OAuth 金鑰。

請參閱 https://maas.io/docs/此超連結會帶您前往 Dell Technologies 以外的網站。 以了解詳細資訊。

完成後,若要登出 MAAS CLI 環境,請執行

$ maas logout maas

使用「描述」選項建立標籤

如有關標記的 MAAS 文件中所述,可以使用 XPath 運算式根據與節點關聯的“lshw”資訊(格式化為 XML)創建和分配標記。   您可以在每個節點網頁底部按一下「原始探索資料」底下的「顯示發現的詳細資料」連結,以存取此資訊。   其中一個節點的部分「lshw」資訊如下:

...

<lshw:node id="t410" claimed="true" class="system" handle="DMI:0100">
<lshw:description>System</lshw:description>
<lshw:product>PowerEdge T410 ()</lshw:product>
<lshw:vendor>Dell Inc.</lshw:vendor>
<lshw:serial>RHXT410</lshw:serial>
<lshw:width units="bits">64</lshw:width>
<lshw:configuration>
<lshw:setting id="boot" value="normal"/>
<lshw:setting id="chassis" value="server"/>
<lshw:setting id="uuid" value="44454C4C-4800-1058-8054-D2C04F343130"/>
</lshw:configuration>
<lshw:capabilities>
...

要向系統中的節點添加更多描述性標記,可以執行:

$ maas maas tags new name="Dell_Machine" definition='//node[@class="system"]/vendor = "Dell Inc."'
$ maas maas tags new name="Intel_Machine" definition='//node[@class="system"]/vendor = "Intel Corp."'
$ maas maas tags new name="Virtual_Machine" definition='//node[@class="system"]/vendor = "QEMU"'
$ maas maas tags new name="Laptop" definition='//node[@class="system"]/description = "Laptop"'
$ maas maas tags new name="Rack_Mount" definition='//node[@class="system"]/description = "Rack Mount Chassis"'
$ maas maas tags new name="Mini_Tower" definition='//node[@class="system"]/description = "Mini Tower Computer"'
$ maas maas tags new name="System" definition='//node[@class="system"]/description = "System"'
$ maas maas tags new name="Desktop" definition='//node[@class="system"]/description = "Desktop Computer"'
$ maas maas tags new name="Blade" definition='//node[@class="system"]/description = "Multi-system"'
$ maas maas tags new name="Intel_CPU" definition='//node[@class="processor"]/vendor = "Intel Corp."'
$ maas maas tags new name="AMD_CPU" definition='//node[@class="processor"]/vendor = "Advanced Micro Devices [AMD]"'
$ maas maas tags new name="64bit" definition='//node[@class="system"]/width="64"'
$ maas maas tags new name="32bit" definition='//node[@class="system"]/width="32"'

這些會使用 Dell_Machine、Intel_Machine、Virtual_Machine、Rack_Mount、系統、桌上型電腦、筆記型電腦、Rack_Mount、多系統、64 位元和/或 32 位元等標籤來標記相容節點,並且也會套用到稍後新增的任何節點。

手動建立標籤

新的原始標籤會使用 MAAS cli 命令建立

$ maas <profile> tag new name="<tag-name>" [comment="<comment>"]
  • <設定檔> 是使用登入命令設定的設定檔名稱,通常為「Maas」
  • <標籤名稱> 是標籤的名稱
  • <評論> 是可選的,但是個好主意。

請注意,我們這裡沒有使用描述選項。   偌:

$ maas maas tag new name="my-juju-node" comment="my new juju node"

此標籤可以手動分配給系統中的一個或多個節點。

指派標籤

若要將標籤指派給一個或多個節點,請執行下列命令:

$ maas <profile> tag update-nodes <raw-tag-name> add="<system-id>"
  • <「設定檔> 」是登入時設定的設定檔名稱
  • <raw-tag-name> 是先前建立的標籤名稱
  • <系統 ID> 是節點的系統 ID。

<系統 ID>?  那是什麼?

如何找到節點的系統ID?   一種方法是列出節點資訊並將其從結構中挑選出來。  Maas cli 命令

$ maas <profile> nodes list
  • <「設定檔> 」是登入時設定的設定檔名稱

將轉儲一個 JSON 格式的物件(結構清單),其中包含有關節點的所有資訊。  例如:

$ maas maas nodes list

[
{
"status": 4,
"macaddress_set": [
{
"resource_uri": "/MAAS/api/1.0/nodes/node-2349c038-d792-11e3-8df4-0c54a5f0ce34/macs/bc%3A30%3A5b%3Ae3%3A21%3A15/",
"mac_address": "bc:30:5b:e3:21:15"
}
],
"hostname": "T110ii.maas",
"zone": {
"resource_uri": "/MAAS/api/1.0/zones/default/",
"name": "default",
"description": ""
},
"routers": [],
"netboot": true,
"cpu_count": 8,
"storage": 239825,
"owner": null,
"system_id": "node-2349c038-d792-11e3-8df4-0c54a5f0ce34",
"architecture": "amd64/generic",
"memory": 8192,
"power_type": "ipmi",
"tag_names": [
"use-fastpath-installer",
"my-juju-boostrap-node"
],
"ip_addresses": [
"192.168.0.53"
],
"resource_uri": "/MAAS/api/1.0/nodes/node-2349c038-d792-11e3-8df4-0c54a5f0ce34/"
},
]

解碼輸出

清單中的第一個節點具有「T110ii.maas」的「hostname」屬性。我們也對這個節點的 system-id 屬性感興趣:「system_id」:「node-2349c038-d792-11e3-8df4-0c54a5f0ce34」

現在,我們可以將新標籤分配給此節點:

$ maas maas tag update-nodes my-juju-bootstap-node add=node-2349c038-d792-11e3-8df4-0c54a5f0ce34

圖 1 中的「標籤名稱」屬性列出了分配給此節點的所有標籤,包括新標籤。

說明您新增分頁的文稿

Options:

  • --login :在將標籤分配給節點之前登錄。此選項還需要
    • –oauth :用於在上面登錄的 API / OAuth 金鑰,根據您的設置,
    • –host_url:用於在上面登入的主機 URL
    • –設定檔:用於在上面登入的設定檔名稱
  • --remove_tags :刪除此腳本之前分配的標籤。
  • --add_tags:根據名稱為每個節點添加標籤

參考資料

命令行介面 MAAS 1.6 說明文件:

https://maas.io/docs/maas-cli此超連結會帶您前往 Dell Technologies 以外的網站。

Juju 說明文件 (限制) 

https://juju.ubuntu.com/docs/charms-constraints.html此超連結會帶您前往 Dell Technologies 以外的網站。

https://juju.ubuntu.com/docs/reference-constraints.html此超連結會帶您前往 Dell Technologies 以外的網站。

Cause

-

Resolution

-

Article Properties


Affected Product

Ubuntu Server LTS

Last Published Date

23 Jul 2024

Version

4

Article Type

Solution