GitHub user InAnimaTe opened a pull request:

    https://github.com/apache/libcloud/pull/899

    Better Error Message on Fieldnames; Add start_container

    ## Changes Title (replace this with a logical title for your changes)
    
    ### Description
    
    This PR extends the Rancher Driver to add `start_container` support. It 
follows the base class so providing a container object is necessary (and you 
get one back as expected).
    
    Additionally, I ran into an a scenario where fields which caused errors 
would return something like:
    
    ```
    In [12]: driver.ex_deploy_service(name='empty_test', image=image, 
environment_id="", service_description="testing", 
environment={"ohnoes":"maybe"})
    ---------------------------------------------------------------------------
    BaseHTTPError                             Traceback (most recent call last)
    <ipython-input-12-e9850d5a4dbf> in <module>()
    ----> 1 driver.ex_deploy_service(name='empty_test', image=image, 
environment_id="", service_description="testing", 
environment={"ohnoes":"maybe"})
    /home/mloria/arrovenv/libcloud/libcloud/container/drivers/rancher.py in 
ex_deploy_service(self, name, image, environment_id, start, 
assign_service_ip_address, service_description, external_i
    d, metadata, retain_ip, scale, scale_policy, secondary_launch_configs, 
selector_container, selector_link, vip, **launch_conf)
        394         data = json.dumps(dict((k, v) for (k, v) in 
service_payload.items()
        395                                if v is not None))
    --> 396         result = self.connection.request('%s/services' % 
self.baseuri,
        397                                          data=data, 
method='POST').object
        398
    /home/mloria/arrovenv/libcloud/libcloud/common/base.py in request(self, 
action, params, data, headers, method, raw)
        860
        861         try:
    --> 862             response = responseCls(**kwargs)
        863         finally:
        864             # Always reset the context after the request has 
completed
    /home/mloria/arrovenv/libcloud/libcloud/common/base.py in __init__(self, 
response, connection)
        177             raise exception_from_message(code=self.status,
        178                                          message=self.parse_error(),
    --> 179                                          headers=self.headers)
        180
        181         self.object = self.parse_body()
    
    BaseHTTPError: None - None
    ```
    
    So I edited `parse_error` to check for this and print something a bit nicer:
    
    ```
    BaseHTTPError: name is NotUnique: None - None
    ```
    
    ### Status
    
    - done, ready for review
    
    ### Checklist (tick everything that applies)
    
    - [x] [Code 
linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide)
 (required, can be done after the PR checks)
    - [x] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html)


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ArroyoNetworks/libcloud rancher_error_fix

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/libcloud/pull/899.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #899
    
----

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to