# 4주차 과제 - 장지원

**URL:** <https://forum.openinfra-kr.org/t/topic/195>\
**Category:** 컨트리뷰션\
**Tags:** 2025컨트리뷰션, 컨트리뷰션\
**Created:** [8월 9, 2025, 7:43오전 UTC](https://forum.openinfra-kr.org/t/topic/195 "2025-08-09T07:43:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kooriangman](https://forum.openinfra-kr.org/letter_avatar_proxy/v4/letter/k/e36b37/32.png) [@kooriangman](https://forum.openinfra-kr.org/u/kooriangman)\
**Post date:** [8월 9, 2025, 7:43오전 UTC](https://forum.openinfra-kr.org/t/topic/195/1 "2025-08-09T07:43:33Z")

</div>

# CLI 사용법

## 분석 대상

**test\_metadef\_resource\_types / `openstack image metadef resource type list`**

[openstack.image.v2.metadef\_resource\_type — openstacksdk 4.4.1.dev6 documentation](https://docs.openstack.org/openstacksdk/2025.1/user/resources/image/v2/metadef_resource_type.html)

- 사용 목적

### Openstack Glance

- Openstack의 이미지 관리 서비스를 제공하는 컴포넌트

- 사용자가 가상 머신 이미지를 업로드, 저장, 검색, 공유 등 관리할 수 있도록 지원

- S3같은 외부 스토리지와 연동 가능

- 동작 과정

### 동작

- `openstack image metadef resource type list` 실행 시의 화면

- OCA-OpenStack/python-openstackclient/openstackclient/image/v2/metadef\_resource\_types.py

- `image_client = self.app.client_manager.image` 를 통해 Glance를 호출한다.

- 사용 가능한 칼럼 리스트는 `openstacksdk/openstack/image/v2/metadef_resource_type.py` 파일에서 확인할 수 있다.

### 옵션

```auto
$ openstack image metadef resource type list -help
usage: shell image metadef resource type list [-h] [-f {csv,json,table,value,yaml}] [-c COLUMN]
                                              [--quote {all,minimal,none,nonnumeric}] [--noindent]
                                              [--max-width <integer>] [--fit-width] [--print-empty]
                                              [--sort-column SORT_COLUMN] [--sort-ascending |
                                              --sort-descending]

List metadef resource types

options:
  -h, --help show this help message and exit

output formatters:
  output formatter options

  -f, --format {csv,json,table,value,yaml}
                        the output format, defaults to table
  -c, --column COLUMN
                        specify the column(s) to include, can be repeated to show multiple columns
  --sort-column SORT_COLUMN
                        specify the column(s) to sort the data (columns specified first have a priority, non-
                        existing columns are ignored), can be repeated
  --sort-ascending sort the column(s) in ascending order
  --sort-descending sort the column(s) in descending order

CSV Formatter:
  --quote {all,minimal,none,nonnumeric}
                        when to include quotes, defaults to nonnumeric

json formatter:
  --noindent whether to disable indenting the JSON

table formatter:
  --max-width <integer>
                        Maximum display width, <1 to disable. You can also use the CLIFF_MAX_TERM_WIDTH
                        environment variable, but the parameter takes precedence.
  --fit-width Fit the table to the display width. Implied if --max-width greater than 0. Set the
                        environment variable CLIFF_FIT_WIDTH=1 to always enable
  --print-empty Print empty table if there is no data to show.

This command is provided by the python-openstackclient plugin.

```

- `python-openstackclient/openstackclient/image/v2/metadef_resource_types.py`의 import 부분을 보면 osc\_lib의 command를 통해 옵션을 제공하고 있음을 알 수 있다.

- osc\_lib.command는 cliff의 lister을 import 하여 사용하기에 최종적으로는 해당 클래스를 확인하면 된다.
