Merge "Adjust some proxy method names in bare_metal"
This commit is contained in:
@@ -16,6 +16,7 @@ from openstack.bare_metal.v1 import node as _node
|
|||||||
from openstack.bare_metal.v1 import port as _port
|
from openstack.bare_metal.v1 import port as _port
|
||||||
from openstack.bare_metal.v1 import port_group as _portgroup
|
from openstack.bare_metal.v1 import port_group as _portgroup
|
||||||
from openstack import proxy2
|
from openstack import proxy2
|
||||||
|
from openstack import utils
|
||||||
|
|
||||||
|
|
||||||
class Proxy(proxy2.BaseProxy):
|
class Proxy(proxy2.BaseProxy):
|
||||||
@@ -374,9 +375,50 @@ class Proxy(proxy2.BaseProxy):
|
|||||||
"""
|
"""
|
||||||
return self._delete(_port.Port, port, ignore_missing=ignore_missing)
|
return self._delete(_port.Port, port, ignore_missing=ignore_missing)
|
||||||
|
|
||||||
|
@utils.deprecated(deprecated_in="0.9.14", removed_in="1.0",
|
||||||
|
details="Use port_groups instead")
|
||||||
def portgroups(self, details=False, **query):
|
def portgroups(self, details=False, **query):
|
||||||
"""Retrieve a generator of port groups.
|
"""Retrieve a generator of port groups.
|
||||||
|
|
||||||
|
:param details: A boolean indicating whether the detailed information
|
||||||
|
for every portgroup should be returned.
|
||||||
|
:param dict query: Optional query parameters to be sent to restrict
|
||||||
|
the portgroups returned. Available parameters include:
|
||||||
|
|
||||||
|
* ``address``: Only return portgroups with the specified physical
|
||||||
|
hardware address, typically a MAC address.
|
||||||
|
* ``fields``: A list containing one or more fields to be returned
|
||||||
|
in the response. This may lead to some performance gain
|
||||||
|
because other fields of the resource are not refreshed.
|
||||||
|
* ``limit``: Requests at most the specified number of portgroups
|
||||||
|
returned from the query.
|
||||||
|
* ``marker``: Specifies the ID of the last-seen portgroup. Use the
|
||||||
|
``limit`` parameter to make an initial limited request and
|
||||||
|
use the ID of the last-seen portgroup from the response as
|
||||||
|
the ``marker`` value in a subsequent limited request.
|
||||||
|
* ``node``:only return the ones associated with this specific node
|
||||||
|
(name or UUID), or an empty set if not found.
|
||||||
|
* ``sort_dir``: Sorts the response by the requested sort direction.
|
||||||
|
A valid value is ``asc`` (ascending) or ``desc``
|
||||||
|
(descending). Default is ``asc``. You can specify multiple
|
||||||
|
pairs of sort key and sort direction query parameters. If
|
||||||
|
you omit the sort direction in a pair, the API uses the
|
||||||
|
natural sorting direction of the server attribute that is
|
||||||
|
provided as the ``sort_key``.
|
||||||
|
* ``sort_key``: Sorts the response by the this attribute value.
|
||||||
|
Default is ``id``. You can specify multiple pairs of sort
|
||||||
|
key and sort direction query parameters. If you omit the
|
||||||
|
sort direction in a pair, the API uses the natural sorting
|
||||||
|
direction of the server attribute that is provided as the
|
||||||
|
``sort_key``.
|
||||||
|
|
||||||
|
:returns: A generator of portgroup instances.
|
||||||
|
"""
|
||||||
|
return self.port_groups(details=details, **query)
|
||||||
|
|
||||||
|
def port_groups(self, details=False, **query):
|
||||||
|
"""Retrieve a generator of port groups.
|
||||||
|
|
||||||
:param details: A boolean indicating whether the detailed information
|
:param details: A boolean indicating whether the detailed information
|
||||||
for every port group should be returned.
|
for every port group should be returned.
|
||||||
:param dict query: Optional query parameters to be sent to restrict
|
:param dict query: Optional query parameters to be sent to restrict
|
||||||
@@ -414,18 +456,34 @@ class Proxy(proxy2.BaseProxy):
|
|||||||
cls = _portgroup.PortGroupDetail if details else _portgroup.PortGroup
|
cls = _portgroup.PortGroupDetail if details else _portgroup.PortGroup
|
||||||
return self._list(cls, paginated=True, **query)
|
return self._list(cls, paginated=True, **query)
|
||||||
|
|
||||||
|
@utils.deprecated(deprecated_in="0.9.14", removed_in="1.0",
|
||||||
|
details="Use create_port_group instead")
|
||||||
def create_portgroup(self, **attrs):
|
def create_portgroup(self, **attrs):
|
||||||
"""Create a new port group from attributes.
|
"""Create a new port group from attributes.
|
||||||
|
|
||||||
:param dict attrs: Keyword arguments that will be used to create a
|
:param dict attrs: Keyword arguments that will be used to create a
|
||||||
:class:`~openstack.bare_metal.v1.portgroup.PortGroup`, it
|
:class:`~openstack.bare_metal.v1.port_group.PortGroup`, it
|
||||||
comprises of the properties on the ``PortGroup`` class.
|
comprises of the properties on the ``PortGroup`` class.
|
||||||
|
|
||||||
:returns: The results of portgroup creation.
|
:returns: The results of portgroup creation.
|
||||||
:rtype: :class:`~openstack.bare_metal.v1.portgroup.PortGroup`.
|
:rtype: :class:`~openstack.bare_metal.v1.port_group.PortGroup`.
|
||||||
|
"""
|
||||||
|
return self.create_port_group(**attrs)
|
||||||
|
|
||||||
|
def create_port_group(self, **attrs):
|
||||||
|
"""Create a new portgroup from attributes.
|
||||||
|
|
||||||
|
:param dict attrs: Keyword arguments that will be used to create a
|
||||||
|
:class:`~openstack.bare_metal.v1.port_group.PortGroup`, it
|
||||||
|
comprises of the properties on the ``PortGroup`` class.
|
||||||
|
|
||||||
|
:returns: The results of portgroup creation.
|
||||||
|
:rtype: :class:`~openstack.bare_metal.v1.port_group.PortGroup`.
|
||||||
"""
|
"""
|
||||||
return self._create(_portgroup.PortGroup, **attrs)
|
return self._create(_portgroup.PortGroup, **attrs)
|
||||||
|
|
||||||
|
@utils.deprecated(deprecated_in="0.9.14", removed_in="1.0",
|
||||||
|
details="Use find_port_group instead")
|
||||||
def find_portgroup(self, name_or_id, ignore_missing=True):
|
def find_portgroup(self, name_or_id, ignore_missing=True):
|
||||||
"""Find a single port group.
|
"""Find a single port group.
|
||||||
|
|
||||||
@@ -434,17 +492,32 @@ class Proxy(proxy2.BaseProxy):
|
|||||||
:class:`~openstack.exceptions.ResourceNotFound` will be raised
|
:class:`~openstack.exceptions.ResourceNotFound` will be raised
|
||||||
when the port group does not exist. When set to `True``, None will
|
when the port group does not exist. When set to `True``, None will
|
||||||
be returned when attempting to find a nonexistent port group.
|
be returned when attempting to find a nonexistent port group.
|
||||||
:returns: One :class:`~openstack.bare_metal.v1.portgroup.PortGroup`
|
:returns: One :class:`~openstack.bare_metal.v1.port_group.PortGroup`
|
||||||
|
object or None.
|
||||||
|
"""
|
||||||
|
return self.find_port_group(name_or_id, ignore_missing=ignore_missing)
|
||||||
|
|
||||||
|
def find_port_group(self, name_or_id, ignore_missing=True):
|
||||||
|
"""Find a single port group.
|
||||||
|
|
||||||
|
:param str name_or_id: The name or ID of a portgroup.
|
||||||
|
:param bool ignore_missing: When set to ``False``, an exception of
|
||||||
|
:class:`~openstack.exceptions.ResourceNotFound` will be raised
|
||||||
|
when the port group does not exist. When set to `True``, None will
|
||||||
|
be returned when attempting to find a nonexistent port group.
|
||||||
|
:returns: One :class:`~openstack.bare_metal.v1.port_group.PortGroup`
|
||||||
object or None.
|
object or None.
|
||||||
"""
|
"""
|
||||||
return self._find(_portgroup.PortGroup, name_or_id,
|
return self._find(_portgroup.PortGroup, name_or_id,
|
||||||
ignore_missing=ignore_missing)
|
ignore_missing=ignore_missing)
|
||||||
|
|
||||||
|
@utils.deprecated(deprecated_in="0.9.14", removed_in="1.0",
|
||||||
|
details="Use get_port_group instead")
|
||||||
def get_portgroup(self, portgroup, **query):
|
def get_portgroup(self, portgroup, **query):
|
||||||
"""Get a specific port group.
|
"""Get a specific port group.
|
||||||
|
|
||||||
:param portgroup: The value can be the name or ID of a chassis or a
|
:param portgroup: The value can be the name or ID of a chassis or a
|
||||||
:class:`~openstack.bare_metal.v1.portgroup.PortGroup` instance.
|
:class:`~openstack.bare_metal.v1.port_group.PortGroup` instance.
|
||||||
:param dict query: Optional query parameters to be sent to restrict
|
:param dict query: Optional query parameters to be sent to restrict
|
||||||
the portgroup properties returned. Available parameters include:
|
the portgroup properties returned. Available parameters include:
|
||||||
|
|
||||||
@@ -452,30 +525,68 @@ class Proxy(proxy2.BaseProxy):
|
|||||||
in the response. This may lead to some performance gain
|
in the response. This may lead to some performance gain
|
||||||
because other fields of the resource are not refreshed.
|
because other fields of the resource are not refreshed.
|
||||||
|
|
||||||
:returns: One :class:`~openstack.bare_metal.v1.portgroup.PortGroup`
|
:returns: One :class:`~openstack.bare_metal.v1.port_group.PortGroup`
|
||||||
:raises: :class:`~openstack.exceptions.ResourceNotFound` when no
|
:raises: :class:`~openstack.exceptions.ResourceNotFound` when no
|
||||||
port group matching the name or ID could be found.
|
port group matching the name or ID could be found.
|
||||||
"""
|
"""
|
||||||
return self._get(_portgroup.PortGroup, portgroup, **query)
|
return self.get_port_group(portgroup, **query)
|
||||||
|
|
||||||
|
def get_port_group(self, port_group, **query):
|
||||||
|
"""Get a specific port group.
|
||||||
|
|
||||||
|
:param port_group: The value can be the name or ID of a chassis or a
|
||||||
|
:class:`~openstack.bare_metal.v1.port_group.PortGroup` instance.
|
||||||
|
:param dict query: Optional query parameters to be sent to restrict
|
||||||
|
the port group properties returned. Available parameters include:
|
||||||
|
|
||||||
|
* ``fields``: A list containing one or more fields to be returned
|
||||||
|
in the response. This may lead to some performance gain
|
||||||
|
because other fields of the resource are not refreshed.
|
||||||
|
|
||||||
|
:returns: One :class:`~openstack.bare_metal.v1.port_group.PortGroup`
|
||||||
|
:raises: :class:`~openstack.exceptions.ResourceNotFound` when no
|
||||||
|
port group matching the name or ID could be found.
|
||||||
|
"""
|
||||||
|
return self._get(_portgroup.PortGroup, port_group, **query)
|
||||||
|
|
||||||
|
@utils.deprecated(deprecated_in="0.9.14", removed_in="1.0",
|
||||||
|
details="Use update_port_group instead")
|
||||||
def update_portgroup(self, portgroup, **attrs):
|
def update_portgroup(self, portgroup, **attrs):
|
||||||
"""Update a port group.
|
"""Update a port group.
|
||||||
|
|
||||||
:param chassis: Either the name or the ID of a portgroup or an instance
|
:param chassis: Either the name or the ID of a port group or
|
||||||
of :class:`~openstack.bare_metal.v1.portgroup.PortGroup`.
|
an instance of
|
||||||
|
:class:`~openstack.bare_metal.v1.port_group.PortGroup`.
|
||||||
:param dict attrs: The attributes to update on the port group
|
:param dict attrs: The attributes to update on the port group
|
||||||
represented by the ``portgroup`` parameter.
|
represented by the ``portgroup`` parameter.
|
||||||
|
|
||||||
:returns: The updated port group.
|
:returns: The updated port group.
|
||||||
:rtype: :class:`~openstack.bare_metal.v1.portgroup.PortGroup`
|
:rtype: :class:`~openstack.bare_metal.v1.port_group.PortGroup`
|
||||||
"""
|
"""
|
||||||
return self._update(_portgroup.PortGroup, portgroup, **attrs)
|
return self.update_port_group(portgroup, **attrs)
|
||||||
|
|
||||||
|
def update_port_group(self, port_group, **attrs):
|
||||||
|
"""Update a port group.
|
||||||
|
|
||||||
|
:param chassis: Either the name or the ID of a port group or
|
||||||
|
an instance of
|
||||||
|
:class:`~openstack.bare_metal.v1.port_group.PortGroup`.
|
||||||
|
:param dict attrs: The attributes to update on the port group
|
||||||
|
represented by the ``port_group`` parameter.
|
||||||
|
|
||||||
|
:returns: The updated port group.
|
||||||
|
:rtype: :class:`~openstack.bare_metal.v1.port_group.PortGroup`
|
||||||
|
"""
|
||||||
|
return self._update(_portgroup.PortGroup, port_group, **attrs)
|
||||||
|
|
||||||
|
@utils.deprecated(deprecated_in="0.9.14", removed_in="1.0",
|
||||||
|
details="Use delete_port_group instead")
|
||||||
def delete_portgroup(self, portgroup, ignore_missing=True):
|
def delete_portgroup(self, portgroup, ignore_missing=True):
|
||||||
"""Delete a port group.
|
"""Delete a port group.
|
||||||
|
|
||||||
:param portgroup: The value can be either the name or ID of a portgroup
|
:param portgroup: The value can be either the name or ID of a port
|
||||||
or a :class:`~openstack.bare_metal.v1.portgroup.PortGroup`
|
group or a
|
||||||
|
:class:`~openstack.bare_metal.v1.port_group.PortGroup`
|
||||||
instance.
|
instance.
|
||||||
:param bool ignore_missing: When set to ``False``, an exception
|
:param bool ignore_missing: When set to ``False``, an exception
|
||||||
:class:`~openstack.exceptions.ResourceNotFound` will be raised
|
:class:`~openstack.exceptions.ResourceNotFound` will be raised
|
||||||
@@ -484,7 +595,25 @@ class Proxy(proxy2.BaseProxy):
|
|||||||
port group.
|
port group.
|
||||||
|
|
||||||
:returns: The instance of the port group which was deleted.
|
:returns: The instance of the port group which was deleted.
|
||||||
:rtype: :class:`~openstack.bare_metal.v1.portgroup.PortGroup`.
|
:rtype: :class:`~openstack.bare_metal.v1.port_group.PortGroup`.
|
||||||
"""
|
"""
|
||||||
return self._delete(_portgroup.PortGroup, portgroup,
|
return self.delete_port_group(portgroup, ignore_missing=ignore_missing)
|
||||||
|
|
||||||
|
def delete_port_group(self, port_group, ignore_missing=True):
|
||||||
|
"""Delete a port group.
|
||||||
|
|
||||||
|
:param port_group: The value can be either the name or ID of
|
||||||
|
a port group or a
|
||||||
|
:class:`~openstack.bare_metal.v1.port_group.PortGroup`
|
||||||
|
instance.
|
||||||
|
:param bool ignore_missing: When set to ``False``, an exception
|
||||||
|
:class:`~openstack.exceptions.ResourceNotFound` will be raised
|
||||||
|
when the port group could not be found. When set to ``True``, no
|
||||||
|
exception will be raised when attempting to delete a non-existent
|
||||||
|
port group.
|
||||||
|
|
||||||
|
:returns: The instance of the port group which was deleted.
|
||||||
|
:rtype: :class:`~openstack.bare_metal.v1.port_group.PortGroup`.
|
||||||
|
"""
|
||||||
|
return self._delete(_portgroup.PortGroup, port_group,
|
||||||
ignore_missing=ignore_missing)
|
ignore_missing=ignore_missing)
|
||||||
|
@@ -10,6 +10,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import deprecation
|
||||||
|
|
||||||
from openstack.bare_metal.v1 import _proxy
|
from openstack.bare_metal.v1 import _proxy
|
||||||
from openstack.bare_metal.v1 import chassis
|
from openstack.bare_metal.v1 import chassis
|
||||||
from openstack.bare_metal.v1 import driver
|
from openstack.bare_metal.v1 import driver
|
||||||
@@ -121,34 +123,42 @@ class TestBareMetalProxy(test_proxy_base2.TestProxyBase):
|
|||||||
def test_delete_port_ignore(self):
|
def test_delete_port_ignore(self):
|
||||||
self.verify_delete(self.proxy.delete_port, port.Port, True)
|
self.verify_delete(self.proxy.delete_port, port.Port, True)
|
||||||
|
|
||||||
|
@deprecation.fail_if_not_removed
|
||||||
def test_portgroups_detailed(self):
|
def test_portgroups_detailed(self):
|
||||||
self.verify_list(self.proxy.portgroups, port_group.PortGroupDetail,
|
self.verify_list(self.proxy.portgroups, port_group.PortGroupDetail,
|
||||||
paginated=True,
|
paginated=True,
|
||||||
method_kwargs={"details": True, "query": 1},
|
method_kwargs={"details": True, "query": 1},
|
||||||
expected_kwargs={"query": 1})
|
expected_kwargs={"query": 1})
|
||||||
|
|
||||||
|
@deprecation.fail_if_not_removed
|
||||||
def test_portgroups_not_detailed(self):
|
def test_portgroups_not_detailed(self):
|
||||||
self.verify_list(self.proxy.portgroups, port_group.PortGroup,
|
self.verify_list(self.proxy.portgroups, port_group.PortGroup,
|
||||||
paginated=True,
|
paginated=True,
|
||||||
method_kwargs={"details": False, "query": 1},
|
method_kwargs={"details": False, "query": 1},
|
||||||
expected_kwargs={"query": 1})
|
expected_kwargs={"query": 1})
|
||||||
|
|
||||||
|
@deprecation.fail_if_not_removed
|
||||||
def test_create_portgroup(self):
|
def test_create_portgroup(self):
|
||||||
self.verify_create(self.proxy.create_portgroup, port_group.PortGroup)
|
self.verify_create(self.proxy.create_portgroup, port_group.PortGroup)
|
||||||
|
|
||||||
|
@deprecation.fail_if_not_removed
|
||||||
def test_find_portgroup(self):
|
def test_find_portgroup(self):
|
||||||
self.verify_find(self.proxy.find_portgroup, port_group.PortGroup)
|
self.verify_find(self.proxy.find_portgroup, port_group.PortGroup)
|
||||||
|
|
||||||
|
@deprecation.fail_if_not_removed
|
||||||
def test_get_portgroup(self):
|
def test_get_portgroup(self):
|
||||||
self.verify_get(self.proxy.get_portgroup, port_group.PortGroup)
|
self.verify_get(self.proxy.get_portgroup, port_group.PortGroup)
|
||||||
|
|
||||||
|
@deprecation.fail_if_not_removed
|
||||||
def test_update_portgroup(self):
|
def test_update_portgroup(self):
|
||||||
self.verify_update(self.proxy.update_portgroup, port_group.PortGroup)
|
self.verify_update(self.proxy.update_portgroup, port_group.PortGroup)
|
||||||
|
|
||||||
|
@deprecation.fail_if_not_removed
|
||||||
def test_delete_portgroup(self):
|
def test_delete_portgroup(self):
|
||||||
self.verify_delete(self.proxy.delete_portgroup, port_group.PortGroup,
|
self.verify_delete(self.proxy.delete_portgroup, port_group.PortGroup,
|
||||||
False)
|
False)
|
||||||
|
|
||||||
|
@deprecation.fail_if_not_removed
|
||||||
def test_delete_portgroup_ignore(self):
|
def test_delete_portgroup_ignore(self):
|
||||||
self.verify_delete(self.proxy.delete_portgroup, port_group.PortGroup,
|
self.verify_delete(self.proxy.delete_portgroup, port_group.PortGroup,
|
||||||
True)
|
True)
|
||||||
|
Reference in New Issue
Block a user