object_type = 'AddressType'
object_ids = []
- def call(self, auth, address_type_fields = {}):
+ def call(self, auth, address_type_fields):
address_type_fields = dict(filter(can_update, address_type_fields.items()))
address_type = AddressType(self.api, address_type_fields)
address_type.sync()
object_type = 'ConfFile'
object_ids = []
- def call(self, auth, conf_file_fields = {}):
+ def call(self, auth, conf_file_fields):
conf_file_fields = dict(filter(can_update, conf_file_fields.items()))
conf_file = ConfFile(self.api, conf_file_fields)
conf_file.sync()
from PLC.Auth import PasswordAuth
can_update = lambda (field, value): field in \
- ['hostname', 'site_id', 'boot_state', 'model', 'version']
+ ['hostname', 'boot_state', 'model', 'version']
class AddNode(Method):
"""
accepts = [
PasswordAuth(),
+ Mixed(Site.fields['site_id'],
+ Site.fields['login_base']),
node_fields
]
object_type = 'Node'
object_ids = []
- def call(self, auth, node_fields = {}):
+ def call(self, auth, site_id_or_login_base, node_fields):
node_fields = dict(filter(can_update, node_fields.items()))
-
+
# Get site information
- sites = Sites(self.api, [node_fields['site_id']])
+ sites = Sites(self.api, [site_id_or_login_base])
if not sites:
raise PLCInvalidArgument, "No such site"
assert self.caller['person_id'] in site['person_ids']
node = Node(self.api, node_fields)
+ node['site_id'] = site['site_id']
node.sync()
self.object_ids = [site['site_id'], node['node_id']]
object_type = 'NodeGroup'
object_ids = []
- def call(self, auth, nodegroup_fields = {}):
+ def call(self, auth, nodegroup_fields):
nodegroup_fields = dict(filter(can_update, nodegroup_fields.items()))
nodegroup = NodeGroup(self.api, nodegroup_fields)
nodegroup.sync()
from PLC.NodeNetworks import NodeNetwork, NodeNetworks
from PLC.Auth import PasswordAuth
-can_update = lambda (field, value): field not in ['nodenetwork_id']
+can_update = lambda (field, value): field not in ['nodenetwork_id', 'node_id']
class AddNodeNetwork(Method):
"""
+
Adds a new network for a node. Any values specified in
- nodenetwork_fields are used, otherwise defaults are used. Acceptable
- values for method are dhcp, static, proxy, tap, and
- ipmi. Acceptable value for type is ipv4. If type is static, 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 add networks to their own nodes. ins may
+ nodenetwork_fields are used, otherwise defaults are
+ used. Acceptable values for method may be retrieved via
+ GetNetworkMethods. Acceptable values for type may be retrieved via
+ GetNetworkTypes.
+
+ If type is static, 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 add networks to their own nodes. Admins may
add networks to any node.
Returns the new nodenetwork_id (> 0) if successful, faults otherwise.
accepts = [
PasswordAuth(),
+ Mixed(Node.fields['node_id'],
+ Node.fields['hostname']),
nodenetwork_fields
]
object_type = 'NodeNetwork'
object_ids = []
- def call(self, auth, nodenetwork_fields = {}):
+ def call(self, auth, node_id_or_hostname, nodenetwork_fields):
nodenetwork_fields = dict(filter(can_update, nodenetwork_fields.items()))
# Check if node exists
- nodes = Nodes(self.api, [nodenetwork_fields['node_id']]).values()
+ nodes = Nodes(self.api, [node_id_or_hostname]).values()
if not nodes:
raise PLCInvalidArgument, "No such node"
node = nodes[0]
# Add node network
nodenetwork = NodeNetwork(self.api, nodenetwork_fields)
+ nodenetwork['node_id'] = node['node_id']
nodenetwork.sync()
self.object_ids = [node['node_id'], nodenetwork['nodenetwork_id']]
from PLC.Sites import Site, Sites
can_update = lambda (field, value): field in \
- ['site_id',
- 'ip', 'hostname', 'protocol',
+ ['ip', 'hostname', 'protocol',
'username', 'password',
'model', 'notes']
accepts = [
PasswordAuth(),
+ Mixed(Site.fields['site_id'],
+ Site.fields['login_base']),
pcu_fields
]
object_type = 'PCU'
object_ids = []
- def call(self, auth, 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
- sites = Sites(self.api, [pcu_fields['site_id']]).values()
+ sites = Sites(self.api, [site_id_or_login_base]).values()
if not sites:
raise PLCInvalidArgument, "No such site"
site = sites[0]
raise PLCPermissionDenied, "Not allowed to add a PCU to that site"
pcu = PCU(self.api, pcu_fields)
+ pcu['site_id'] = site['site_id']
pcu.sync()
self.object_ids = [site['site_id'], pcu['pcu_id']]
object_type = 'Person'
object_ids = []
- def call(self, auth, person_fields = {}):
+ def call(self, auth, person_fields):
person_fields = dict(filter(can_update, person_fields.items()))
person = Person(self.api, person_fields)
person.sync()
object_type = 'Address'
object_ids = []
- def call(self, auth, site_id_or_login_base, address_fields = {}):
+ def call(self, auth, site_id_or_login_base, address_fields):
address_fields = dict(filter(can_update, address_fields.items()))
# Get associated site details
object_type = 'Slice'
object_ids = []
- def call(self, auth, slice_fields = {}):
+ def call(self, auth, slice_fields):
slice_fields = dict(filter(can_update, slice_fields.items()))
# 1. Lowercase.
object_type = 'SliceAttributeType'
object_ids = []
- def call(self, auth, attribute_type_fields = {}):
+ def call(self, auth, attribute_type_fields):
attribute_type_fields = dict(filter(can_update, attribute_type_fields.items()))
attribute_type = SliceAttributeType(self.api, attribute_type_fields)
attribute_type.sync()
from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
-from PLC.Auth import PasswordAuth
+from PLC.Auth import PasswordAuth, BootAuth
class AuthCheck(Method):
"""
- Returns 1 if the user authenticated successfully, faults
+ Returns 1 if the user or node authenticated successfully, faults
otherwise.
"""
roles = ['admin', 'pi', 'user', 'tech']
- accepts = [PasswordAuth()]
+ accepts = [Mixed(PasswordAuth(), BootAuth())]
returns = Parameter(int, '1 if successful')
def call(self, auth):
--- /dev/null
+from PLC.Methods.AuthCheck import AuthCheck
+
+class BootCheckAuthentication(AuthCheck):
+ """
+ Deprecated. See AuthCheck.
+ """
+
+ status = "deprecated"
--- /dev/null
+from PLC.Method import Method
+from PLC.Parameter import Parameter, Mixed
+from PLC.Auth import PasswordAuth, BootAuth
+
+class BootUpdateNode(Method):
+ """
+ Allows the calling node to update its own record. Only the primary
+ network can be updated, and the node IP cannot be changed.
+
+ Returns 1 if updated successfully.
+ """
+
+ accepts = [BootAuth(), dict]
+ returns = Parameter(int, '1 if successful')
+
+ def call(self, auth, update_fields):
+ # XXX
+ return 1
roles = ['admin', 'pi']
address_fields = dict(filter(can_update, Address.fields.items()))
- for field in address_fields.values():
- field.optional = True
accepts = [
PasswordAuth(),
roles = ['admin']
address_type_fields = dict(filter(can_update, AddressType.fields.items()))
- for field in address_type_fields.values():
- field.optional = True
accepts = [
PasswordAuth(),
roles = ['admin']
conf_file_fields = dict(filter(can_update, ConfFile.fields.items()))
- for field in conf_file_fields.values():
- field.optional = True
accepts = [
PasswordAuth(),
roles = ['admin', 'pi', 'tech', 'user']
key_fields = dict(filter(can_update, Key.fields.items()))
- for field in key_fields.values():
- field.optional = True
accepts = [
PasswordAuth(),
roles = ['admin', 'pi', 'tech']
node_fields = dict(filter(can_update, Node.fields.items()))
- for field in node_fields.values():
- field.optional = True
accepts = [
PasswordAuth(),
roles = ['admin']
nodegroup_fields = dict(filter(can_update, NodeGroup.fields.items()))
- for field in nodegroup_fields.values():
- field.optional = True
accepts = [
PasswordAuth(),
returns = Parameter(int, '1 if successful')
- def call(self, auth, nodegroup_id_or_name, nodegroup_fields = {}):
+ def call(self, auth, nodegroup_id_or_name, nodegroup_fields):
nodegroup_fields = dict(filter(can_update, nodegroup_fields.items()))
# Get nodegroup information
roles = ['admin', 'pi', 'tech']
nodenetwork_fields = dict(filter(can_update, NodeNetwork.fields.items()))
- for field in nodenetwork_fields.values():
- field.optional = True
accepts = [
PasswordAuth(),
"""
Updates a person. Only the fields specified in person_fields are
updated, all other fields are left untouched.
-
- To remove a value without setting a new one in its place (for
- example, to remove an address from the person), specify -1 for int
- and double fields and 'null' for string fields. first_name and
- last_name cannot be unset.
Users and techs can only update themselves. PIs can only update
themselves and other non-PIs at their sites.
roles = ['admin', 'pi', 'user', 'tech']
person_fields = dict(filter(can_update, Person.fields.items()))
- for field in person_fields.values():
- field.optional = True
accepts = [
PasswordAuth(),
Updates a site. Only the fields specified in update_fields are
updated, all other fields are left untouched.
- To remove a value without setting a new one in its place (for
- example, to remove an address from the node), specify -1 for int
- and double fields and 'null' for string fields. hostname and
- boot_state cannot be unset.
-
PIs can only update sites they are a member of. Only admins can
update max_slices.
roles = ['admin', 'pi']
site_fields = dict(filter(can_update, Site.fields.items()))
- for field in site_fields.values():
- field.optional = True
accepts = [
PasswordAuth(),
roles = ['admin', 'pi', 'user']
slice_fields = dict(filter(can_update, Slice.fields.items()))
- for field in slice_fields.values():
- field.optional = True
accepts = [
PasswordAuth(),
roles = ['admin']
attribute_type_fields = dict(filter(can_update, SliceAttributeType.fields.items()))
- for field in attribute_type_fields.values():
- field.optional = True
accepts = [
PasswordAuth(),
attribute_type = attribute_types[0]
attribute_type.update(attribute_type_fields)
-
attribute_type.sync()
return 1
-methods = 'AddAddressType AddAddressTypeToAddress AddBootState AddConfFile AddConfFileToNodeGroup AddConfFileToNode AddKeyType AddNetworkMethod AddNetworkType AddNodeGroup AddNodeNetwork AddNode AddNodeToNodeGroup AddNodeToPCU AddPCU AddPersonKey AddPerson AddPersonToSite AddPersonToSlice AddRole AddRoleToPerson AddSiteAddress AddSite AddSliceAttribute AddSliceAttributeType AddSlice AddSliceToNodes 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 AuthCheck BlacklistKey DeleteAddress DeleteAddressTypeFromAddress DeleteAddressType DeleteBootState DeleteConfFileFromNodeGroup DeleteConfFileFromNode DeleteConfFile DeleteKey DeleteKeyType DeleteNetworkMethod DeleteNetworkType DeleteNodeFromNodeGroup DeleteNodeFromPCU DeleteNodeGroup DeleteNodeNetwork DeleteNode DeletePCU DeletePersonFromSite DeletePersonFromSlice DeletePerson DeleteRoleFromPerson DeleteRole DeleteSite DeleteSliceAttribute DeleteSliceAttributeType DeleteSliceFromNodes DeleteSlice GetAddresses GetAddressTypes GetBootStates GetConfFiles GetEvents GetKeys GetKeyTypes GetNetworkMethods GetNetworkTypes GetNodeGroups GetNodeNetworks GetNodes GetPCUs GetPersons GetRoles GetSites GetSliceAttributes GetSliceAttributeTypes GetSlices GetSlivers RebootNode SetPersonPrimarySite SliceCreate SliceDelete UpdateAddress UpdateAddressType UpdateConfFile UpdateKey UpdateNodeGroup UpdateNodeNetwork UpdateNode UpdatePCU UpdatePerson UpdateSite UpdateSliceAttribute UpdateSliceAttributeType UpdateSlice system.listMethods system.methodHelp system.methodSignature system.multicall'.split()
+methods = 'AddAddressType AddAddressTypeToAddress AddBootState AddConfFile AddConfFileToNodeGroup AddConfFileToNode AddKeyType AddNetworkMethod AddNetworkType AddNodeGroup AddNodeNetwork AddNode AddNodeToNodeGroup AddNodeToPCU AddPCU AddPersonKey AddPerson AddPersonToSite AddPersonToSlice AddRole AddRoleToPerson AddSiteAddress AddSite AddSliceAttribute AddSliceAttributeType AddSlice AddSliceToNodes 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 AuthCheck BlacklistKey BootCheckAuthentication BootUpdateNode DeleteAddress DeleteAddressTypeFromAddress DeleteAddressType DeleteBootState DeleteConfFileFromNodeGroup DeleteConfFileFromNode DeleteConfFile DeleteKey DeleteKeyType DeleteNetworkMethod DeleteNetworkType DeleteNodeFromNodeGroup DeleteNodeFromPCU DeleteNodeGroup DeleteNodeNetwork DeleteNode DeletePCU DeletePersonFromSite DeletePersonFromSlice DeletePerson DeleteRoleFromPerson DeleteRole DeleteSite DeleteSliceAttribute DeleteSliceAttributeType DeleteSliceFromNodes DeleteSlice GetAddresses GetAddressTypes GetBootStates GetConfFiles GetEvents GetKeys GetKeyTypes GetNetworkMethods GetNetworkTypes GetNodeGroups GetNodeNetworks GetNodes GetPCUs GetPersons GetRoles GetSites GetSliceAttributes GetSliceAttributeTypes GetSlices GetSlivers RebootNode SetPersonPrimarySite SliceCreate SliceDelete UpdateAddress UpdateAddressType UpdateConfFile UpdateKey UpdateNodeGroup UpdateNodeNetwork UpdateNode UpdatePCU UpdatePerson UpdateSite UpdateSliceAttribute UpdateSliceAttributeType UpdateSlice system.listMethods system.methodHelp system.methodSignature system.multicall'.split()