2012-06-06 01:32:05 +04:00
/* -------------------------------------------------------------------------- */
2019-01-16 13:27:59 +03:00
/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */
2012-06-06 01:32:05 +04:00
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
# ifndef QUOTA_IMAGE_H_
# define QUOTA_IMAGE_H_
# include "Quota.h"
/**
* Image Quotas , defined as :
* IMAGE = [
2012-06-07 21:31:16 +04:00
* ID = < ID of the image >
* RVMS = < Max . number times the image can be instantiated >
* RVMS _USED = Current number of VMs using the image
2012-06-06 01:32:05 +04:00
* ]
*
* 0 = unlimited , default if missing
*/
class QuotaImage : public Quota
{
public :
2012-11-30 03:16:52 +04:00
QuotaImage ( bool is_default ) :
Quota ( " IMAGE_QUOTA " ,
" IMAGE " ,
IMAGE_METRICS ,
NUM_IMAGE_METRICS ,
is_default )
2012-06-06 01:32:05 +04:00
{ } ;
~ QuotaImage ( ) { } ;
/**
2012-11-30 03:16:52 +04:00
* Check if the resource allocation will exceed the quota limits . If not
2012-06-06 01:32:05 +04:00
* the usage counters are updated
* @ param tmpl template for the resource
2012-11-19 19:38:39 +04:00
* @ param default_quotas Quotas that contain the default limits
2012-11-30 03:16:52 +04:00
* @ param error string
2012-06-06 01:32:05 +04:00
* @ return true if the operation can be performed
*/
2012-11-19 19:38:39 +04:00
bool check ( Template * tmpl , Quotas & default_quotas , string & error ) ;
2012-06-06 01:32:05 +04:00
/**
* Decrement usage counters when deallocating image
* @ param tmpl template for the resource
*/
void del ( Template * tmpl ) ;
protected :
2012-11-19 18:19:09 +04:00
/**
* Gets the default quota identified by its ID .
*
* @ param id of the quota
2012-11-19 19:38:39 +04:00
* @ param default_quotas Quotas that contain the default limits
2012-11-19 18:19:09 +04:00
* @ param va The quota , if it is found
*
* @ return 0 on success , - 1 if not found
*/
2012-11-19 19:38:39 +04:00
int get_default_quota ( const string & id ,
Quotas & default_quotas ,
VectorAttribute * * va ) ;
2012-11-19 18:19:09 +04:00
2012-06-06 01:32:05 +04:00
static const char * IMAGE_METRICS [ ] ;
static const int NUM_IMAGE_METRICS ;
} ;
# endif /*QUOTA_IMAGE_H_*/