Cannot create a loadbalance healthmonitor by openstack sdk

Bug #1711546 reported by TingtingYu
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack SDK
Fix Released
Undecided
Unassigned

Bug Description

I can't create a loadbalance healthmonitor with a pool id by openstack sdk.There is an error with the message "Failed to parse request. Required attribute 'pool_id' not specified"
The openstacksdk version is 0.9.17
This is my test case:
test_sdk.py

from openstack import connection
from openstack import profile

def create_connection(auth_url, region, project_name, username, password):
    prof = profile.Profile()
    prof.set_region(profile.Profile.ALL, region)

    return connection.Connection(
        profile=prof,
        user_agent='senlin',
        auth_url=auth_url,
        project_name=project_name,
        username=username,
        password=password
    )
def healthmonitor_create(conn):
    kwargs = {
             'type': 'HTTP',
             'delay': 20,
             'timeout': 5,
             'max_retries': 3,
             #'pools': [{'id': 'e84f5634-d721-491f-873f-0c04f6260510'}],
             'pool_id': 'e84f5634-d721-491f-873f-0c04f6260510',
             'admin_state_up': True,
             'http_method': 'GET',
             'url_path': '/health',
             'expected_codes': '200',
            }
    try:
       res = conn.network.create_health_monitor(**kwargs)
       print "create health"
    except Exception as e:
       print e
conn = create_connection('http://192.168.6.71:5000/v2.0','','admin','admin','pass')

[root@vs-controller env(keystone)]$ python test_sdk.py
HttpException: Bad Request (HTTP 400) (Request-ID: req-b57adb0f-2aa6-49b4-bd6f-d18e9d7e9708), Failed to parse request. Required attribute 'pool_id' not specified

Then I change the 'pool_id': 'e84f5634-d721-491f-873f-0c04f6260510' to 'pools': [{'id': 'e84f5634-d721-491f-873f-0c04f6260510'}], there is also the same error.

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

Neither pools nor pool_id are documented in the HealthMonitor resource: https://developer.openstack.org/sdks/python/openstacksdk/users/resources/network/v2/health_monitor.html#openstack.network.v2.health_monitor.HealthMonitor

You can't just add arbitrary fields, so you changing your code isn't changing what's sent. It seems like the resource just needs to be switch the pool_ids field to be singular pool_id and only accept one value.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-openstacksdk (master)

Reviewed: https://review.openstack.org/495135
Committed: https://git.openstack.org/cgit/openstack/python-openstacksdk/commit/?id=a045f9741fa3068d7eaac17b903bca676f69e240
Submitter: Jenkins
Branch: master

commit a045f9741fa3068d7eaac17b903bca676f69e240
Author: TingtingYu <yu_qearl@163.com>
Date: Fri Aug 18 17:26:05 2017 +0800

    Add required pool_id property to HealthMonitor

    When I create a healthmonitor with a pool id by openstack sdk, there is an
    error with the message "Failed to parse request. Required attribute
    'pool_id' not specified", Then I find the code has no the parameter that
    "pool_id".

    I modify the healthmonitor class, I add a new line pool_id =
    resource.Body('pool_id'), then successfully create a healthmonitor.

    Change-Id: I95901152849341862333f1b3694c6265c43879ce
    Closes-Bug: 1711546

Changed in python-openstacksdk:
status: New → Fix Released
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.