X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=PLC%2FMethods%2FUpdateNodeNetwork.py;h=244647c1ef76e1d6267bc8b81f21776ad361016c;hb=b2e98f7a85d2589217303aeeff292b995aba47a8;hp=ca1e91fc73e88216d0cbdbbab4b170dfe4eed492;hpb=1f8c38dd1357c93e4be8d94456b7274a591d2db4;p=plcapi.git diff --git a/PLC/Methods/UpdateNodeNetwork.py b/PLC/Methods/UpdateNodeNetwork.py index ca1e91f..244647c 100644 --- a/PLC/Methods/UpdateNodeNetwork.py +++ b/PLC/Methods/UpdateNodeNetwork.py @@ -10,15 +10,15 @@ can_update = lambda (field, value): field not in \ class UpdateNodeNetwork(Method): """ - Updates an existing node network. Any values specified in update_fields - are used, otherwise defaults are used. Acceptable values for method are - dhcp and static. If type is static, the parameter update_fields must - be present and ip, gateway, network, broadcast, netmask, and dns1 must - all be specified. If type is dhcp, these parameters, even if - specified, are ignored. + Updates an existing node network. Any values specified in + nodenetwork_fields are used, otherwise defaults are + used. Acceptable values for method are dhcp and static. If type is + static, then ip, gateway, network, broadcast, netmask, and dns1 + must all be specified in nodenetwork_fields. If type is dhcp, + these parameters, even if specified, are ignored. PIs and techs may only update networks associated with their own - nodes. ins may update any node network. + nodes. Admins may update any node network. Returns 1 if successful, faults otherwise. """ @@ -29,18 +29,17 @@ class UpdateNodeNetwork(Method): accepts = [ Auth(), - Mixed(NodeNetwork.fields['nodenetwork_id'], - NodeNetwork.fields['ip']), + NodeNetwork.fields['nodenetwork_id'], nodenetwork_fields ] returns = Parameter(int, '1 if successful') - def call(self, auth, nodenetwork_id_or_ip, nodenetwork_fields): + def call(self, auth, nodenetwork_id, nodenetwork_fields): nodenetwork_fields = dict(filter(can_update, nodenetwork_fields.items())) # Get node network information - nodenetworks = NodeNetworks(self.api, [nodenetwork_id_or_ip]).values() + nodenetworks = NodeNetworks(self.api, [nodenetwork_id]) if not nodenetworks: raise PLCInvalidArgument, "No such node network" @@ -52,7 +51,7 @@ class UpdateNodeNetwork(Method): # If we are not an admin, make sure that the caller is a # member of the site where the node exists. if 'admin' not in self.caller['roles']: - nodes = Nodes(self.api, [nodenetwork['node_id']]).values() + nodes = Nodes(self.api, [nodenetwork['node_id']]) if not nodes: raise PLCPermissionDenied, "Node network is not associated with a node" node = nodes[0] @@ -63,4 +62,8 @@ class UpdateNodeNetwork(Method): nodenetwork.update(nodenetwork_fields) nodenetwork.sync() + self.object_ids = [nodenetwork['nodenetwork_id']] + self.message = "Node network %d updated: %s " % \ + (nodenetwork['nodenetwork_id'], ", ".join(nodenetwork_fields.keys())) + return 1