cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
src.cm.models.user.User Class Reference

USER Model User's class for keeping quota. More...

Classes

class  Meta

Public Member Functions

def __unicode__
def check_points
 Check if used points is over the limit It raises exception in that case.
def check_quota
def check_storage
 Checks if User's storage quota is sufficient for image with given size.
def dict
def get_quota
def long_dict
def points_history
 Finds all User's VM's that have been working within current callendar month, which didn't fail at any stage of existence.
def used_cpu
def used_memory
def used_points
def used_storage

Static Public Member Functions

def create
 Method creates and returns CM User's data.
def get
 Returns the User instance by passed id.

Static Public Attributes

tuple cpu = models.IntegerField()
tuple memory = models.IntegerField()
tuple points = models.IntegerField()
tuple public_ip = models.IntegerField()
tuple storage = models.IntegerField()

Detailed Description

USER Model User's class for keeping quota.

To have the ability to create and manage VMs and to have access to other CC1 features one needs to have an User account. User's general data is stored and proceeded on CLM and that's where User authorization and authentication is performed. However, User's quota differs within CM's and not every User has granted access to each Cluster. Thats why User class exists also on CM and User's quota is stored here.

User quota is defined in "settings.py" file. It covers:

  • simultanous storage space usage,
  • simultanous CPU usage,
  • simultanous RAM memory usage,
  • IP requests count,
  • monthly points consumption.

Points a month are calculated based on overall monthly storage, CPU, and RAM usage.

By default each user gains quota speficied by CM settings. It may be further adjusted by admin via admin interface.

Definition at line 61 of file user.py.

Member Function Documentation

def src.cm.models.user.User.__unicode__ (   self)

Definition at line 72 of file user.py.

def src.cm.models.user.User.check_points (   self)

Check if used points is over the limit It raises exception in that case.

Definition at line 346 of file user.py.

def src.cm.models.user.User.check_quota (   self,
  template_count 
)
Todo:
Test template_count is a list of template objects?
     Method checks this User's quota for ability to run VMs based on
     given Template and it raises CMException, if it's exceeded:

     @param template_count

     @exception CMException('user_cpu_limit')
     @exception CMException('user_memory_limit')
     @exception CMException('user_storage_limit')
     @exception CMException('user_points_limit')

Definition at line 315 of file user.py.

def src.cm.models.user.User.check_storage (   self,
  size 
)

Checks if User's storage quota is sufficient for image with given size.

Parameters
size(int) size to fit within User's storage quota

Definition at line 334 of file user.py.

def src.cm.models.user.User.create (   user_id)
static

Method creates and returns CM User's data.

Quota is set to default defined in "settings.py" file.

Parameters
user_id(int) id of the CLM User to be stored on particular CM
Returns
(User) new instance of CM User referencing to CLM user with given id

Definition at line 152 of file user.py.

def src.cm.models.user.User.dict (   self)
Returns
(dict) user's data
fields:
  • id (int)
  • cpu (int) CPU total granted by User quota
  • memory (int) memory total [MB] granted by User quota
  • storage (int) storage total [MB] granted by User quota
  • public_ip (int) public IPs count total granted by User quota
  • used_points (int) points used within current month by User

Definition at line 98 of file user.py.

def src.cm.models.user.User.get (   user_id)
static

Returns the User instance by passed id.

Parameters
user_id(int) id of the requested User
Returns
(User) instance of requested User
Exceptions
CMException('user_get')cannot get user

Definition at line 361 of file user.py.

def src.cm.models.user.User.get_quota (   self,
  fields = None,
  used = True,
  total = True 
)

Definition at line 75 of file user.py.

def src.cm.models.user.User.long_dict (   self)
Returns
(dict) user's extended data in dictionary format.
fields:
  • id (int)
  • cpu (int) CPU total granted by User quota
  • memory (int) memory total [MB] granted by User quota
  • storage (int) storage total [MB] granted by User quota
  • public_ip (int) public IPs count total granted by User quota
  • points (int) points total granted by User quota
  • used_cpu (int) cpu currently used by User
  • used_memory (int) memory currently used by User
  • used_storage (int) storage currently used by User
  • used_public_ip (int) public IPs count currently used by User
  • used_points (int) points used within current month by User

Definition at line 126 of file user.py.

def src.cm.models.user.User.points_history (   self)

Finds all User's VM's that have been working within current callendar month, which didn't fail at any stage of existence.

Counts points for those VMs consumed within current month. Failed VMs don't count.

Returns
(dict)
fields:
  • points (list(list)) infos about points used in specified moments of time
  • limit (int) User's quota for points per month

Definition at line 252 of file user.py.

def src.cm.models.user.User.used_cpu (   self)
Returns
(int) CPU being used by User the moment of call

Definition at line 170 of file user.py.

def src.cm.models.user.User.used_memory (   self)
Returns
(int) memory being used by User [MB] the moment of call

Definition at line 181 of file user.py.

def src.cm.models.user.User.used_points (   self)
Returns
(int) points consumed by VMs of this User's that have been working within current calendar month. Those might either have been started the previous month and be still running during months break, or be just started in current month. Those may be still running or already closed VMs.

Definition at line 209 of file user.py.

def src.cm.models.user.User.used_storage (   self)
Returns
(int) storage being used by User [MB] the moment of call

Definition at line 193 of file user.py.

Member Data Documentation

tuple src.cm.models.user.User.cpu = models.IntegerField()
static

Definition at line 63 of file user.py.

tuple src.cm.models.user.User.memory = models.IntegerField()
static

Definition at line 62 of file user.py.

tuple src.cm.models.user.User.points = models.IntegerField()
static

Definition at line 66 of file user.py.

tuple src.cm.models.user.User.public_ip = models.IntegerField()
static

Definition at line 65 of file user.py.

tuple src.cm.models.user.User.storage = models.IntegerField()
static

Definition at line 64 of file user.py.


The documentation for this class was generated from the following file: