@@ -1609,122 +1609,49 @@ def create_one_server_migration(attrs=None, methods=None):
16091609 return migration
16101610
16111611
1612- class FakeVolumeAttachment ( object ):
1613- """Fake one or more volume attachments (BDMs)."""
1612+ def create_one_volume_attachment ( attrs = None ):
1613+ """Create a fake volume attachment.
16141614
1615- @staticmethod
1616- def create_one_volume_attachment (attrs = None , methods = None ):
1617- """Create a fake volume attachment.
1618-
1619- :param dict attrs:
1620- A dictionary with all attributes
1621- :param dict methods:
1622- A dictionary with all methods
1623- :return:
1624- A FakeResource object, with id, device, and so on
1625- """
1626- attrs = attrs or {}
1627- methods = methods or {}
1628-
1629- # Set default attributes.
1630- volume_attachment_info = {
1631- "id" : uuid .uuid4 ().hex ,
1632- "device" : "/dev/sdb" ,
1633- "serverId" : uuid .uuid4 ().hex ,
1634- "volumeId" : uuid .uuid4 ().hex ,
1635- # introduced in API microversion 2.70
1636- "tag" : "foo" ,
1637- # introduced in API microversion 2.79
1638- "delete_on_termination" : True ,
1639- # introduced in API microversion 2.89
1640- "attachment_id" : uuid .uuid4 ().hex ,
1641- "bdm_uuid" : uuid .uuid4 ().hex
1642- }
1643-
1644- # Overwrite default attributes.
1645- volume_attachment_info .update (attrs )
1646-
1647- volume_attachment = fakes .FakeResource (
1648- info = copy .deepcopy (volume_attachment_info ),
1649- methods = methods ,
1650- loaded = True )
1651- return volume_attachment
1652-
1653- @staticmethod
1654- def create_volume_attachments (attrs = None , methods = None , count = 2 ):
1655- """Create multiple fake volume attachments (BDMs).
1656-
1657- :param dict attrs:
1658- A dictionary with all attributes
1659- :param dict methods:
1660- A dictionary with all methods
1661- :param int count:
1662- The number of volume attachments to fake
1663- :return:
1664- A list of FakeResource objects faking the volume attachments.
1665- """
1666- volume_attachments = []
1667- for i in range (0 , count ):
1668- volume_attachments .append (
1669- FakeVolumeAttachment .create_one_volume_attachment (
1670- attrs , methods ))
1671-
1672- return volume_attachments
1673-
1674- @staticmethod
1675- def create_one_sdk_volume_attachment (attrs = None , methods = None ):
1676- """Create a fake sdk VolumeAttachment.
1615+ :param dict attrs: A dictionary with all attributes
1616+ :return: A fake openstack.compute.v2.volume_attachment.VolumeAttachment
1617+ object
1618+ """
1619+ attrs = attrs or {}
16771620
1678- :param dict attrs:
1679- A dictionary with all attributes
1680- :param dict methods:
1681- A dictionary with all methods
1682- :return:
1683- A fake VolumeAttachment object, with id, device, and so on
1684- """
1685- attrs = attrs or {}
1686- methods = methods or {}
1621+ # Set default attributes.
1622+ volume_attachment_info = {
1623+ "id" : uuid .uuid4 ().hex ,
1624+ "device" : "/dev/sdb" ,
1625+ "server_id" : uuid .uuid4 ().hex ,
1626+ "volume_id" : uuid .uuid4 ().hex ,
1627+ # introduced in API microversion 2.70
1628+ "tag" : "foo" ,
1629+ # introduced in API microversion 2.79
1630+ "delete_on_termination" : True ,
1631+ # introduced in API microversion 2.89
1632+ "attachment_id" : uuid .uuid4 ().hex ,
1633+ "bdm_id" : uuid .uuid4 ().hex ,
1634+ }
16871635
1688- # Set default attributes.
1689- volume_attachment_info = {
1690- "id" : uuid .uuid4 ().hex ,
1691- "device" : "/dev/sdb" ,
1692- "server_id" : uuid .uuid4 ().hex ,
1693- "volume_id" : uuid .uuid4 ().hex ,
1694- # introduced in API microversion 2.70
1695- "tag" : "foo" ,
1696- # introduced in API microversion 2.79
1697- "delete_on_termination" : True ,
1698- # introduced in API microversion 2.89
1699- "attachment_id" : uuid .uuid4 ().hex ,
1700- "bdm_uuid" : uuid .uuid4 ().hex
1701- }
1636+ # Overwrite default attributes.
1637+ volume_attachment_info .update (attrs )
17021638
1703- # Overwrite default attributes.
1704- volume_attachment_info .update (attrs )
1639+ return volume_attachment .VolumeAttachment (** volume_attachment_info )
17051640
1706- return volume_attachment .VolumeAttachment (** volume_attachment_info )
17071641
1708- @staticmethod
1709- def create_sdk_volume_attachments (attrs = None , methods = None , count = 2 ):
1710- """Create multiple fake VolumeAttachment objects (BDMs).
1642+ def create_volume_attachments (attrs = None , count = 2 ):
1643+ """Create multiple fake volume attachments.
17111644
1712- :param dict attrs:
1713- A dictionary with all attributes
1714- :param dict methods:
1715- A dictionary with all methods
1716- :param int count:
1717- The number of volume attachments to fake
1718- :return:
1719- A list of VolumeAttachment objects faking the volume attachments.
1720- """
1721- volume_attachments = []
1722- for i in range (0 , count ):
1723- volume_attachments .append (
1724- FakeVolumeAttachment .create_one_sdk_volume_attachment (
1725- attrs , methods ))
1645+ :param dict attrs: A dictionary with all attributes
1646+ :param int count: The number of volume attachments to fake
1647+ :return: A list of fake
1648+ openstack.compute.v2.volume_attachment.VolumeAttachment objects
1649+ """
1650+ volume_attachments = []
1651+ for i in range (0 , count ):
1652+ volume_attachments .append (create_one_volume_attachment (attrs ))
17261653
1727- return volume_attachments
1654+ return volume_attachments
17281655
17291656
17301657def create_one_hypervisor (attrs = None ):
0 commit comments