From 2fbc54bb18d05d1c8972257a342c3ae162e83c6e Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Mon, 1 Oct 2007 21:23:43 +0000 Subject: [PATCH] - merge from PlanetLab Europe --- Makefile | 66 ++++++--- PLC/Methods/AddSliceAttribute.py | 13 +- PLC/Methods/AddSliceToNodes.py | 10 +- PLC/Methods/GetNodeNetworks.py | 8 +- PLC/Methods/GetNodes.py | 15 ++- PLC/Methods/GetPersons.py | 2 + PLC/Methods/GetSites.py | 2 + PLC/Methods/GetSlices.py | 2 + PLC/Methods/NotifySupport.py | 36 +++++ PLC/Methods/__init__.py | 222 ++++++++++++++++++++++++++++++- PLC/NodeNetworkSettingTypes.py | 2 +- PLC/NodeNetworkSettings.py | 2 +- PLC/Persons.py | 10 +- PLC/PyCurl.py | 4 +- PLC/Sites.py | 8 ++ PLC/Slices.py | 8 ++ PLC/__init__.py | 47 ++++++- PLCAPI.spec | 4 +- Test.py | 2 +- setup.py | 4 +- 20 files changed, 431 insertions(+), 36 deletions(-) create mode 100644 PLC/Methods/NotifySupport.py diff --git a/Makefile b/Makefile index 8a68a114..fcc8c829 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2005 The Trustees of Princeton University # -# $Id: Makefile,v 1.14 2007/08/31 02:52:12 mef Exp $ +# $Id: Makefile,v 1.15 2007/10/01 20:51:46 tmack Exp $ # # Metafiles @@ -16,12 +16,9 @@ modules := psycopg2 # Temporarily until we can kill the Fedora Core 2 build curl_vernum := $(shell printf %d 0x$(shell curl-config --vernum)) pycurl_vernum := $(shell printf %d 0x070d01) # 7.13.1 -pycurl_incompatnum := $(shell printf %d 0x071000) # 7.16.0 ifeq ($(shell test $(curl_vernum) -ge $(pycurl_vernum) && echo 1),1) -ifeq ($(shell test $(curl_vernum) -ge $(pycurl_incompatnum) && echo 0),1) modules += pycurl endif -endif modules-install := $(foreach module, $(modules), $(module)-install) modules-clean := $(foreach module, $(modules), $(module)-clean) @@ -73,31 +70,70 @@ clean: $(modules-clean) index: $(init) +index-clean: + rm $(init) + tags: find . '(' -name '*.py' -o -name '*.sql' -o -name '*.php' -o -name Makefile ')' | xargs etags +########## make sync PLCHOST=hostname +ifdef PLCHOST +PLCSSH:=root@$(PLCHOST) +endif + +LOCAL_RSYNC_EXCLUDES := --exclude '*.pyc' +RSYNC_EXCLUDES := --exclude .svn --exclude CVS --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES) +RSYNC_COND_DRY_RUN := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,) +RSYNC := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES) + +sync: +ifeq (,$(PLCSSH)) + echo "sync: You must define target host as PLCHOST on the command line" + echo " e.g. make sync PLCHOST=private.one-lab.org" ; exit 1 +else + +$(RSYNC) PLC planetlab4.sql migrations $(PLCSSH):/plc/root/usr/share/plc_api/ + ssh $(PLCSSH) chroot /plc/root apachectl graceful +endif + +#################### # All .py files in PLC/ -PLC := $(filter-out %/__init__.py, $(wildcard PLC/*.py)) -PLC_init := all = '$(notdir $(PLC:.py=))'.split() -PLC/__init__.py: - echo "$(PLC_init)" >$@ +# the current content of __init__.py +PLC_now := $(sort $(shell fgrep -v '"' PLC/__init__.py 2>/dev/null)) +# what should be declared +PLC_paths := $(filter-out %/__init__.py, $(wildcard PLC/*.py)) +PLC_files := $(sort $(notdir $(PLC_paths:.py=))) -ifneq ($(sort $(PLC_init)), $(sort $(shell cat PLC/__init__.py 2>/dev/null))) +ifneq ($(PLC_now),$(PLC_files)) PLC/__init__.py: force endif +PLC/__init__.py: + (echo 'all = """' ; cd PLC; ls -1 *.py | grep -v __init__ | sed -e 's,.py$$,,' ; echo '""".split()') > $@ -# All .py files in PLC/Methods/ and PLC/Methods/system/ -METHODS := $(filter-out %/__init__.py, $(wildcard PLC/Methods/*.py PLC/Methods/system/*.py)) -Methods_init := methods = '$(notdir $(subst system/, system., $(METHODS:.py=)))'.split() -PLC/Methods/__init__.py: - echo "$(Methods_init)" >$@ +# the current content of __init__.py +METHODS_now := $(sort $(shell fgrep -v '"' PLC/Methods/__init__.py 2>/dev/null)) +# what should be declared +METHODS_paths := $(filter-out %/__init__.py, $(wildcard PLC/Methods/*.py PLC/Methods/system/*.py)) +METHODS_files := $(sort $(notdir $(subst system/, system., $(METHODS_paths:.py=)))) -ifneq ($(sort $(Methods_init)), $(sort $(shell cat PLC/Methods/__init__.py 2>/dev/null))) +ifneq ($(METHODS_now),$(METHODS_files)) PLC/Methods/__init__.py: force endif +PLC/Methods/__init__.py: + (echo 'methods = """' ; cd PLC/Methods; ls -1 *.py system/*.py | grep -v __init__ | sed -e 's,.py$$,,' -e 's,system/,system.,' ; echo '""".split()') > $@ force: .PHONY: all install force clean index tags $(subdirs) $(modules) + +#################### convenience, for debugging only +# make +foo : prints the value of $(foo) +# make ++foo : idem but verbose, i.e. foo=$(foo) +++%: varname=$(subst +,,$@) +++%: + @echo "$(varname)=$($(varname))" ++%: varname=$(subst +,,$@) ++%: + @echo "$($(varname))" + diff --git a/PLC/Methods/AddSliceAttribute.py b/PLC/Methods/AddSliceAttribute.py index aec3047e..af80ee2f 100644 --- a/PLC/Methods/AddSliceAttribute.py +++ b/PLC/Methods/AddSliceAttribute.py @@ -86,7 +86,6 @@ class AddSliceAttribute(Method): if node['node_id'] not in slice['node_ids']: raise PLCInvalidArgument, "Node not in the specified slice" - slice_attribute['node_id'] = node['node_id'] # Sliver attribute shared accross nodes if nodegroup is sepcified @@ -98,6 +97,18 @@ class AddSliceAttribute(Method): slice_attribute['nodegroup_id'] = nodegroup['nodegroup_id'] + # Check if slice attribute alreay exists + slice_attribute_check = None + slice_attributes_check = SliceAttributes(self.api, {'slice_id': slice['slice_id'], 'name': attribute_type['name'], 'value': value}) + for slice_attribute_check in slice_attributes_check: + print slice_attribute_check + if 'node_id' in slice_attribute and slice_attribute['node_id'] == slice_attribute_check['node_id']: + raise PLCInvalidArgument, "Sliver attribute already exists" + if 'nodegroup_id' in slice_attribute and slice_attribute['nodegroup_id'] == slice_attribute_check['nodegroup_id']: + raise PLCInvalidArgument, "Slice attribute already exists for this nodegroup" + if node_id_or_hostname is None and nodegroup_id_or_name is None: + raise PLCInvalidArgument, "Slice attribute already exists" + slice_attribute.sync() self.event_objects = {'SliceAttribute': [slice_attribute['slice_attribute_id']]} diff --git a/PLC/Methods/AddSliceToNodes.py b/PLC/Methods/AddSliceToNodes.py index ce8bb1c6..d5a2c8c2 100644 --- a/PLC/Methods/AddSliceToNodes.py +++ b/PLC/Methods/AddSliceToNodes.py @@ -3,6 +3,7 @@ from PLC.Method import Method from PLC.Parameter import Parameter, Mixed from PLC.Nodes import Node, Nodes from PLC.Slices import Slice, Slices +from PLC.Persons import Person, Persons from PLC.Auth import Auth class AddSliceToNodes(Method): @@ -47,12 +48,15 @@ class AddSliceToNodes(Method): raise PLCPermissionDenied, "Specified slice not associated with any of your sites" # Get specified nodes, add them to the slice - nodes = Nodes(self.api, node_id_or_hostname_list, ['node_id', 'hostname', 'slice_ids', 'slice_ids_whitelist']) + nodes = Nodes(self.api, node_id_or_hostname_list, ['node_id', 'hostname', 'slice_ids', 'slice_ids_whitelist', 'site_id']) + for node in nodes: # check the slice whitelist on each node first + # allow users at site to add node to slice, ignoring whitelist if node['slice_ids_whitelist'] and \ - slice['slice_id'] not in node['slice_ids_whitelist']: - raise PLCInvalidArgument, "%s is not on %s's whitelist" % \ + slice['slice_id'] not in node['slice_ids_whitelist'] and \ + not set(self.caller['site_ids']).intersection([node['site_id']]): + raise PLCInvalidArgument, "%s is not allowed on %s (not on the whitelist)" % \ (slice['name'], node['hostname']) if slice['slice_id'] not in node['slice_ids']: slice.add_node(node, commit = False) diff --git a/PLC/Methods/GetNodeNetworks.py b/PLC/Methods/GetNodeNetworks.py index 558dcf36..150f87de 100644 --- a/PLC/Methods/GetNodeNetworks.py +++ b/PLC/Methods/GetNodeNetworks.py @@ -10,9 +10,10 @@ class GetNodeNetworks(Method): Returns an array of structs containing details about node network interfacess. If nodenetworks_filter is specified and is an array of node network identifiers, or a struct of node network - attributes, only node network interfaces matching the filter will - be returned. If return_fields is specified, only the - specified details will be returned. + fields and values, only node network interfaces matching the filter + will be returned. + + If return_fields is given, only the specified details will be returned. """ roles = ['admin', 'pi', 'user', 'tech', 'node', 'anonymous'] @@ -20,6 +21,7 @@ class GetNodeNetworks(Method): accepts = [ Auth(), Mixed([NodeNetwork.fields['nodenetwork_id']], + Parameter (int, "nodenetwork id"), Filter(NodeNetwork.fields)), Parameter([str], "List of fields to return", nullok = True) ] diff --git a/PLC/Methods/GetNodes.py b/PLC/Methods/GetNodes.py index e442a952..8e2931a1 100644 --- a/PLC/Methods/GetNodes.py +++ b/PLC/Methods/GetNodes.py @@ -23,6 +23,8 @@ class GetNodes(Method): Auth(), Mixed([Mixed(Node.fields['node_id'], Node.fields['hostname'])], + Parameter(str,"hostname"), + Parameter(int,"node_id"), Filter(Node.fields)), Parameter([str], "List of fields to return", nullok = True), ] @@ -34,7 +36,7 @@ class GetNodes(Method): # Must query at least slice_ids_whitelist if return_fields is not None: - added_fields = set(['slice_ids_whitelist']).difference(return_fields) + added_fields = set(['slice_ids_whitelist', 'site_id']).difference(return_fields) return_fields += added_fields else: added_fields =[] @@ -46,14 +48,23 @@ class GetNodes(Method): if not isinstance(self.caller, Person) or \ 'admin' not in self.caller['roles']: slice_ids = set() + site_ids = set() if self.caller: slice_ids.update(self.caller['slice_ids']) - # if node has whitelist, make sure the user has a slice on the whitelist + site_ids.update(self.caller['site_ids']) + + # if node has whitelist, only return it if users is at + # the same site or user has a slice on the whitelist for node in nodes[:]: + if 'site_id' in node and \ + site_ids.intersection([node['site_id']]): + continue if 'slice_ids_whitelist' in node and \ node['slice_ids_whitelist'] and \ not slice_ids.intersection(node['slice_ids_whitelist']): nodes.remove(node) + + # remove remaining admin only fields for node in nodes: for field in ['boot_nonce', 'key', 'session', 'root_person_ids']: if field in node: diff --git a/PLC/Methods/GetPersons.py b/PLC/Methods/GetPersons.py index e48db7be..a483dd4d 100644 --- a/PLC/Methods/GetPersons.py +++ b/PLC/Methods/GetPersons.py @@ -27,6 +27,8 @@ class GetPersons(Method): Auth(), Mixed([Mixed(Person.fields['person_id'], Person.fields['email'])], + Parameter(str,"email"), + Parameter(int,"person_id"), Filter(Person.fields)), Parameter([str], "List of fields to return", nullok = True) ] diff --git a/PLC/Methods/GetSites.py b/PLC/Methods/GetSites.py index 0d98e6b2..c0f198e1 100644 --- a/PLC/Methods/GetSites.py +++ b/PLC/Methods/GetSites.py @@ -19,6 +19,8 @@ class GetSites(Method): Auth(), Mixed([Mixed(Site.fields['site_id'], Site.fields['login_base'])], + Parameter(str,"login_base"), + Parameter(int,"site_id"), Filter(Site.fields)), Parameter([str], "List of fields to return", nullok = True) ] diff --git a/PLC/Methods/GetSlices.py b/PLC/Methods/GetSlices.py index b2ddfde1..c300ce0c 100644 --- a/PLC/Methods/GetSlices.py +++ b/PLC/Methods/GetSlices.py @@ -26,6 +26,8 @@ class GetSlices(Method): Auth(), Mixed([Mixed(Slice.fields['slice_id'], Slice.fields['name'])], + Parameter(str,"name"), + Parameter(int,"slice_id"), Filter(Slice.fields)), Parameter([str], "List of fields to return", nullok = True) ] diff --git a/PLC/Methods/NotifySupport.py b/PLC/Methods/NotifySupport.py new file mode 100644 index 00000000..99ec318e --- /dev/null +++ b/PLC/Methods/NotifySupport.py @@ -0,0 +1,36 @@ +from PLC.Method import Method +from PLC.Parameter import Parameter, Mixed +from PLC.Auth import Auth +from PLC.sendmail import sendmail + +class NotifySupport(Method): + """ + Sends an e-mail message to the configured support address. + + Returns 1 if successful. + """ + + roles = ['admin'] + + accepts = [ + Auth(), + Parameter(str, "E-mail subject"), + Parameter(str, "E-mail body") + ] + + returns = Parameter(int, '1 if successful') + + def call(self, auth, subject, body): + to_name="%s Support"%self.api.config.PLC_NAME + to_address=self.api.config.PLC_MAIL_SUPPORT_ADDRESS + + # Send email + sendmail(self.api, To=(to_name,to_address), + Subject = subject, + Body = body) + + # Logging variables + #self.event_objects = {'Person': [person['person_id'] for person in persons]} + self.message = subject + + return 1 diff --git a/PLC/Methods/__init__.py b/PLC/Methods/__init__.py index 246e36aa..05274218 100644 --- a/PLC/Methods/__init__.py +++ b/PLC/Methods/__init__.py @@ -1 +1,221 @@ -methods = 'AddAddressType AddAddressTypeToAddress AddBootState AddConfFile AddConfFileToNodeGroup AddConfFileToNode AddInitScript AddKeyType AddMessage AddNetworkMethod AddNetworkType AddNodeGroup AddNodeNetwork AddNodeNetworkSetting AddNodeNetworkSettingType AddNode AddNodeToNodeGroup AddNodeToPCU AddPCU AddPeer AddPersonKey AddPerson AddPersonToSite AddPersonToSlice AddRole AddRoleToPerson AddSession AddSiteAddress AddSite AddSliceAttribute AddSliceAttributeType AddSliceInstantiation AddSlice AddSliceToNodes AddSliceToNodesWhitelist AdmAddAddressType AdmAddNodeGroup AdmAddNodeNetwork AdmAddNode AdmAddNodeToNodeGroup AdmAddPersonKey AdmAddPerson AdmAddPersonToSite AdmAddSitePowerControlUnit AdmAddSite AdmAssociateNodeToPowerControlUnitPort AdmAuthCheck AdmDeleteAddressType AdmDeleteAllPersonKeys AdmDeleteNodeGroup AdmDeleteNodeNetwork AdmDeleteNode AdmDeletePersonKeys AdmDeletePerson AdmDeleteSitePowerControlUnit AdmDeleteSite AdmDisassociatePowerControlUnitPort AdmGenerateNodeConfFile AdmGetAllAddressTypes AdmGetAllKeyTypes AdmGetAllNodeNetworks AdmGetAllRoles AdmGetNodeGroupNodes AdmGetNodeGroups AdmGetNodes AdmGetPersonKeys AdmGetPersonRoles AdmGetPersonSites AdmGetPersons AdmGetPowerControlUnitNodes AdmGetPowerControlUnits AdmGetSiteNodes AdmGetSitePersons AdmGetSitePIs AdmGetSitePowerControlUnits AdmGetSites AdmGetSiteTechContacts AdmGrantRoleToPerson AdmIsPersonInRole AdmQueryConfFile AdmQueryNode AdmQueryPerson AdmQueryPowerControlUnit AdmQuerySite AdmRebootNode AdmRemoveNodeFromNodeGroup AdmRemovePersonFromSite AdmRevokeRoleFromPerson AdmSetPersonEnabled AdmSetPersonPrimarySite AdmUpdateNodeGroup AdmUpdateNodeNetwork AdmUpdateNode AdmUpdatePerson AdmUpdateSitePowerControlUnit AdmUpdateSite AnonAdmGetNodeGroups AuthCheck BlacklistKey BootCheckAuthentication BootGetNodeDetails BootNotifyOwners BootUpdateNode DeleteAddress DeleteAddressTypeFromAddress DeleteAddressType DeleteBootState DeleteConfFileFromNodeGroup DeleteConfFileFromNode DeleteConfFile DeleteInitScript DeleteKey DeleteKeyType DeleteMessage DeleteNetworkMethod DeleteNetworkType DeleteNodeFromNodeGroup DeleteNodeFromPCU DeleteNodeGroup DeleteNodeNetwork DeleteNodeNetworkSetting DeleteNodeNetworkSettingType DeleteNode DeletePCU DeletePeer DeletePersonFromSite DeletePersonFromSlice DeletePerson DeleteRoleFromPerson DeleteRole DeleteSession DeleteSite DeleteSliceAttribute DeleteSliceAttributeType DeleteSliceFromNodes DeleteSliceFromNodesWhitelist DeleteSliceInstantiation DeleteSlice GenerateNodeConfFile GetAddresses GetAddressTypes GetBootMedium GetBootStates GetConfFiles GetEventObjects GetEvents GetInitScripts GetKeys GetKeyTypes GetMessages GetNetworkMethods GetNetworkTypes GetNodeGroups GetNodeNetworkSettings GetNodeNetworkSettingTypes GetNodeNetworks GetNodes GetPCUs GetPeerData GetPeerName GetPeers GetPersons GetPlcRelease GetRoles GetSession GetSessions GetSites GetSliceAttributes GetSliceAttributeTypes GetSliceInstantiations GetSliceKeys GetSlicesMD5 GetSlices GetSliceTicket GetSlivers GetWhitelist NotifyPersons RebootNode RefreshPeer ResetPassword SetPersonPrimarySite SliceCreate SliceDelete SliceExtendedInfo SliceGetTicket SliceInfo SliceListNames SliceListUserSlices SliceNodesAdd SliceNodesDel SliceNodesList SliceRenew SliceTicketGet SliceUpdate SliceUserAdd SliceUserDel SliceUsersList UpdateAddress UpdateAddressType UpdateConfFile UpdateInitScript UpdateKey UpdateMessage UpdateNodeGroup UpdateNodeNetwork UpdateNodeNetworkSetting UpdateNodeNetworkSettingType UpdateNode UpdatePCU UpdatePeer UpdatePerson UpdateSite UpdateSliceAttribute UpdateSliceAttributeType UpdateSlice VerifyPerson system.listMethods system.methodHelp system.methodSignature system.multicall'.split() +methods = """ +AddAddressType +AddAddressTypeToAddress +AddBootState +AddConfFile +AddConfFileToNode +AddConfFileToNodeGroup +AddInitScript +AddKeyType +AddMessage +AddNetworkMethod +AddNetworkType +AddNode +AddNodeGroup +AddNodeNetwork +AddNodeNetworkSetting +AddNodeNetworkSettingType +AddNodeToNodeGroup +AddNodeToPCU +AddPCU +AddPeer +AddPerson +AddPersonKey +AddPersonToSite +AddPersonToSlice +AddRole +AddRoleToPerson +AddSession +AddSite +AddSiteAddress +AddSlice +AddSliceAttribute +AddSliceAttributeType +AddSliceInstantiation +AddSliceToNodes +AddSliceToNodesWhitelist +AdmAddAddressType +AdmAddNode +AdmAddNodeGroup +AdmAddNodeNetwork +AdmAddNodeToNodeGroup +AdmAddPerson +AdmAddPersonKey +AdmAddPersonToSite +AdmAddSite +AdmAddSitePowerControlUnit +AdmAssociateNodeToPowerControlUnitPort +AdmAuthCheck +AdmDeleteAddressType +AdmDeleteAllPersonKeys +AdmDeleteNode +AdmDeleteNodeGroup +AdmDeleteNodeNetwork +AdmDeletePerson +AdmDeletePersonKeys +AdmDeleteSite +AdmDeleteSitePowerControlUnit +AdmDisassociatePowerControlUnitPort +AdmGetAllAddressTypes +AdmGetAllKeyTypes +AdmGetAllNodeNetworks +AdmGetAllRoles +AdmGetNodeGroupNodes +AdmGetNodeGroups +AdmGetNodes +AdmGetPersonKeys +AdmGetPersonRoles +AdmGetPersonSites +AdmGetPersons +AdmGetPowerControlUnitNodes +AdmGetPowerControlUnits +AdmGetSiteNodes +AdmGetSitePIs +AdmGetSitePersons +AdmGetSitePowerControlUnits +AdmGetSiteTechContacts +AdmGetSites +AdmGrantRoleToPerson +AdmIsPersonInRole +AdmQueryConfFile +AdmQueryNode +AdmQueryPerson +AdmQueryPowerControlUnit +AdmQuerySite +AdmRebootNode +AdmRemoveNodeFromNodeGroup +AdmRemovePersonFromSite +AdmRevokeRoleFromPerson +AdmSetPersonEnabled +AdmSetPersonPrimarySite +AdmUpdateNode +AdmUpdateNodeGroup +AdmUpdateNodeNetwork +AdmUpdatePerson +AdmUpdateSite +AdmUpdateSitePowerControlUnit +AnonAdmGetNodeGroups +AuthCheck +BlacklistKey +BootCheckAuthentication +BootGetNodeDetails +BootNotifyOwners +BootUpdateNode +DeleteAddress +DeleteAddressType +DeleteAddressTypeFromAddress +DeleteBootState +DeleteConfFile +DeleteConfFileFromNode +DeleteConfFileFromNodeGroup +DeleteInitScript +DeleteKey +DeleteKeyType +DeleteMessage +DeleteNetworkMethod +DeleteNetworkType +DeleteNode +DeleteNodeFromNodeGroup +DeleteNodeFromPCU +DeleteNodeGroup +DeleteNodeNetwork +DeleteNodeNetworkSetting +DeleteNodeNetworkSettingType +DeletePCU +DeletePeer +DeletePerson +DeletePersonFromSite +DeletePersonFromSlice +DeleteRole +DeleteRoleFromPerson +DeleteSession +DeleteSite +DeleteSlice +DeleteSliceAttribute +DeleteSliceAttributeType +DeleteSliceFromNodes +DeleteSliceFromNodesWhitelist +DeleteSliceInstantiation +GetAddressTypes +GetAddresses +GetBootMedium +GetBootStates +GetConfFiles +GetEventObjects +GetEvents +GetInitScripts +GetKeyTypes +GetKeys +GetMessages +GetNetworkMethods +GetNetworkTypes +GetNodeGroups +GetNodeNetworkSettingTypes +GetNodeNetworkSettings +GetNodeNetworks +GetNodes +GetPCUs +GetPeerData +GetPeerName +GetPeers +GetPersons +GetPlcRelease +GetRoles +GetSession +GetSessions +GetSites +GetSliceAttributeTypes +GetSliceAttributes +GetSliceInstantiations +GetSliceKeys +GetSliceTicket +GetSlices +GetSlicesMD5 +GetSlivers +GetWhitelist +NotifyPersons +NotifySupport +RebootNode +RefreshPeer +ResetPassword +SetPersonPrimarySite +SliceCreate +SliceDelete +SliceExtendedInfo +SliceGetTicket +SliceInfo +SliceListNames +SliceListUserSlices +SliceNodesAdd +SliceNodesDel +SliceNodesList +SliceRenew +SliceTicketGet +SliceUpdate +SliceUserAdd +SliceUserDel +SliceUsersList +UpdateAddress +UpdateAddressType +UpdateConfFile +UpdateInitScript +UpdateKey +UpdateMessage +UpdateNode +UpdateNodeGroup +UpdateNodeNetwork +UpdateNodeNetworkSetting +UpdateNodeNetworkSettingType +UpdatePCU +UpdatePeer +UpdatePerson +UpdateSite +UpdateSlice +UpdateSliceAttribute +UpdateSliceAttributeType +VerifyPerson +system.listMethods +system.methodHelp +system.methodSignature +system.multicall +""".split() diff --git a/PLC/NodeNetworkSettingTypes.py b/PLC/NodeNetworkSettingTypes.py index deb8be34..f2ff2144 100644 --- a/PLC/NodeNetworkSettingTypes.py +++ b/PLC/NodeNetworkSettingTypes.py @@ -1,7 +1,7 @@ # # Thierry Parmentelat - INRIA # -# $Revision: 88 $ +# $Revision: 1.1 $ # from types import StringTypes diff --git a/PLC/NodeNetworkSettings.py b/PLC/NodeNetworkSettings.py index 026fec95..eddd1e21 100644 --- a/PLC/NodeNetworkSettings.py +++ b/PLC/NodeNetworkSettings.py @@ -1,7 +1,7 @@ # # Thierry Parmentelat - INRIA # -# $Revision: 98 $ +# $Revision: 1.1 $ # from PLC.Faults import * from PLC.Parameter import Parameter diff --git a/PLC/Persons.py b/PLC/Persons.py index 7c1a8fd5..f035955e 100644 --- a/PLC/Persons.py +++ b/PLC/Persons.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: Persons.py,v 1.38 2007/08/22 19:54:07 tmack Exp $ +# $Id: Persons.py,v 1.39 2007/10/01 20:51:46 tmack Exp $ # from types import StringTypes @@ -326,6 +326,14 @@ class Persons(Table): elif isinstance(person_filter, dict): person_filter = Filter(Person.fields, person_filter) sql += " AND (%s)" % person_filter.sql(api, "AND") + elif isinstance (person_filter, StringTypes): + person_filter = Filter(Person.fields, {'email':[person_filter]}) + sql += " AND (%s)" % person_filter.sql(api, "AND") + elif isinstance (person_filter, int): + person_filter = Filter(Person.fields, {'person_id':[person_filter]}) + sql += " AND (%s)" % person_filter.sql(api, "AND") + else: + raise PLCInvalidArgument, "Wrong person filter %r"%person_filter # aggregate data all_persons = {} diff --git a/PLC/PyCurl.py b/PLC/PyCurl.py index 9b42905c..51b08a36 100644 --- a/PLC/PyCurl.py +++ b/PLC/PyCurl.py @@ -5,7 +5,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: PyCurl.py,v 1.2 2007/09/12 17:52:27 tmack Exp $ +# $Id: PyCurl.py,v 1.3 2007/10/01 20:51:47 tmack Exp $ # import os @@ -70,7 +70,7 @@ class PyCurlTransport(xmlrpclib.Transport): if errcode == 60: raise Exception, "PyCurl: SSL certificate validation failed" elif errcode != 200: - raise Exception, "PyCurl: HTTP error %d" % errcode + raise Exception, "PyCurl: HTTP error %d -- %r" % (errcode,errmsg) # Parse response p, u = self.getparser() diff --git a/PLC/Sites.py b/PLC/Sites.py index 4aead295..759e1d79 100644 --- a/PLC/Sites.py +++ b/PLC/Sites.py @@ -186,5 +186,13 @@ class Sites(Table): elif isinstance(site_filter, dict): site_filter = Filter(Site.fields, site_filter) sql += " AND (%s)" % site_filter.sql(api, "AND") + elif isinstance (site_filter, StringTypes): + site_filter = Filter(Site.fields, {'login_base':[site_filter]}) + sql += " AND (%s)" % site_filter.sql(api, "AND") + elif isinstance (site_filter, int): + site_filter = Filter(Site.fields, {'site_id':[site_filter]}) + sql += " AND (%s)" % site_filter.sql(api, "AND") + else: + raise PLCInvalidArgument, "Wrong site filter %r"%site_filter self.selectall(sql) diff --git a/PLC/Slices.py b/PLC/Slices.py index d8962c45..88c0b579 100644 --- a/PLC/Slices.py +++ b/PLC/Slices.py @@ -155,5 +155,13 @@ class Slices(Table): elif isinstance(slice_filter, dict): slice_filter = Filter(Slice.fields, slice_filter) sql += " AND (%s)" % slice_filter.sql(api, "AND") + elif isinstance (slice_filter, StringTypes): + slice_filter = Filter(Slice.fields, {'name':[slice_filter]}) + sql += " AND (%s)" % slice_filter.sql(api, "AND") + elif isinstance (slice_filter, int): + slice_filter = Filter(Slice.fields, {'slice_id':[slice_filter]}) + sql += " AND (%s)" % slice_filter.sql(api, "AND") + else: + raise PLCInvalidArgument, "Wrong slice filter %r"%slice_filter self.selectall(sql) diff --git a/PLC/__init__.py b/PLC/__init__.py index fed5fa7f..5d41de2e 100644 --- a/PLC/__init__.py +++ b/PLC/__init__.py @@ -1 +1,46 @@ -all = 'Addresses AddressTypes API Auth Boot BootStates Cache ConfFiles Config Debug EventObjects Events Faults Filter GPG InitScripts Keys KeyTypes Messages Method NetworkMethods NetworkTypes NodeGroups NodeNetworkSettings NodeNetworkSettingTypes NodeNetworks Nodes Parameter PCUs Peers Persons POD PostgreSQL PyCurl Roles sendmail Sessions Shell Sites SliceAttributes SliceAttributeTypes SliceInstantiations Slices Table Test'.split() +all = """ +API +AddressTypes +Addresses +Auth +Boot +BootStates +ConfFiles +Config +Debug +EventObjects +Events +Faults +Filter +GPG +InitScripts +KeyTypes +Keys +Messages +Method +NetworkMethods +NetworkTypes +NodeGroups +NodeNetworkSettingTypes +NodeNetworkSettings +NodeNetworks +Nodes +PCUs +POD +Parameter +Peers +Persons +PostgreSQL +PyCurl +Roles +Sessions +Shell +Sites +SliceAttributeTypes +SliceAttributes +SliceInstantiations +Slices +Table +Test +sendmail +""".split() diff --git a/PLCAPI.spec b/PLCAPI.spec index 96e06eba..f96be933 100644 --- a/PLCAPI.spec +++ b/PLCAPI.spec @@ -1,7 +1,7 @@ Summary: PlanetLab Central API Name: PLCAPI -Version: 4.3 -Release: 2%{?pldistro:.%{pldistro}}%{?date:.%{date}} +Version: 4.1 +Release: 3%{?pldistro:.%{pldistro}}%{?date:.%{date}} License: PlanetLab Group: System Environment/Daemons URL: http://cvs.planet-lab.org/cvs/new_plc_api diff --git a/Test.py b/Test.py index 97811175..3e2e5aa2 100755 --- a/Test.py +++ b/Test.py @@ -5,7 +5,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: Test.py 502 2007-06-11 14:41:07Z thierry $ +# $Id: Test.py,v 1.23 2007/09/14 15:34:01 mef Exp $ # """ diff --git a/setup.py b/setup.py index 5df2a9e9..3f6ba5ca 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: setup.py,v 1.8 2007/01/30 11:48:14 thierry Exp $ +# $Id: setup.py,v 1.10 2007/10/01 20:51:46 tmack Exp $ # from distutils.core import setup @@ -13,7 +13,7 @@ from glob import glob setup(py_modules = ['ModPython'], packages = ['PLC', 'PLC/Methods', 'PLC/Methods/system'], - scripts = ['plcsh', 'Server.py', 'Test.py'], + scripts = ['plcsh', 'Server.py'], data_files = [('', ['planetlab4.sql']), ('php', ['php/plc_api.php']), ('migrations', ['migrations/README.txt'] + glob('migrations/[0-9][0-9][0-9]*')), -- 2.47.0