@@ -679,3 +679,64 @@ def get_floating_ips(floating_ips=None, count=2):
679679 if floating_ips is None :
680680 floating_ips = FakeFloatingIP .create_floating_ips (count )
681681 return mock .MagicMock (side_effect = floating_ips )
682+
683+
684+ class FakeSubnetPool (object ):
685+ """Fake one or more subnet pools."""
686+
687+ @staticmethod
688+ def create_one_subnet_pool (attrs = {}, methods = {}):
689+ """Create a fake subnet pool.
690+
691+ :param Dictionary attrs:
692+ A dictionary with all attributes
693+ :param Dictionary methods:
694+ A dictionary with all methods
695+ :return:
696+ A FakeResource object faking the subnet pool
697+ """
698+ # Set default attributes.
699+ subnet_pool_attrs = {
700+ 'id' : 'subnet-pool-id-' + uuid .uuid4 ().hex ,
701+ 'name' : 'subnet-pool-name-' + uuid .uuid4 ().hex ,
702+ }
703+
704+ # Overwrite default attributes.
705+ subnet_pool_attrs .update (attrs )
706+
707+ # Set default methods.
708+ subnet_pool_methods = {
709+ 'keys' : ['id' , 'name' ]
710+ }
711+
712+ # Overwrite default methods.
713+ subnet_pool_methods .update (methods )
714+
715+ subnet_pool = fakes .FakeResource (
716+ info = copy .deepcopy (subnet_pool_attrs ),
717+ methods = copy .deepcopy (subnet_pool_methods ),
718+ loaded = True
719+ )
720+
721+ return subnet_pool
722+
723+ @staticmethod
724+ def create_subnet_pools (attrs = {}, methods = {}, count = 2 ):
725+ """Create multiple fake subnet pools.
726+
727+ :param Dictionary attrs:
728+ A dictionary with all attributes
729+ :param Dictionary methods:
730+ A dictionary with all methods
731+ :param int count:
732+ The number of subnet pools to fake
733+ :return:
734+ A list of FakeResource objects faking the subnet pools
735+ """
736+ subnet_pools = []
737+ for i in range (0 , count ):
738+ subnet_pools .append (
739+ FakeSubnetPool .create_one_subnet_pool (attrs , methods )
740+ )
741+
742+ return subnet_pools
0 commit comments