PowerVC 2.0.2.1 設定 ~ストレージ・ホストネーム・テンプレートの設定 ~ 

##### はじめに


ストレージ・ホストネーム・テンプレートを設定すると PowerVC がデプロイした際に自動で作成されるストレージ上の Host Name 属性をある程度定義することが可能です。


https://www.ibm.com/docs/ja/powervc/2.0.2?topic=commands

"powervc-config compute storage_hostname_template"

>Use this command to customize hostname on the backend storage during NPIV virtual machine deployment. This command is applicable for XIV® and SVC storage types.

>The storage_hostname_template can have prefix, suffix, host where the virtual machine is deployed and the vm_display_name which is used for the virtual machine name. The prefix and suffix are optional but you must provide either host or vm_display_name.


(コマンド・ヘルプのご参考)

```
# powervc-config compute storage_hostname_template --help
usage: powervc-config compute storage_hostname_template [-h] [--host HOSTNAME]
                                                        [--set VALUE]
                                                        [--clear] [--restart]


The storage_hostname_template is used to set the template for hostname
customization on the storage. Template to be used to configure is
prefix_%(host)s_%(vm_display_name)s_suffix. The %(host)s and
%(vm_display_name)s values can have a dynamic truncation value. It can be
specified with the format: %(<dynamic_option>).<max-length>s. By  default, the
truncation length for both the dynamic options is 20. It can be configured as
mentioned above.  Default value of storage_hostname_template is None. The
total length of storage_hostname_template should be  less than 55 characters.
This includes the truncation length of both dynamic options, prefix, suffix
and one additional length of the underscore character. Also, if the
storage_hostname_template starts with a number - an underscore will be added
at the beginning, thus increasing the template length by one. The template
length will be calculated on the truncation length given for each parameter.
So, even if the length of vm name is 10 and truncation length is 20, the total
template length will be measured with 20 as the vm name length.


optional arguments:
  -h, --help       show this help message and exit
  --host HOSTNAME  The hypervisor host name on which to update the
                   storage_hostname_template.
  --set VALUE       Specify the template to use for the
                   storage_hostname_template.  The template allows prefix and
                   suffix along with the host  where the VM is deployed and
                   vm_display_name used for the VM name. The Template should
                   be set like  --set
                   prefix_%(host).10s_%(vm_display_name).20s_suffix  where
                   prefix and suffix are user choice string value  and the
                   string values are optional.   '%(host).10s' shows host
                   where the vm is deployed and   '%(vm_display_name).20s'
                   shows the vm name. Even though both '%(host)s' and
                   '%(vm_display_name)s' are optional, but advisable to have
                   atleast one field. For example,'--set
                   powervc_%(host).5s_%(vm_display_name).10s_svc'  specifies 5
                   as the truncate_host_length and 10 as the
                   truncate_vm_name_length. If VM name is
                   rhel_vm_hmc_123456789012345, it will be truncated to
                   rhel_vm_hm and if host name is 9179MHC_1086D5R,  it will be
                   truncated to 9179M. If truncation lengths are not
                   specified. For example: --set
                   powervc_%(host)s_%(vm_display_name)s_svc, the host name and
                   vm_display_name will be truncated to 20 by default and for
                   the above example VM name would be rhel_vm_hmc_12345678
                   after truncation and host name would be 9179MHC_1086D5R
                   after truncation.
  --clear          Clear the host's storage_hostname_template.
  --restart        Restart the Nova compute service on the host If this option
                   is not specified, you must  manually restart the services
                   to make  the changes effective.
```

----
##### 環境

・PowerVC 2.0.2.1
・ストレージ V7000



----

##### 設定方法

PowerVC 上でコマンドを発行してストレージ・ホストネーム・テンプレートを設定します。
"vm_display_name" がホストネームとして定義される設定を行います。

実行前確認

```
# powervc-config compute storage_hostname_template --host Server-8286-42A-XXXXXXXX
No value found for storage_hostname_template on host Server-8286-42A-XXXXXXXX.
#
```

実行

```
# powervc-config compute storage_hostname_template --host Server-8286-42A-XXXXXXXX --set '%(vm_display_name)s' --restart
Restarting the Nova compute service.
Successfully restarted the openstack-nova-compute service.
#
```
実行後確認

```
# powervc-config compute storage_hostname_template --host Server-8286-42A-XXXXXXXX
The value for storage_hostname_template on host Server-8286-42A-XXXXXXXX is %(vm_display_name).20s.
#
```

-----

##### テンプレート設定反映確認

定義後にVM デプロイを実施し、設定を確認します。

PowerVC 上で "AIXTEST0107-TEST" という VM を作成しました。

![図1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/517421/256389f9-16f4-d19e-58e3-413e2c6d093c.png)

V7000 の GUI で"Host Name" が "AIXTEST0107-TEST-xxxxx" で作成されています。
末尾に付く文字列は、自動付与です。これは現時点では致し方なし。
ホスト名のみにしたい場合は、削除対応が必要となるようです。

![図2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/517421/ec8410d3-3c8e-72de-513d-b6ce0e015c1c.png)

ボリューム名は、特にテンプレート指定はしていませんが、volume-"VM名"-xxxxx で作成されていました。

![図3.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/517421/fe0789cc-cf45-06a3-2215-36ba8a577033.png)


----

ちなみに何も設定していない場合のホスト名は pvc-"VM名"-xxxxxxx-xxxxxxxx  (末尾はUID?)のような形式でストレージ・ホストネームが設定されていました。 


以上です。