def test_security_groups(os_conn):
query = {
"limit": 2
}
objs = os_conn.vpcv1.security_groups(**query)
objs = list(objs)
for obj in objs:
print(obj)
设置limit为2, 但是返回了所有的security groups, limit不起作用,
只有修改sdk中v1/_proxy.py 将self._list(_security_group.SecurityGroup, paginated=True,
**query)改为self._list(_security_group.SecurityGroup, paginated=False,
**query)
sdk 函数如下:
def security_groups(self, **query):
"""Return a generator of security groups
:param dict query: Optional query parameters to be sent to limit
the resources being returned. Valid parameters are:
limit: The number of records returned on each page.
marker: The resource ID of pagination query.
vpc_id: The ID of the VPC this security group is
associated with.
enterprise_project_id: The ID of the enterprise project.
:returns: A generator of security group objects
:rtype: :class:~openstack.vpc.v1.security_group.SecurityGroup
"""
return self._list(_security_group.
sdk中是将 paginated=True, 但是效果并没有按照每次返回一个page,而是全部返回了,paginated=False, 反而能够按page返回