Oshin aggrawal
Oshin aggrawal

Reputation: 79

Create a flavour with openstack SDK

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

Upvotes: 0

Views: 273

Answers (1)

Rockcat
Rockcat

Reputation: 3240

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)

Upvotes: 1

Related Questions