def new_compute_rate(): # Create a new Compute Chargeback rate try: desc = 'custom_' + fauxfactory.gen_alphanumeric() compute = cb.ComputeRate(description=desc, fields={ 'Used CPU': { 'per_time': 'Hourly', 'variable_rate': '3' }, 'Used Disk I/O': { 'per_time': 'Hourly', 'variable_rate': '2' }, 'Used Memory': { 'per_time': 'Hourly', 'variable_rate': '2' } }) compute.create() storage = cb.StorageRate(description=desc, fields={ 'Used Disk Storage': { 'per_time': 'Hourly', 'variable_rate': '3' } }) storage.create() yield desc finally: compute.delete() storage.delete()
def new_compute_rate(): return cb.ComputeRate(description='cb' + random.generate_random_string(), cpu_alloc=(1000, cb.DAILY), disk_io=(10, cb.DAILY), compute_fixed_1=(100, cb.MONTHLY), compute_fixed_2=(200, cb.DAILY), mem_alloc=(10000, cb.MONTHLY), mem_used=(4000, cb.WEEKLY), net_io=(6000, cb.WEEKLY))
def new_compute_rate(): return cb.ComputeRate(description='cb' + fauxfactory.gen_alphanumeric(), cpu_alloc=(1000, cb.DAILY), disk_io=(10, cb.DAILY), compute_fixed_1=(100, cb.MONTHLY), compute_fixed_2=(200, cb.DAILY), mem_alloc=(10000, cb.MONTHLY), mem_used=(4000, cb.WEEKLY), net_io=(6000, cb.WEEKLY))
def chargeback_compute_rate(): return cb.ComputeRate( description='cb' + fauxfactory.gen_alphanumeric(), fields={ 'Allocated CPU Count': with_random_per_time(fixed_rate='1000'), 'Used Disk I/O': with_random_per_time(fixed_rate='10'), 'Fixed Compute Cost 1': with_random_per_time(fixed_rate='100'), 'Used Memory': with_random_per_time(fixed_rate='6000'), 'Used CPU Cores': {'variable_rate': '0.05'} })
def new_compute_rate(): return cb.ComputeRate(description='cb' + fauxfactory.gen_alphanumeric(), fields={'Allocated CPU Count': {'per_time': random.choice(per_time), 'fixed_rate': '1000'}, 'Used Disk I/O': {'per_time': random.choice(per_time), 'fixed_rate': '10'}, 'Fixed Compute Cost 1': {'per_time': random.choice(per_time), 'fixed_rate': '100'}, 'Used Memory': {'per_time': random.choice(per_time), 'fixed_rate': '6000'}, 'Used CPU Cores': {'variable_rate': '0.05'}})
def new_compute_rate(): # Create a new Chargeback compute rate try: desc = 'custom_' + fauxfactory.gen_alphanumeric() ccb = cb.ComputeRate(description=desc, cpu_used_var=(3, cb.HOURLY), disk_io_var=(1, cb.HOURLY), mem_alloc=(0, cb.HOURLY), mem_used_var=(2, cb.HOURLY), net_io_var=(2, cb.HOURLY)) ccb.create() yield desc finally: ccb.delete()
def new_chargeback_rate(appliance, include_variable_rates=True): # Create a new Chargeback compute rate def rand_float_str(): return str(round(random() * fauxfactory.gen_integer(1, 20), 2)) def gen_var_rate(): return (rand_float_str() if include_variable_rates else 0) description = 'custom_rate_' + fauxfactory.gen_alphanumeric() data = { 'Used CPU Cores': { 'per_time': 'Hourly', 'fixed_rate': fauxfactory.gen_integer(1, 4), 'variable_rate': gen_var_rate() }, 'Fixed Compute Cost 1': { 'per_time': 'Hourly', 'fixed_rate': rand_float_str() }, 'Fixed Compute Cost 2': { 'per_time': 'Hourly', 'fixed_rate': rand_float_str() }, 'Used Memory': { 'per_time': 'Hourly', 'fixed_rate': rand_float_str(), 'variable_rate': gen_var_rate() }, 'Used Network I/O': { 'per_time': 'Hourly', 'fixed_rate': rand_float_str(), 'variable_rate': gen_var_rate() } } ccb = cb.ComputeRate(description, fields=data, appliance=appliance) ccb.create() return ccb