from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.Faults import *
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.Methods.AddInterfaceTag import AddInterfaceTag
from PLC.Methods.UpdateInterfaceTag import UpdateInterfaceTag
from PLC.Methods.AddInterfaceTag import AddInterfaceTag
from PLC.Methods.UpdateInterfaceTag import UpdateInterfaceTag
static, then ip, gateway, network, broadcast, netmask, and dns1
must all be specified in interface_fields. If type is dhcp,
these parameters, even if specified, are ignored.
static, then ip, gateway, network, broadcast, netmask, and dns1
must all be specified in interface_fields. If type is dhcp,
these parameters, even if specified, are ignored.
PIs and techs may only update interfaces associated with their own
nodes. Admins may update any interface network.
PIs and techs may only update interfaces associated with their own
nodes. Admins may update any interface network.
Returns 1 if successful, faults otherwise.
"""
roles = ['admin', 'pi', 'tech']
Returns 1 if successful, faults otherwise.
"""
roles = ['admin', 'pi', 'tech']
- accepted_fields = Row.accepted_fields(can_update, [Interface.fields,Interface.tags])
+ accepted_fields = Row.accepted_fields(cannot_update, Interface.fields,exclude=True)
+ accepted_fields.update(Interface.tags)
[native,tags,rejected] = Row.split_fields(interface_fields,[Interface.fields,Interface.tags])
[native,tags,rejected] = Row.split_fields(interface_fields,[Interface.fields,Interface.tags])
- # Get interface information
- interfaces = Interfaces(self.api, [interface_id])
- if not interfaces:
+ # Get interface information
+ interfaces = Interfaces(self.api, [interface_id])
+ if not interfaces:
# member of the site where the node exists.
if 'admin' not in self.caller['roles']:
nodes = Nodes(self.api, [interface['node_id']])
# member of the site where the node exists.
if 'admin' not in self.caller['roles']:
nodes = Nodes(self.api, [interface['node_id']])
if node['site_id'] not in self.caller['site_ids']:
raise PLCPermissionDenied, "Not allowed to update interface"
if node['site_id'] not in self.caller['site_ids']:
raise PLCPermissionDenied, "Not allowed to update interface"
for (tagname,value) in tags.iteritems():
# the tagtype instance is assumed to exist, just check that
if not TagTypes(self.api,{'tagname':tagname}):
for (tagname,value) in tags.iteritems():
# the tagtype instance is assumed to exist, just check that
if not TagTypes(self.api,{'tagname':tagname}):
- self.event_objects = {'Interface': [interface['interface_id']]}
- self.message = "Interface %d updated: %s " % \
- (interface['interface_id'], ", ".join(interface_fields.keys()))
+ self.event_objects = {'Interface': [interface['interface_id']]}
+ if 'ip' in interface:
+ self.message = "Interface %s updated"%interface['ip']
+ else:
+ self.message = "Interface %d updated"%interface['interface_id']
+ self.message += "[%s]." % ", ".join(interface_fields.keys())