@echo " or make sync PLCHOST=testplc.onelab.eu GUEST=vplc03.inria.fr"
@exit 1
else
- +$(RSYNC) plcsh PLC planetlab5.sql migrations $(SSHURL)/usr/share/plc_api/
+ +$(RSYNC) plcsh PLC planetlab5.sql migrations aspects $(SSHURL)/usr/share/plc_api/
+$(RSYNC) db-config.d/ $(SSHURL)/etc/planetlab/db-config.d/
+$(RSYNC) plc.d/ $(SSHURL)/etc/plc.d/
$(SSHCOMMAND) apachectl graceful
# Copyright (C) 2004-2006 The Trustees of Princeton University
#
+import os
import sys
import traceback
import string
if self.config.PLC_OMF_ENABLED:
from aspects import apply_omf_aspect
apply_omf_aspect()
+
+ if self.config.PLC_RATELIMIT_ENABLED:
+ from aspects import apply_ratelimit_aspect
+ apply_ratelimit_aspect()
+
+
+ # Enable Caching. Only for GetSlivers for the moment.
+ # TODO: we may consider to do this in an aspect like the ones above.
+ try:
+ if self.config.PLC_GETSLIVERS_CACHE:
+ getslivers_cache = true
+ except AttributeError:
+ getslivers_cache = false
+
+ if getslivers_cache:
+ os.environ['DJANGO_SETTINGS_MODULE']='plc_django_settings'
+ from cache_utils.decorators import cached
+ from PLC.Methods.GetSlivers import GetSlivers
+
+ @cached(7200)
+ def cacheable_call(cls, auth, node_id_or_hostname):
+ return cls.raw_call(auth, node_id_or_hostname)
+
+ GetSlivers.call = cacheable_call
+
def callable(self, method):
define_accessors(current_module, Slice, "Vref", "vref",
"slice/config", "vserver reference image name",
set_roles=["admin","pi","user","node"], expose_in_api=True)
+# this contains the actual script text
+# if set, it supersedes 'initscript'
+define_accessors(current_module, Slice, "InitscriptCode","initscript_code",
+ "slice/usertools", "Slice initialization script code",
+ set_roles=["admin","pi","user"], expose_in_api=True)
+# this may contain a *name* that refers to the GetInitScripts
+# it was initially designed to share scripts among slices
define_accessors(current_module, Slice, "Initscript","initscript",
- "slice/usertools", "Slice initialization script",
+ "slice/usertools", "Slice initialization script name",
set_roles=["admin","pi","user"], expose_in_api=True)
# BootManager might need to set any of these 3, so 'node' needs to be in set_roles
from PLC.Sites import Site, Sites
from PLC.Nodes import Node, Nodes
from PLC.TagTypes import TagTypes
-from PLC.NodeTags import NodeTags
+from PLC.NodeTags import NodeTags, NodeTag
from PLC.Methods.AddNodeTag import AddNodeTag
from PLC.Methods.UpdateNodeTag import UpdateNodeTag
for (tagname,value) in tags.iteritems():
# the tagtype instance is assumed to exist, just check that
- if not TagTypes(self.api,{'tagname':tagname}):
+ tag_types = TagTypes(self.api,{'tagname':tagname})
+ if not tag_types:
raise PLCInvalidArgument,"No such TagType %s"%tagname
+ tag_type = tag_types[0]
node_tags=NodeTags(self.api,{'tagname':tagname,'node_id':node['node_id']})
if not node_tags:
- AddNodeTag(self.api).__call__(auth,node['node_id'],tagname,value)
+ node_tag = NodeTag(self.api)
+ node_tag['node_id'] = node['node_id']
+ node_tag['tag_type_id'] = tag_type['tag_type_id']
+ node_tag['tagname'] = tagname
+ node_tag['value'] = value
+ node_tag.sync()
else:
- UpdateNodeTag(self.api).__call__(auth,node_tags[0]['node_tag_id'],value)
+ node_tag = node_tags[0]
+ node_tag['value'] = value
+ node_tag.sync()
self.event_objects = {'Site': [site['site_id']],
'Node': [node['node_id']]}
from PLC.Accessors.Accessors_standard import *
-# Caching
-import os
-os.environ['DJANGO_SETTINGS_MODULE']='plc_django_settings'
-from cache_utils.decorators import cached
-
# XXX used to check if slice expiration time is sane
MAXINT = 2L**31-1
}
def call(self, auth, node_id_or_hostname = None):
- try:
- cache_opt = self.api.config.PLC_GETSLIVERS_CACHE
- with AttributeError:
- cache_opt = False
-
- if (cache_opt):
- return self.cacheable_call(auth, node_id_or_hostname)
- else:
- return self.raw_call(auth, node_id_or_hostname)
-
- @cached(7200)
- def cacheable_call(self, auth, node_id_or_hostname):
return self.raw_call(auth, node_id_or_hostname)
+
def raw_call(self, auth, node_id_or_hostname):
timestamp = int(time.time())
from PLC.Sites import Sites
from PLC.Nodes import Node, Nodes
from PLC.TagTypes import TagTypes
-from PLC.NodeTags import NodeTags
+from PLC.NodeTags import NodeTags, NodeTag
from PLC.Methods.AddNodeTag import AddNodeTag
from PLC.Methods.UpdateNodeTag import UpdateNodeTag
raise PLCInvalidArgument,"No such TagType %s"%tagname
node_tags=NodeTags(self.api,{'tagname':tagname,'node_id':node['node_id']})
if not node_tags:
- AddNodeTag(self.api).__call__(auth,node['node_id'],tagname,value)
+ node_tag = NodeTag(self.api)
+ node_tag['node_id'] = node['node_id']
+ node_tag['tag_type_id'] = tag_type['tag_type_id']
+ node_tag['tagname'] = tagname
+ node_tag['value'] = value
+ node_tag.sync()
else:
- UpdateNodeTag(self.api).__call__(auth,node_tags[0]['node_tag_id'],value)
-
+ node_tag = node_tags[0]
+ node_tag['value'] = value
+ node_tag.sync()
# Logging variables
self.event_objects = {'Node': [node['node_id']]}
if 'hostname' in node:
-### $Id: Namespace.py
-### $URL:
-
URN_PREFIX = "urn:publicid:IDN"
def get_leaf(hrn):
def hostname_to_hrn(auth_hrn, login_base, hostname):
"""
- Convert hrn to plantelab name.
+ Convert hrn to planetlab name.
"""
sfa_hostname = ".".join([auth_hrn, login_base, hostname.split(".")[0]])
return sfa_hostname
-# $Id$
-# $URL$
#
# Thierry Parmentelat - INRIA
#
import re
from types import StringTypes
+import traceback
from urlparse import urlparse
import PLC.Auth
+from PLC.Debug import log
from PLC.Faults import *
from PLC.Namespace import hostname_to_hrn
from PLC.Parameter import Parameter, Mixed
'peer_node_id': peer_node_id},
commit = commit)
- # attempt to manually update the 'hrn' tag
- root_auth = self['hrn_root']
sites = Sites(self.api, node['site_id'], ['login_base'])
site = sites[0]
login_base = site['login_base']
- hrn = hostname_to_hrn(root_auth, login_base, node['hostname'])
- tags = {'hrn': hrn}
- Node(self.api, node).update_tags(tags)
+ try:
+ # attempt to manually update the 'hrn' tag with the remote prefix
+ hrn_root = self['hrn_root']
+ hrn = hostname_to_hrn(hrn_root, login_base, node['hostname'])
+ tags = {'hrn': hrn}
+ Node(self.api, node).update_tags(tags)
+ except:
+ print >>log, "WARNING: (beg) could not find out hrn on hostname=%s"%node['hostname']
+ traceback.print_exc(5,log)
+ print >>log, "WARNING: (end) could not find out hrn on hostname=%s"%node['hostname']
def remove_node(self, node, commit = True):
"""
remove = Row.remove_object(Node, 'peer_node')
remove(self, node, commit)
- # attempt to manually update the 'hrn' tag
+ # attempt to manually update the 'hrn' tag now that the node is local
root_auth = self.api.config.PLC_HRN_ROOT
sites = Sites(self.api, node['site_id'], ['login_base'])
site = sites[0]
%define name PLCAPI
%define version 5.0
-%define taglevel 30
+%define taglevel 32
%define release %{taglevel}%{?pldistro:.%{pldistro}}%{?date:.%{date}}
%changelog
+* Tue Mar 22 2011 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - plcapi-5.0-32
+- rename initscript_body into initscript_code
+
+* Mon Mar 21 2011 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - plcapi-5.0-31
+- new initscript_body tag
+
* Wed Mar 09 2011 Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> - plcapi-5.0-30
- working draft for GetSliceSshKeys
def apply_omf_aspect():
# track all PLC methods to add OMF hooks
weave_class_method(OMFAspect(), Method, "__call__")
+
+def apply_ratelimit_aspect():
weave_class_method(RateLimitAspect(), Method, "__call__")
def apply_debugger_aspect():
initscript_id serial PRIMARY KEY, -- Initscript identifier
name text NOT NULL, -- Initscript name
enabled bool NOT NULL DEFAULT true, -- Initscript is active
- script text NOT NULL, -- Initscript body
+ script text NOT NULL, -- Initscript code
UNIQUE (name)
) WITH OIDS;
CREATE INDEX initscripts_name_idx ON initscripts (name);