[ https://issues.apache.org/jira/browse/LIBCLOUD-704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15299958#comment-15299958
]
Stefan Friesel commented on LIBCLOUD-704:
-----------------------------------------
this was fixed a year ago: https://github.com/apache/libcloud/pull/512
> CloudStack's drvier does not consider 'Unlimited'.
> --------------------------------------------------
>
> Key: LIBCLOUD-704
> URL: https://issues.apache.org/jira/browse/LIBCLOUD-704
> Project: Libcloud
> Issue Type: Bug
> Components: Compute
> Environment: CloudStack 4.3.0.2
> Reporter: Hiroshi Yoshikawa
>
> When I tested *ex_list_projects()* method in cloudstack compute driver:
> {code:title=Test program 'libcloudtest.py'|borderStyle=solid}
> from libcloud.compute.types import Provider
> from libcloud.compute.providers import get_driver
> ACCESS_ID = 'XXXXXXXXXXXXXXXXXXXXXX'
> SECRET_KEY = 'XXXXXXXXXXXXXXXXXXXXXX'
> PROJECTID = 'XXXXXXXXXXXXXXXXXXXX'
> ENDPOINTURL = 'https://<our cloudstack url>/client/api'
> cls = get_driver(Provider.CLOUDSTACK)
> driver = cls(key=ACCESS_ID, secret=SECRET_KEY, secure=True, url=ENDPOINTURL)
> projs = driver.ex_list_projects()
> {code}
> I encountered an error shown below:
> {code:title=Error Message}
> Traceback (most recent call last):
> File "libcloudtest.py", line 11, in <module>
> projs = driver.ex_list_projects()
> File "/usr/lib/python2.7/site-packages/libcloud/compute/drivers/cloudstack.py", line
1652, in ex_list_projects
> extra = self._get_extra_dict(proj, extra_map)
> File "/usr/lib/python2.7/site-packages/libcloud/compute/drivers/cloudstack.py", line
3350, in _get_extra_dict
> extra[attribute] = transform_func(value)
> ValueError: invalid literal for int() with base 10: 'Unlimited'
> {code}
> According to a source file *site-packages/libcloud/compute/drivers/cloudstack.py*,
> the *ex_list_projects()* receives strings from CloudStack and converts it into integers
with buit-in function *int()*. The built-in function *int()* can only accept strings which
represent integers (_e.g. '3', '-1'_). However CloudStack may return a string *'Unlimited'*,
which *int()* can not deal with.
> I modified the source file in order to treat _'Unlimited'_ as _-1_, then the error disappeared.
> {code:title=Modify 'cloudstack.py'|borderStyle=solid}
> def ex_cs_int(z):
> if z == 'Unlimited':
> _val = -1
> else:
> _val = int(z)
> return _val
> """
> Define the extra dictionary for specific resources
> """
> RESOURCE_EXTRA_ATTRIBUTES_MAP = {
> << snipped >>
> 'project': {
> 'account': {'key_name': 'account', 'transform_func': str},
> 'cpuavailable': {'key_name': 'cpuavailable', 'transform_func': ex_cs_int},
> ..........
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
|