[
https://issues.apache.org/jira/browse/LIBCLOUD-704?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Hiroshi Yoshikawa updated LIBCLOUD-704:
---------------------------------------
Description:
When I tested *ex_list_projects()* method in cloudstack compute driver, I
encountered an error shown below:
{quote}
{noformat}
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'
{noformat}
{quote}
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 a source 'site-packages/libcloud/compute/drivers/cloudstack.py' in
order to treat 'Unlimited' as -1. Then the error disappeared.
{code:title=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
"""
<< snipped >>
'project': {
'account': {'key_name': 'account', 'transform_func': str},
'cpuavailable': {'key_name': 'cpuavailable', 'transform_func':
ex_cs_int},
..........
{code}
was:
When I tested *ex_list_projects()* method in cloudstack compute driver, I
encountered an error shown below:
{quote}
{noformat}
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'
{noformat}
{quote}
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 a source 'site-packages/libcloud/compute/drivers/cloudstack.py' in
order to treat 'Unlimited' as -1. Then the error disappeared.
{code:title=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 = {
'network': {
<< snipped >>
'project': {
'account': {'key_name': 'account', 'transform_func': str},
'cpuavailable': {'key_name': 'cpuavailable', 'transform_func':
ex_cs_int},
..........
{code}
> 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, I
> encountered an error shown below:
> {quote}
> {noformat}
> 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'
> {noformat}
> {quote}
> 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 a source 'site-packages/libcloud/compute/drivers/cloudstack.py' in
> order to treat 'Unlimited' as -1. Then the error disappeared.
> {code:title=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
> """
> << 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)