Skip to content

Conversation

@choieastsea
Copy link
Collaborator

Overview

Add get_flavors tools for compute tools.

Key Changes

  • Add get_flavors() method
  • Since format is different, changed previous Flavor model to ServerFlavor
  • Add test code for compute_tools

Related Issues

Additional context

server 조회시 flavor 응답 예시

"flavor": {
    "disk": 1,
    "ephemeral": 0,
    "extra_specs": {},
    "original_name": "m1.tiny",
    "ram": 512,
    "swap": 0,
    "vcpus": 1
}

flavor 리스트 조회시 응답 예시

{
    "id": "1",
    "links": [
        {
            "href": "http://openstack.example.com/v2/6f70656e737461636b20342065766572/flavors/1",
            "rel": "self"
        },
        {
            "href": "http://openstack.example.com/6f70656e737461636b20342065766572/flavors/1",
            "rel": "bookmark"
        }
    ],
    "name": "m1.tiny",
    "description": null
}

original_name <-> name이 달라 별도의 response 객체로 분리하였습니다

Comment on lines 4 to 7
class ServerFlavor(BaseModel):
id: str | None = Field(default=None, exclude=True)
name: str = Field(validation_alias="original_name")
model_config = ConfigDict(validate_by_name=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flavor가 Nova에 포함된 리소스긴 하지만 Server라고 접두사를 붙이지 않아도 충분히 전달이 되지 않을까 의견 드립니다.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ServerFlavor와 Flavor 속성이 달라 구분이 필요

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

실제 API 반환을 보니 구조가 달라 구분 및 공통화를 했다는점 이해했습니다.
다만 필드가 디르면 의미가 다르다고 생각이 드는데 Inner class 를 활용하면 어떨까 의견 드렸습니다 (온라인)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 제안주신 대로 inner class로 바꿨습니다 ~ 좋은 의견 감사합니다

Comment on lines +4 to +30
class Server(BaseModel):
class Flavor(BaseModel):
id: str | None = Field(default=None, exclude=True)
name: str = Field(validation_alias="original_name")
model_config = ConfigDict(validate_by_name=True)

model_config = ConfigDict(validate_by_name=True)
class Image(BaseModel):
id: str

class IPAddress(BaseModel):
addr: str
version: int
type: str = Field(validation_alias="OS-EXT-IPS:type")

class ServerSecurityGroup(BaseModel):
name: str
model_config = ConfigDict(validate_by_name=True)

class SecurityGroup(BaseModel):
name: str

class Server(BaseModel):
id: str
name: str
status: str | None = None
flavor: Flavor | None = None
image: Image | None = None
addresses: dict[str, list[ServerIp]] | None = None
addresses: dict[str, list[IPAddress]] | None = None
key_name: str | None = None
security_groups: list[ServerSecurityGroup] | None = None
security_groups: list[SecurityGroup] | None = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ❤️

Copy link
Collaborator

@halucinor halucinor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@halucinor halucinor merged commit c0d41dc into develop Aug 14, 2025
6 checks passed
platanus-kr pushed a commit that referenced this pull request Aug 16, 2025
* feat: get flavors

* fix: to inner class

* fix: format
@choieastsea choieastsea deleted the feat/flavor branch August 18, 2025 14:59
halucinor pushed a commit that referenced this pull request Aug 24, 2025
* feat: get flavors

* fix: to inner class

* fix: format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants