Functions
samweb_client.admin Namespace Reference

Functions

def listApplications (samweb, queryCriteria)
 
def addApplication (samweb, family, name, version)
 
def listUsers (samweb)
 
def _describeUser (samweb, username, format=None)
 
def describeUser (samweb, username)
 
def describeUserText (samweb, username)
 
def addUser (samweb, username, firstname=None, lastname=None, email=None, uid=None, groups=None)
 
def modifyUser (samweb, username, args)
 
def getAvailableValues (samweb)
 
def listValues (samweb, vtype)
 
def addValue (samweb, vtype, args, kwargs)
 
def listParameters (samweb)
 
def listParameterValues (samweb, param)
 
def addParameter (samweb, name, data_type, category=None)
 
def listDataDisks (samweb)
 
def addDataDisk (samweb, mount_point)
 

Function Documentation

def samweb_client.admin._describeUser (   samweb,
  username,
  format = None 
)
private

Definition at line 21 of file admin.py.

21 def _describeUser(samweb, username, format=None):
22  params = {}
23  if format:
24  params['format'] = format
25  return samweb.getURL('/users/name/%s' % escape_url_path(username), params)
26 
27 @samweb_method
def _describeUser(samweb, username, format=None)
Definition: admin.py:21
def samweb_client.admin.addApplication (   samweb,
  family,
  name,
  version 
)

Definition at line 12 of file admin.py.

12 def addApplication(samweb, family, name, version):
13  return samweb.postURL('/values/applications', {"family":family, "name":name, "version":version}, secure=True, role='*').text.rstrip()
14 
15 @samweb_method
def addApplication(samweb, family, name, version)
Definition: admin.py:12
def samweb_client.admin.addDataDisk (   samweb,
  mount_point 
)
Add a new data disk to the database 
arguments:
    mount_point: The mount point for the new disk

Definition at line 124 of file admin.py.

124 def addDataDisk(samweb, mount_point):
125  """ Add a new data disk to the database
126  arguments:
127  mount_point: The mount point for the new disk
128  """
129  return samweb.postURL('/values/data_disks', {'mountpoint': mount_point}, secure=True, role='*')
130 
131 
def addDataDisk(samweb, mount_point)
Definition: admin.py:124
def samweb_client.admin.addParameter (   samweb,
  name,
  data_type,
  category = None 
)
Add a new parameter to the database
arguments:
    name: Parameter name (either just the name, or category.name)
    datatype: data type for new parameter

Definition at line 108 of file admin.py.

108 def addParameter(samweb, name, data_type, category=None):
109  """ Add a new parameter to the database
110  arguments:
111  name: Parameter name (either just the name, or category.name)
112  datatype: data type for new parameter
113  """
114  data = { 'name' : name, 'data_type' : data_type }
115  if category: data['category'] = category
116  return samweb.postURL('/values/parameters', data, secure=True, role='*')
117 
118 @samweb_method
def addParameter(samweb, name, data_type, category=None)
Definition: admin.py:108
def samweb_client.admin.addUser (   samweb,
  username,
  firstname = None,
  lastname = None,
  email = None,
  uid = None,
  groups = None 
)

Definition at line 38 of file admin.py.

References makeTrainCVSamples.int.

38 def addUser(samweb, username, firstname=None, lastname=None, email=None, uid=None, groups=None):
39 
40  userdata = { 'username' : username }
41  if firstname: userdata['first_name'] = firstname
42  if lastname: userdata['last_name'] = lastname
43  if email: userdata['email'] = email
44  if uid is not None:
45  try:
46  uid = int(uid)
47  except ValueError:
48  raise ArgumentError("Invalid value for uid: %s" % uid)
49  else:
50  userdata['uid'] = uid
51  if groups:
52  userdata["groups"] = groups
53  return samweb.postURL('/users', data=json.dumps(userdata), content_type='application/json', secure=True, role='*').text.rstrip()
54 
55 @samweb_method
def addUser(samweb, username, firstname=None, lastname=None, email=None, uid=None, groups=None)
Definition: admin.py:38
def samweb_client.admin.addValue (   samweb,
  vtype,
  args,
  kwargs 
)
Add a new value to the database
arguments:
    vtype: string giving the type of value to add ( ie data_tiers, groups)
    *args: arguments to pass to server
    **kwargs: keyword arguments to pass to server

Definition at line 77 of file admin.py.

References runNovaSAM.str.

77 def addValue(samweb, vtype, *args, **kwargs):
78  """ Add a new value to the database
79  arguments:
80  vtype: string giving the type of value to add ( ie data_tiers, groups)
81  *args: arguments to pass to server
82  **kwargs: keyword arguments to pass to server
83  """
84  # build the provided arguments into a parameter list. The args sequence is turned into multiple
85  # "value" parameters
86  postdata = dict(kwargs)
87  if args: postdata["value"] = [str(i) for i in args]
88  try:
89  return samweb.postURL('/values/%s' % escape_url_path(vtype), postdata, secure=True, role='*')
90  except HTTPNotFound, ex:
91  raise Error("Unknown value type '%s'" % vtype)
92 
93 @samweb_method
def addValue(samweb, vtype, args, kwargs)
Definition: admin.py:77
def samweb_client.admin.describeUser (   samweb,
  username 
)

Definition at line 28 of file admin.py.

References samweb_client.convert_from_unicode().

28 def describeUser(samweb, username):
29  result = samweb._describeUser(username)
30  return convert_from_unicode(result.json())
31 
32 @samweb_method
def describeUser(samweb, username)
Definition: admin.py:28
def convert_from_unicode(input)
Definition: __init__.py:14
def samweb_client.admin.describeUserText (   samweb,
  username 
)

Definition at line 33 of file admin.py.

33 def describeUserText(samweb, username):
34  result = samweb._describeUser(username, format='plain')
35  return result.text.rstrip()
36 
37 @samweb_method
def describeUserText(samweb, username)
Definition: admin.py:33
def samweb_client.admin.getAvailableValues (   samweb)
get the available names that can be used with listValues, addValues 

Definition at line 60 of file admin.py.

References samweb_client.convert_from_unicode(), and fabricate.json.

60 def getAvailableValues(samweb):
61  """ get the available names that can be used with listValues, addValues """
62  return convert_from_unicode(samweb.getURL('/values?list=generic').json())
63 
64 @samweb_method
def getAvailableValues(samweb)
Definition: admin.py:60
def convert_from_unicode(input)
Definition: __init__.py:14
def samweb_client.admin.listApplications (   samweb,
  queryCriteria 
)

Definition at line 7 of file admin.py.

References samweb_client.convert_from_unicode().

7 def listApplications(samweb, **queryCriteria):
8  result = samweb.getURL('/values/applications', queryCriteria)
9  return convert_from_unicode(result.json())
10 
11 @samweb_method
def listApplications(samweb, queryCriteria)
Definition: admin.py:7
def convert_from_unicode(input)
Definition: __init__.py:14
def samweb_client.admin.listDataDisks (   samweb)
list defined data disks 

Definition at line 119 of file admin.py.

References samweb_client.convert_from_unicode(), and fabricate.json.

119 def listDataDisks(samweb):
120  """ list defined data disks """
121  return convert_from_unicode(samweb.getURL('/values/data_disks').json())
122 
123 @samweb_method
def listDataDisks(samweb)
Definition: admin.py:119
def convert_from_unicode(input)
Definition: __init__.py:14
def samweb_client.admin.listParameters (   samweb)
list defined parameters 

Definition at line 94 of file admin.py.

References samweb_client.convert_from_unicode(), and fabricate.json.

94 def listParameters(samweb):
95  """ list defined parameters """
96  return convert_from_unicode(samweb.getURL('/values/parameters').json())
97 
98 @samweb_method
def convert_from_unicode(input)
Definition: __init__.py:14
def listParameters(samweb)
Definition: admin.py:94
def samweb_client.admin.listParameterValues (   samweb,
  param 
)
list the values for the given parameter
arguments:
    param: parameter name

Definition at line 99 of file admin.py.

References samweb_client.convert_from_unicode().

99 def listParameterValues(samweb, param):
100  """ list the values for the given parameter
101  arguments:
102  param: parameter name
103  """
104  result = samweb.getURL('/values/parameters/%s?format=json' % escape_url_path(param))
105  return convert_from_unicode(result.json())
106 
107 @samweb_method
def convert_from_unicode(input)
Definition: __init__.py:14
def listParameterValues(samweb, param)
Definition: admin.py:99
def samweb_client.admin.listUsers (   samweb)

Definition at line 16 of file admin.py.

References samweb_client.convert_from_unicode().

16 def listUsers(samweb):
17  result = samweb.getURL('/users')
18  return convert_from_unicode(result.json())
19 
20 @samweb_method
def convert_from_unicode(input)
Definition: __init__.py:14
def listUsers(samweb)
Definition: admin.py:16
def samweb_client.admin.listValues (   samweb,
  vtype 
)
list values from database. This method tries to be generic, so vtype is
passed directly to the web server
arguments:
    vtype: string with values to return (ie data_tiers, groups)

Definition at line 65 of file admin.py.

References samweb_client.convert_from_unicode(), and fabricate.json.

65 def listValues(samweb, vtype):
66  """ list values from database. This method tries to be generic, so vtype is
67  passed directly to the web server
68  arguments:
69  vtype: string with values to return (ie data_tiers, groups)
70  """
71  try:
72  return convert_from_unicode(samweb.getURL('/values/%s' % escape_url_path(vtype)).json())
73  except HTTPNotFound, ex:
74  raise Error("Unknown value type '%s'" % vtype)
75 
76 @samweb_method
def convert_from_unicode(input)
Definition: __init__.py:14
def listValues(samweb, vtype)
Definition: admin.py:65
def samweb_client.admin.modifyUser (   samweb,
  username,
  args 
)

Definition at line 56 of file admin.py.

56 def modifyUser(samweb, username, **args):
57  return samweb.postURL('/users/name/%s' % escape_url_path(username), data=json.dumps(args), content_type='application/json', secure=True).text.rstrip()
58 
59 @samweb_method
def modifyUser(samweb, username, args)
Definition: admin.py:56