2 # NEPI, a framework to manage network experiments
3 # Copyright (C) 2013 INRIA
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20 from nepi.execution.attribute import Attribute, Flags, Types
21 from nepi.execution.resource import ResourceManager, clsinit_copy, ResourceState, \
23 from nepi.resources.linux.node import LinuxNode
24 from nepi.resources.planetlab.plcapi import PLCAPIFactory
28 class PlanetlabNode(LinuxNode):
29 _rtype = "PlanetlabNode"
32 def _register_attributes(cls):
33 ip = Attribute("ip", "PlanetLab host public IP address",
34 flags = Flags.ReadOnly)
36 pl_url = Attribute("plcApiUrl", "URL of PlanetLab PLCAPI host (e.g. www.planet-lab.eu or www.planet-lab.org) ",
37 default = "www.planet-lab.eu",
38 flags = Flags.Credential)
40 pl_ptn = Attribute("plcApiPattern", "PLC API service regexp pattern (e.g. https://%(hostname)s:443/PLCAPI/ ) ",
41 default = "https://%(hostname)s:443/PLCAPI/",
42 flags = Flags.ExecReadOnly)
44 city = Attribute("city",
45 "Constrain location (city) during resource discovery. May use wildcards.",
48 country = Attribute("country",
49 "Constrain location (country) during resource discovery. May use wildcards.",
52 region = Attribute("region",
53 "Constrain location (region) during resource discovery. May use wildcards.",
56 architecture = Attribute("architecture",
57 "Constrain architecture during resource discovery.",
58 type = Types.Enumerate,
63 operating_system = Attribute("operatingSystem",
64 "Constrain operating system during resource discovery.",
65 type = Types.Enumerate,
73 site = Attribute("site",
74 "Constrain the PlanetLab site this node should reside on.",
75 type = Types.Enumerate,
81 min_reliability = Attribute("minReliability",
82 "Constrain reliability while picking PlanetLab nodes. Specifies a lower acceptable bound.",
87 max_reliability = Attribute("maxReliability",
88 "Constrain reliability while picking PlanetLab nodes. Specifies an upper acceptable bound.",
93 min_bandwidth = Attribute("minBandwidth",
94 "Constrain available bandwidth while picking PlanetLab nodes. Specifies a lower acceptable bound.",
99 max_bandwidth = Attribute("maxBandwidth",
100 "Constrain available bandwidth while picking PlanetLab nodes. Specifies an upper acceptable bound.",
103 flags = Flags.Filter)
105 min_load = Attribute("minLoad",
106 "Constrain node load average while picking PlanetLab nodes. Specifies a lower acceptable bound.",
109 flags = Flags.Filter)
111 max_load = Attribute("maxLoad",
112 "Constrain node load average while picking PlanetLab nodes. Specifies an upper acceptable bound.",
115 flags = Flags.Filter)
117 min_cpu = Attribute("minCpu",
118 "Constrain available cpu time while picking PlanetLab nodes. Specifies a lower acceptable bound.",
121 flags = Flags.Filter)
123 max_cpu = Attribute("maxCpu",
124 "Constrain available cpu time while picking PlanetLab nodes. Specifies an upper acceptable bound.",
127 flags = Flags.Filter)
129 timeframe = Attribute("timeframe",
130 "Past time period in which to check information about the node. Values are year,month, week, latest",
132 type = Types.Enumerate,
137 flags = Flags.Filter)
139 cls._register_attribute(ip)
140 cls._register_attribute(pl_url)
141 cls._register_attribute(pl_ptn)
142 cls._register_attribute(city)
143 cls._register_attribute(country)
144 cls._register_attribute(region)
145 cls._register_attribute(architecture)
146 cls._register_attribute(operating_system)
147 cls._register_attribute(min_reliability)
148 cls._register_attribute(max_reliability)
149 cls._register_attribute(min_bandwidth)
150 cls._register_attribute(max_bandwidth)
151 cls._register_attribute(min_load)
152 cls._register_attribute(max_load)
153 cls._register_attribute(min_cpu)
154 cls._register_attribute(max_cpu)
155 cls._register_attribute(timeframe)
157 def __init__(self, ec, guid):
158 super(PlanetlabNode, self).__init__(ec, guid)
165 slicename = self.get("username")
166 pl_pass = self.get("password")
167 pl_url = self.get("plcApiUrl")
168 pl_ptn = self.get("plcApiPattern")
170 self._plapi = PLCAPIFactory.get_api(slicename, pl_pass, pl_url,
175 def valid_connection(self, guid):