0

I have a heat template yaml file for creating a flavor named "flavor_one" on compute node placed at specific path /opt/config/template.yml

How can I create a flavor with the template file with openstack SDK in python. I tried with the below. But failed:

 image = conn.create_flavor(
                    filename='/opt/config/template.yml' + flavor_one,
                    wait=True)

Any help ? I am a novice at openstack SDK. I have successfully established a connection with clouds.yaml file

  • 2
    Perhaps I am missing something, but as far as I can see, `create_flavor` [takes a single argument](https://docs.openstack.org/openstacksdk/latest/user/proxies/compute.html#flavor-operations), namely a dictionary of flavor properties. I also believe that you need to call it as `conn.compute.create_flavor`. – berndbausch Aug 06 '21 at 11:13
  • I can't find any property for passing `template` file from its [source code](https://github.com/openstack/openstacksdk/blob/master/openstack/compute/v2/flavor.py#L38), so it might be unsupported now. – Corey Aug 07 '21 at 00:24
  • Check this : openstack.compute.v2.flavor https://docs.openstack.org/openstacksdk/latest/user/resources/compute/v2/flavor.html#openstack.compute.v2.flavor.Flavor – Victor Lee Aug 07 '21 at 08:02

1 Answers1

1

You can use the create_flavor method...

import json, openstack

try:    
  os_connect = openstack.connect(
       auth_url="https://controller:5000/v3/",
       project_name="admin", username="admin",
       password="secretPassword",
       region_name="RegionOne",
       user_domain_name="Default",
       project_domain_name="default",
       app_version='1.0')

  # Change name, ram, vcpus, disk to your favourite values
  os_connect.create_flavor(name, ram, vcpus, disk, flavorid='auto', ephemeral=0, swap=0, rxtx_factor=1.0, is_public=True)
Rockcat
  • 3,002
  • 2
  • 14
  • 28