Skip to content

compute: add ext_specs to flavor#2561

Merged
mandre merged 1 commit intogophercloud:masterfrom
gxxxh:flavor_extra_spec
Aug 2, 2023
Merged

compute: add ext_specs to flavor#2561
mandre merged 1 commit intogophercloud:masterfrom
gxxxh:flavor_extra_spec

Conversation

@gxxxh
Copy link
Copy Markdown
Contributor

@gxxxh gxxxh commented Feb 17, 2023

Fixes #2497

Openstack API Ref:
flavor get

nova code Ref:
https://github.com/openstack/nova/blob/5c32d5efe1e1aece48b680474617113c61a248d5/nova/objects/flavor.py#L220

As there is no extra_spec in flavor create's parameter,for acceptance test, I write a test which create extra_spec for a already existed flavor, then compare the get result's extra_spec. nova create flavor code.

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for submitting your first PR! Be sure that we will be looking at it but keep in mind
this sometimes takes a while.
Please let the maintainers know if your PR has not got enough attention after a few days.
If any doubt, please consult our PR tutorial.

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 17, 2023

Coverage Status

Coverage: 80.237%. Remained the same when pulling 680a8df on gxxxh:flavor_extra_spec into 7edb0d0 on gophercloud:master.

@mandre mandre added this to the v2.0.0 milestone Feb 23, 2023
client, err := clients.NewComputeV2Client()
th.AssertNoErr(t, err)

// Microversion 2.55 is required to add extra_specs to flavor
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bad copy&paste?
The comment should say Microversion 2.61 (first micro-version to support extra_specs according to the docs)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I forget to change this, thank you for the reviewing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi, I have updated the code based on the advices, thank you for the reviewing

// pairs. This will only be included if the user is allowed by policy to
// index flavor extra_specs
// New in version 2.61
Properties map[string]string `json:"extra_specs"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't it match the json tag?

Suggested change
Properties map[string]string `json:"extra_specs"`
ExtraSpecs map[string]string `json:"extra_specs"`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeap, I am agree with you. But when I use "openstack flavor show" in the command line, the extra_specs was displayed as properties. I think properties is much easier to understand but I am not sure whether to use it

Copy link
Copy Markdown
Contributor

@EmilienM EmilienM Mar 1, 2023

Choose a reason for hiding this comment

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

We don't care about openstackclient in this case. We care about the API output and in JSON it returns:

{
  "extra_specs": {
    "hw:cpu_policy": "dedicated",
    "hw:mem_page_size": "large"
  }
}

Let's use ExtraSpecs, I agree with Martin.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi, I have updated the code based on the advices, thank you for the reviewing

@gxxxh gxxxh force-pushed the flavor_extra_spec branch from 253025b to 680a8df Compare March 2, 2023 09:34
@mandre mandre added the semver:major Breaking change label Jun 30, 2023
@pierreprinetti
Copy link
Copy Markdown
Member

@mandre Do you think we still need this, given what you pointed out in the issue?

Alternatively, you can also get the extra spec for a given flavor using the flavors.ListExtraSpecs() method.

(Sorry @gxxxh that I completely missed that one)

@spjmurray
Copy link
Copy Markdown
Contributor

I'd say it's necessary, just noticed this had been done after duplicating the effort, pretty much exactly! If you check out the conversation in #2691 the performance gains can be huge, as well as making client code cleaner, simpler and less bug prone. Just my two cents... this interface was added to OpenStack for a good reason evidently.

@mandre mandre changed the title add ext_specs to flavor compute: add ext_specs to flavor Aug 2, 2023
@mandre
Copy link
Copy Markdown
Contributor

mandre commented Aug 2, 2023

We've more or less sorted our branch management - master is now for the v2 development and can accept API breaking changes. Let's merge this!

@mandre mandre merged commit d35a80f into gophercloud:master Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver:major Breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openstack flavor show [flavorID] properties

6 participants