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 Server 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

本文作者是 Canonical 现场工程师 Mark Wenning

用于对 MAAS 和 Juju 群集进行更精细控制的标记

MAAS 根据节点的物理属性实现标记系统。关于标记的 MAAS 文档主要从使用现有硬件标记和 –constraints 的描述选项的角度对此进行了讨论。 

还可以手动创建新标记,以便更轻松地部署和管理 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>
  • <profile-name 可以是您想要的任何名称> ,通常这是“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

使用“description”选项创建标签

如有关标记的 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>"]
  • <profile> 是使用登录命令设置的配置文件名称,通常为“maas”
  • <tag-name> 是标记的名称
  • <评论> 是可选的,但是一个好主意。

请注意,我们未在此处使用描述选项。   所以:

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

可以手动将此标记分配给系统中的一个或多个节点。

分配标记

要将标记分配给一个或多个节点,请运行以下命令:

$ maas <profile> tag update-nodes <raw-tag-name> add="<system-id>"
  • <Profile> 是在登录期间设置的配置文件名称
  • <raw-tag-name> 是之前创建的标记的名称
  • <system-id> 是节点的系统 ID。

<系统 ID>?  什么?

如何查找节点的系统 ID?   一种方法是列出节点信息并将其从结构中挑选出来。  maas cli 命令

$ maas <profile> nodes list
  • <Profile> 是在登录期间设置的配置文件名称

将转储出一个 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/"
},
]

解码输出

列表中第一个节点的“hostname”属性为“T110ii.maas”。我们还对此节点的 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 中的“tag-names”属性列出了分配给此节点的所有标记,包括新标记。

帮助您添加标签的脚本

选项包括:

  • --login :在将标签分配给节点之前登录。此选项还需要
    • –oauth :用于在上面登录的api / oauth密钥,可能取决于您的设置,
    • –host_url : 用于登录上面的主机 URL
    • –profile :用于在上面登录的配置文件名称
  • --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