device_owner in openstack.network.v2.port.Port incorrect after creating instance

Bug #1633203 reported by Vinicius G Ferreira
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack SDK
New
Undecided
Unassigned

Bug Description

After wasting about 1h on chasing a problem, I noticed the cause was the openstack.network.v2.port.Port object had an incorrect value for the device_owner attribute after creating an instance. I was expecting it to have the value 'compute:nova' (which is shown when we create the instance using the Horizon console), but the actual value when we use the Unified SDK is 'compute:None'.

Here is a minimal example that demonstrates the issue:

----------

from openstack import connection
import json
import os

def get_connection_to_services(auth_url, username, password, user_domain_name, project_name, project_domain_name):
    conn = connection.Connection(
        auth_url=auth_url,
        project_name=project_name,
        project_domain_name=project_domain_name,
        username=username,
        user_domain_name=user_domain_name,
        password=password)
    return conn

inputfile = my_credentials_file

with open(inputfile) as json_file:
    json_string = json_file.read()
    json_obj = json.loads(json_string)

username = json_obj["username"]
password = json_obj["password"]
auth_url_sdk = json_obj["auth_url_sdk"]
user_domain_name = json_obj["user_domain_name"]
project_domain_name = json_obj["project_domain_name"]
project_name = json_obj["project_name"]

conn = get_connection_to_services(
       auth_url=auth_url_sdk,
       project_name=project_name,
       project_domain_name=project_domain_name,
       username=username,
       user_domain_name=user_domain_name,
       password=password)
compute_service = conn.compute
network_service = conn.network
image_service = conn.image
block_service = conn.block_store

# Network is using the id for 'private' and imageRef the id for 'Cirros'
compute_service.create_server(
name="Teste",
flavor_id=1,
networks=[{'uuid': '9ffae962-0287-44d5-ad2f-e692b180d369', 'fixed_ip': '10.0.0.88'}],
security_groups=[{'name': 'default'}],
imageRef='48c05e01-63a1-483c-a4de-3a256034b89a'
)

for i in network_service.ports():
    if i['device_owner'] == 'compute:None':
        print i

Tags: network
Revision history for this message
Brian Curtin (brian.curtin) wrote :

We just take the JSON that comes back in the device_owner field, so that's what the server is giving us.

Revision history for this message
Vinicius G Ferreira (vini-g-fer) wrote :

Indeed, that value is being recorded in the database, as this query shows:

mysql> select device_owner from neutron.ports;
+------------------------+
| device_owner |
+------------------------+
| network:floatingip |
| network:floatingip |
| network:router_gateway |
| compute:None |
| compute:nova |
| network:dhcp |
| network:router_interface |
| network:router_interface |
+------------------------+
8 rows in set (0.00 sec)

However I don't understand why Horizon is recording a correct value, and the SDK/API is not. I also tested the CLI, and the same problem occurs.

Richard Theis (rtheis)
tags: added: network
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.