modification to use cluster version
Change-Id: Iaf169507577deba20d548348532a2e0b91a03249
refs: #3652
diff --git a/ndn/placer.py b/ndn/placer.py
new file mode 100644
index 0000000..ba521b8
--- /dev/null
+++ b/ndn/placer.py
@@ -0,0 +1,87 @@
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2015-2017, The University of Memphis,
+# Arizona Board of Regents,
+# Regents of the University of California.
+#
+# This file is part of Mini-NDN.
+# See AUTHORS.md for a complete list of Mini-NDN authors and contributors.
+#
+# Mini-NDN is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Mini-NDN is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Mini-NDN, e.g., in COPYING.md file.
+# If not, see <http://www.gnu.org/licenses/>.
+#
+# This file incorporates work covered by the following copyright and
+# permission notice:
+#
+# Mininet 2.3.0d1 License
+#
+# Copyright (c) 2013-2016 Open Networking Laboratory
+# Copyright (c) 2009-2012 Bob Lantz and The Board of Trustees of
+# The Leland Stanford Junior University
+#
+# Original authors: Bob Lantz and Brandon Heller
+#
+# We are making Mininet available for public use and benefit with the
+# expectation that others will use, modify and enhance the Software and
+# contribute those enhancements back to the community. However, since we
+# would like to make the Software available for broadest use, with as few
+# restrictions as possible permission is hereby granted, free of charge, to
+# any person obtaining a copy of this Software to deal in the Software
+# under the copyrights without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# The name and trademarks of copyright holder(s) may NOT be used in
+# advertising or publicity pertaining to the Software or any derivatives
+# without specific, written prior permission.
+
+from mininet.examples.cluster import Placer
+
+nodePlace = []
+
+class PopulatePlacement():
+ def __init__( self, placeList ):
+ global nodePlace
+ nodePlace = placeList
+
+class GuidedPlacer( Placer ):
+ "Guided placement"
+ def __init__( self, *args, **kwargs ):
+ Placer.__init__( self, *args, **kwargs )
+ self.count = 0
+
+ def place( self, nodename ):
+ assert nodename #please pylint
+ while(True):
+ global nodePlace
+ if nodePlace[self.count] != 0:
+ nodePlace[self.count] -= 1
+ # args[self.count] is not zero, hence return the server at that position
+ # so that if args[0] is 7 and servers[0] is Europa then place 7 nodes on Europa
+ return self.servers[self.count]
+ else:
+ # while makes sure we go back to the if after this
+ self.count += 1