@@ -1553,122 +1553,49 @@ def create_one_server_migration(attrs=None, methods=None):
15531553 return migration
15541554
15551555
1556- class FakeVolumeAttachment ( object ):
1557- """Fake one or more volume attachments (BDMs)."""
1556+ def create_one_volume_attachment ( attrs = None ):
1557+ """Create a fake volume attachment.
15581558
1559- @staticmethod
1560- def create_one_volume_attachment (attrs = None , methods = None ):
1561- """Create a fake volume attachment.
1562-
1563- :param dict attrs:
1564- A dictionary with all attributes
1565- :param dict methods:
1566- A dictionary with all methods
1567- :return:
1568- A FakeResource object, with id, device, and so on
1569- """
1570- attrs = attrs or {}
1571- methods = methods or {}
1572-
1573- # Set default attributes.
1574- volume_attachment_info = {
1575- "id" : uuid .uuid4 ().hex ,
1576- "device" : "/dev/sdb" ,
1577- "serverId" : uuid .uuid4 ().hex ,
1578- "volumeId" : uuid .uuid4 ().hex ,
1579- # introduced in API microversion 2.70
1580- "tag" : "foo" ,
1581- # introduced in API microversion 2.79
1582- "delete_on_termination" : True ,
1583- # introduced in API microversion 2.89
1584- "attachment_id" : uuid .uuid4 ().hex ,
1585- "bdm_uuid" : uuid .uuid4 ().hex
1586- }
1587-
1588- # Overwrite default attributes.
1589- volume_attachment_info .update (attrs )
1590-
1591- volume_attachment = fakes .FakeResource (
1592- info = copy .deepcopy (volume_attachment_info ),
1593- methods = methods ,
1594- loaded = True )
1595- return volume_attachment
1596-
1597- @staticmethod
1598- def create_volume_attachments (attrs = None , methods = None , count = 2 ):
1599- """Create multiple fake volume attachments (BDMs).
1600-
1601- :param dict attrs:
1602- A dictionary with all attributes
1603- :param dict methods:
1604- A dictionary with all methods
1605- :param int count:
1606- The number of volume attachments to fake
1607- :return:
1608- A list of FakeResource objects faking the volume attachments.
1609- """
1610- volume_attachments = []
1611- for i in range (0 , count ):
1612- volume_attachments .append (
1613- FakeVolumeAttachment .create_one_volume_attachment (
1614- attrs , methods ))
1615-
1616- return volume_attachments
1617-
1618- @staticmethod
1619- def create_one_sdk_volume_attachment (attrs = None , methods = None ):
1620- """Create a fake sdk VolumeAttachment.
1559+ :param dict attrs: A dictionary with all attributes
1560+ :return: A fake openstack.compute.v2.volume_attachment.VolumeAttachment
1561+ object
1562+ """
1563+ attrs = attrs or {}
16211564
1622- :param dict attrs:
1623- A dictionary with all attributes
1624- :param dict methods:
1625- A dictionary with all methods
1626- :return:
1627- A fake VolumeAttachment object, with id, device, and so on
1628- """
1629- attrs = attrs or {}
1630- methods = methods or {}
1565+ # Set default attributes.
1566+ volume_attachment_info = {
1567+ "id" : uuid .uuid4 ().hex ,
1568+ "device" : "/dev/sdb" ,
1569+ "server_id" : uuid .uuid4 ().hex ,
1570+ "volume_id" : uuid .uuid4 ().hex ,
1571+ # introduced in API microversion 2.70
1572+ "tag" : "foo" ,
1573+ # introduced in API microversion 2.79
1574+ "delete_on_termination" : True ,
1575+ # introduced in API microversion 2.89
1576+ "attachment_id" : uuid .uuid4 ().hex ,
1577+ "bdm_id" : uuid .uuid4 ().hex ,
1578+ }
16311579
1632- # Set default attributes.
1633- volume_attachment_info = {
1634- "id" : uuid .uuid4 ().hex ,
1635- "device" : "/dev/sdb" ,
1636- "server_id" : uuid .uuid4 ().hex ,
1637- "volume_id" : uuid .uuid4 ().hex ,
1638- # introduced in API microversion 2.70
1639- "tag" : "foo" ,
1640- # introduced in API microversion 2.79
1641- "delete_on_termination" : True ,
1642- # introduced in API microversion 2.89
1643- "attachment_id" : uuid .uuid4 ().hex ,
1644- "bdm_uuid" : uuid .uuid4 ().hex
1645- }
1580+ # Overwrite default attributes.
1581+ volume_attachment_info .update (attrs )
16461582
1647- # Overwrite default attributes.
1648- volume_attachment_info .update (attrs )
1583+ return volume_attachment .VolumeAttachment (** volume_attachment_info )
16491584
1650- return volume_attachment .VolumeAttachment (** volume_attachment_info )
16511585
1652- @staticmethod
1653- def create_sdk_volume_attachments (attrs = None , methods = None , count = 2 ):
1654- """Create multiple fake VolumeAttachment objects (BDMs).
1586+ def create_volume_attachments (attrs = None , count = 2 ):
1587+ """Create multiple fake volume attachments.
16551588
1656- :param dict attrs:
1657- A dictionary with all attributes
1658- :param dict methods:
1659- A dictionary with all methods
1660- :param int count:
1661- The number of volume attachments to fake
1662- :return:
1663- A list of VolumeAttachment objects faking the volume attachments.
1664- """
1665- volume_attachments = []
1666- for i in range (0 , count ):
1667- volume_attachments .append (
1668- FakeVolumeAttachment .create_one_sdk_volume_attachment (
1669- attrs , methods ))
1589+ :param dict attrs: A dictionary with all attributes
1590+ :param int count: The number of volume attachments to fake
1591+ :return: A list of fake
1592+ openstack.compute.v2.volume_attachment.VolumeAttachment objects
1593+ """
1594+ volume_attachments = []
1595+ for i in range (0 , count ):
1596+ volume_attachments .append (create_one_volume_attachment (attrs ))
16701597
1671- return volume_attachments
1598+ return volume_attachments
16721599
16731600
16741601def create_one_hypervisor (attrs = None ):
0 commit comments