|
25 | 25 | from openstack.compute.v2 import extension as _extension |
26 | 26 | from openstack.compute.v2 import flavor as _flavor |
27 | 27 | from openstack.compute.v2 import hypervisor as _hypervisor |
28 | | -from openstack.compute.v2 import keypair as _keypair |
29 | 28 | from openstack.compute.v2 import limits as _limits |
30 | 29 | from openstack.compute.v2 import migration as _migration |
31 | 30 | from openstack.compute.v2 import server as _server |
@@ -620,61 +619,6 @@ def create_one_flavor_access(attrs=None): |
620 | 619 | return flavor_access |
621 | 620 |
|
622 | 621 |
|
623 | | -def create_one_keypair(attrs=None): |
624 | | - """Create a fake keypair |
625 | | -
|
626 | | - :param dict attrs: A dictionary with all attributes |
627 | | - :return: A fake openstack.compute.v2.keypair.Keypair object |
628 | | - """ |
629 | | - attrs = attrs or {} |
630 | | - |
631 | | - # Set default attributes. |
632 | | - keypair_info = { |
633 | | - 'name': 'keypair-name-' + uuid.uuid4().hex, |
634 | | - 'type': 'ssh', |
635 | | - 'fingerprint': 'dummy', |
636 | | - 'public_key': 'dummy', |
637 | | - 'user_id': 'user', |
638 | | - } |
639 | | - |
640 | | - # Overwrite default attributes. |
641 | | - keypair_info.update(attrs) |
642 | | - |
643 | | - return _keypair.Keypair(**keypair_info) |
644 | | - |
645 | | - |
646 | | -def create_keypairs(attrs=None, count=2): |
647 | | - """Create multiple fake keypairs. |
648 | | -
|
649 | | - :param dict attrs: A dictionary with all attributes |
650 | | - :param int count: The number of keypairs to fake |
651 | | - :return: A list of fake openstack.compute.v2.keypair.Keypair objects |
652 | | - """ |
653 | | - |
654 | | - keypairs = [] |
655 | | - for i in range(0, count): |
656 | | - keypairs.append(create_one_keypair(attrs)) |
657 | | - |
658 | | - return keypairs |
659 | | - |
660 | | - |
661 | | -def get_keypairs(keypairs=None, count=2): |
662 | | - """Get an iterable MagicMock object with a list of faked keypairs. |
663 | | -
|
664 | | - If keypairs list is provided, then initialize the Mock object with the |
665 | | - list. Otherwise create one. |
666 | | -
|
667 | | - :param list keypairs: A list of fake openstack.compute.v2.keypair.Keypair |
668 | | - objects |
669 | | - :param int count: The number of keypairs to fake |
670 | | - :return: An iterable Mock object with side_effect set to a list of faked |
671 | | - keypairs |
672 | | - """ |
673 | | - if keypairs is None: |
674 | | - keypairs = create_keypairs(count) |
675 | | - return mock.Mock(side_effect=keypairs) |
676 | | - |
677 | | - |
678 | 622 | def create_one_availability_zone(attrs=None): |
679 | 623 | """Create a fake AZ. |
680 | 624 |
|
|
0 commit comments