git://git.onelab.eu
/
plcapi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
allow node and anonymous authentication
[plcapi.git]
/
PLC
/
Methods
/
AddPCU.py
diff --git
a/PLC/Methods/AddPCU.py
b/PLC/Methods/AddPCU.py
index
3dec3ef
..
2d5b034
100644
(file)
--- a/
PLC/Methods/AddPCU.py
+++ b/
PLC/Methods/AddPCU.py
@@
-2,11
+2,11
@@
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.PCUs import PCU, PCUs
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.PCUs import PCU, PCUs
-from PLC.Auth import
Password
Auth
+from PLC.Auth import Auth
from PLC.Sites import Site, Sites
can_update = lambda (field, value): field in \
from PLC.Sites import Site, Sites
can_update = lambda (field, value): field in \
- ['hostname', 'protocol',
+ ['
ip', '
hostname', 'protocol',
'username', 'password',
'model', 'notes']
'username', 'password',
'model', 'notes']
@@
-23,23
+23,23
@@
class AddPCU(Method):
roles = ['admin', 'pi', 'tech']
roles = ['admin', 'pi', 'tech']
-
update
_fields = dict(filter(can_update, PCU.fields.items()))
+
pcu
_fields = dict(filter(can_update, PCU.fields.items()))
accepts = [
accepts = [
-
Password
Auth(),
+ Auth(),
Mixed(Site.fields['site_id'],
Site.fields['login_base']),
Mixed(Site.fields['site_id'],
Site.fields['login_base']),
- PCU.fields['ip'],
- update_fields
+ pcu_fields
]
returns = Parameter(int, 'New pcu_id (> 0) if successful')
]
returns = Parameter(int, 'New pcu_id (> 0) if successful')
+
- def call(self, auth, site_id_or_login_base,
ip, pcu_fields = {}
):
+ def call(self, auth, site_id_or_login_base,
pcu_fields
):
pcu_fields = dict(filter(can_update, pcu_fields.items()))
# Get associated site details
pcu_fields = dict(filter(can_update, pcu_fields.items()))
# Get associated site details
- sites = Sites(self.api, [site_id_or_login_base])
.values()
+ sites = Sites(self.api, [site_id_or_login_base])
if not sites:
raise PLCInvalidArgument, "No such site"
site = sites[0]
if not sites:
raise PLCInvalidArgument, "No such site"
site = sites[0]
@@
-50,7
+50,11
@@
class AddPCU(Method):
pcu = PCU(self.api, pcu_fields)
pcu['site_id'] = site['site_id']
pcu = PCU(self.api, pcu_fields)
pcu['site_id'] = site['site_id']
- pcu['ip'] = ip
pcu.sync()
pcu.sync()
+ # Logging variables
+ self.object_ids = [site['site_id'], pcu['pcu_id']]
+ self.message = 'PCU %d added site %s' % \
+ (pcu['pcu_id'], site['site_id'])
+
return pcu['pcu_id']
return pcu['pcu_id']