def setUp(self): self.config = testing.setUp() from budget.models import Base, AwsReservationInventory from sqlalchemy import create_engine engine = create_engine('sqlite://') DBSession.configure(bind=engine) Base.metadata.drop_all(engine) Base.metadata.create_all(engine) with transaction.manager: data = AwsReservationInventory( reservation_id='r-1234abcd', instance_type='instance type', availability_zone='availability_zone', account=1234567890, purchase_date=yesterday, expiration_date=tomorrow, instance_count=314159) DBSession.add(data) data = AwsReservationInventory( reservation_id='r-4567hijk', instance_type='instance type', availability_zone='availability_zone', account=1234567890, purchase_date=yesterday, expiration_date=yesterday, instance_count=602214) DBSession.add(data)
def setUp(self): self.config = testing.setUp() from budget.models import Base, AwsInstanceInventory from sqlalchemy import create_engine engine = create_engine('sqlite://') #FIxME if DBSession: DBSession.remove() DBSession.configure(bind=engine) Base.metadata.drop_all(engine) Base.metadata.create_all(engine) with transaction.manager: data = AwsInstanceInventory(name='instance1', environment='test', instance_id='i-1234abcd', instance_type='m42.ultrahuge', availability_zone='area-51', account=1234567890, status='running', launch_date=yesterday, check_date=today) DBSession.add(data) data = AwsInstanceInventory(name='instance2', environment='test', instance_id='i-4567hijk', instance_type='m42.ultrahuge', availability_zone='area-51', account=1234567890, status='stopped', launch_date=yesterday, check_date=today) DBSession.add(data)
def setUp(self): self.config = testing.setUp() from budget.models import Base, AwsReservationInventory from sqlalchemy import create_engine engine = create_engine('sqlite://') DBSession.configure(bind=engine) Base.metadata.drop_all(engine) Base.metadata.create_all(engine) with transaction.manager: data = AwsReservationInventory( reservation_id = 'r-1234abcd', instance_type = 'instance type', availability_zone = 'availability_zone', account = 1234567890, purchase_date = yesterday, expiration_date = tomorrow, instance_count = 314159 ) DBSession.add(data) data = AwsReservationInventory( reservation_id = 'r-4567hijk', instance_type = 'instance type', availability_zone = 'availability_zone', account = 1234567890, purchase_date = yesterday, expiration_date = yesterday, instance_count = 602214 ) DBSession.add(data)
def setUp(self): self.config = testing.setUp() from sqlalchemy import create_engine engine = create_engine('sqlite://') from budget.models import (Base, DBSession, AwsAccountMetadata) DBSession.configure(bind=engine) Base.metadata.drop_all(engine) Base.metadata.create_all(engine) with transaction.manager: meta = AwsAccountMetadata(account_id=0, account_name='account name', tags="Lorem,ipsum,dolor,sit,amet") DBSession.add(meta)
def setUp(self): self.config = testing.setUp() from sqlalchemy import create_engine engine = create_engine('sqlite://') DBSession.configure(bind=engine) Base.metadata.drop_all(engine) Base.metadata.create_all(engine) with transaction.manager: cost = AwsCostAllocation( invoice_id = 'invoice id', payer_account_id = 0, linked_account_id = 0, record_type = 'AccountTotal', record_id = 0, billing_period_start_date = yesterday, billing_period_end_date = today, invoice_date = today, payer_account_name = 'payer account name', linked_account_name = 'linked account name', taxation_address = 'tax address', payer_po_number = 0, product_code = 'product code', product_name = 'product name', seller_of_record = 'seller', usage_type = 'usage type', operation = 'operation', availability_zone = 'availability zone', rate_id = 0, item_description = 'description', usage_start_date = yesterday, usage_end_date = today, usage_quantity = 1.0001, blended_rate = 2.0002, currency_code = 'currency', cost_before_tax = 3.0003, credits = 4.0004, tax_amount = 5.0005, tax_type = 'tax', total_cost = 6.0006, user_environment = 'env', user_node = 'node' ) meta = AwsAccountMetadata( account_id = 0, account_name = 'linked account name', tags = "test" ) DBSession.add(meta) DBSession.add(cost)
def setUp(self): self.config = testing.setUp() from sqlalchemy import create_engine engine = create_engine('sqlite://') DBSession.configure(bind=engine) Base.metadata.drop_all(engine) Base.metadata.create_all(engine) with transaction.manager: node = Openshift3Node( collection_date = yesterday, create_date = yesterday, end_date = None, uid = '12345678-1234-5678-1234-567812345678', status = ''' status: addresses: - address: 10.0.0.1 type: InternalIP - address: 10.0.0.2 type: ExternalIP allocatable: cpu: "1" memory: 1024Ki pods: "10" capacity: cpu: "1" memory: 1024Ki pods: "10" conditions: - lastHeartbeatTime: 2001-01-01T12:01:00Z lastTransitionTime: 2001-01-01T12:01:00Z message: kubelet is posting ready status reason: KubeletReady status: "True" type: Ready ''', meta = ''' metadata: creationTimestamp: 2001-01-01T12:00:00Z labels: color: red type: compute name: test uid: 12345678-1234-5678-1234-567812345678 ''', cluster_id = 'test' ) DBSession.add(node)
def setUp(self): self.config = testing.setUp() from sqlalchemy import create_engine engine = create_engine('sqlite://') DBSession.configure(bind=engine) Base.metadata.drop_all(engine) Base.metadata.create_all(engine) with transaction.manager: node = Openshift3Node(collection_date=yesterday, create_date=yesterday, end_date=None, uid='12345678-1234-5678-1234-567812345678', status=''' status: addresses: - address: 10.0.0.1 type: InternalIP - address: 10.0.0.2 type: ExternalIP allocatable: cpu: "1" memory: 1024Ki pods: "10" capacity: cpu: "1" memory: 1024Ki pods: "10" conditions: - lastHeartbeatTime: 2001-01-01T12:01:00Z lastTransitionTime: 2001-01-01T12:01:00Z message: kubelet is posting ready status reason: KubeletReady status: "True" type: Ready ''', meta=''' metadata: creationTimestamp: 2001-01-01T12:00:00Z labels: color: red type: compute name: test uid: 12345678-1234-5678-1234-567812345678 ''', cluster_id='test') DBSession.add(node)
def setUp(self): self.config = testing.setUp() from budget.views.reservation import DataHolder self.tup = ('m4.xlarge', 'us-east-1a') dummy_inst = DataHolder( instance_type = self.tup[0], availability_zone = self.tup[1], ) dummy_rsrv = DataHolder( instance_type = self.tup[0], availability_zone = self.tup[1], instance_count = 5 ) self.dh = DataHolder( instance_type=self.tup[0], availability_zone=self.tup[1], instances={ '1234567890' : [ dummy_inst ] }, reservations={ '1234567890' : [ dummy_rsrv ] }, account='1234567890' ) from budget.models import Base, AwsPrice, AwsProduct from sqlalchemy import create_engine engine = create_engine('sqlite://') DBSession.configure(bind=engine) Base.metadata.drop_all(engine) Base.metadata.create_all(engine) with transaction.manager: data = AwsPrice( sku = 'test', offer_term_code = 'test1', price_dimensions = '{"test1.test1.test1": {"pricePerUnit": {"USD": "1"}, "appliesTo": [], "rateCode": "test.test.2TG2D8R56U", "unit": "Quantity", "description": "Upfront Fee"}, "test.test.test": {"description": "Linux/UNIX (Amazon VPC), m4.xlarge instance-hours used this month", "pricePerUnit": {"USD": "0.1234000000"}, "rateCode": "test.test.test", "endRange": "Inf", "beginRange": "0", "appliesTo": [], "unit": "Hrs"}}', term_attributes = '{"LeaseContractLength": "1yr", "PurchaseOption": "Partial Upfront"}', json = 'test1.test1' ) DBSession.add(data) data = AwsPrice( sku = 'test', offer_term_code = 'test2', price_dimensions = '{"test.test2.test2": {"description": "$0.79 per On Demand Linux m4.xlarge Instance Hour", "pricePerUnit": {"USD": "0.4567800000"}, "rateCode": "test.test2.test2", "endRange": "Inf", "beginRange": "0", "appliesTo": [], "unit": "Hrs"}}', term_attributes = '{}', json = 'test.test2' ) DBSession.add(data) data = AwsProduct( sku = 'test', location = 'US East (N. Virginia)', instance_type = 'm4.xlarge', current_generation = True, tenancy = 'Shared', usage_type = 'test:test', operation = 'test:test', operating_system = 'Linux', json = '{"sku": "test", "productFamily": "Compute Instance", "attributes": {"enhancedNetworkingSupported": "Yes", "networkPerformance": "High", "preInstalledSw": "NA", "instanceFamily": "Storage optimized", "vcpu": "9000", "locationType": "AWS Region", "usagetype": "test:test"", "storage": "100 x 100 MFM", "currentGeneration": "Yes", "operatingSystem": "Linux", "processorArchitecture": "8-bit", "tenancy": "Shared", "licenseModel": "No License required", "servicecode": "test", "memory": "1 ZiB", "processorFeatures": "Shiny; Hot; Metal", "clockSpeed": "0.1 MHz", "operation": "testStuff", "physicalProcessor": "IBM 8088", "instanceType": "m4.xlarge", "location": "US East (N. Virginia)"}}' ) DBSession.add(data)
def setUp(self): self.config = testing.setUp() from budget.models import Base, AwsInstanceInventory from sqlalchemy import create_engine engine = create_engine('sqlite://') #FIxME if DBSession: DBSession.remove() DBSession.configure(bind=engine) Base.metadata.drop_all(engine) Base.metadata.create_all(engine) with transaction.manager: data = AwsInstanceInventory( name = 'instance1', environment = 'test', instance_id = 'i-1234abcd', instance_type = 'm42.ultrahuge', availability_zone = 'area-51', account = 1234567890, status = 'running', launch_date = yesterday, check_date = today ) DBSession.add(data) data = AwsInstanceInventory( name = 'instance2', environment = 'test', instance_id = 'i-4567hijk', instance_type = 'm42.ultrahuge', availability_zone = 'area-51', account = 1234567890, status = 'stopped', launch_date = yesterday, check_date = today ) DBSession.add(data)
def setUp(self): self.config = testing.setUp() from budget.views.reservation import DataHolder self.tup = ('m4.xlarge', 'us-east-1a') dummy_inst = DataHolder( instance_type=self.tup[0], availability_zone=self.tup[1], ) dummy_rsrv = DataHolder(instance_type=self.tup[0], availability_zone=self.tup[1], instance_count=5) self.dh = DataHolder(instance_type=self.tup[0], availability_zone=self.tup[1], instances={'1234567890': [dummy_inst]}, reservations={'1234567890': [dummy_rsrv]}, account='1234567890') from budget.models import Base, AwsPrice, AwsProduct from sqlalchemy import create_engine engine = create_engine('sqlite://') DBSession.configure(bind=engine) Base.metadata.drop_all(engine) Base.metadata.create_all(engine) with transaction.manager: data = AwsPrice( sku='test', offer_term_code='test1', price_dimensions= '{"test1.test1.test1": {"pricePerUnit": {"USD": "1"}, "appliesTo": [], "rateCode": "test.test.2TG2D8R56U", "unit": "Quantity", "description": "Upfront Fee"}, "test.test.test": {"description": "Linux/UNIX (Amazon VPC), m4.xlarge instance-hours used this month", "pricePerUnit": {"USD": "0.1234000000"}, "rateCode": "test.test.test", "endRange": "Inf", "beginRange": "0", "appliesTo": [], "unit": "Hrs"}}', term_attributes= '{"LeaseContractLength": "1yr", "PurchaseOption": "Partial Upfront"}', json='test1.test1') DBSession.add(data) data = AwsPrice( sku='test', offer_term_code='test2', price_dimensions= '{"test.test2.test2": {"description": "$0.79 per On Demand Linux m4.xlarge Instance Hour", "pricePerUnit": {"USD": "0.4567800000"}, "rateCode": "test.test2.test2", "endRange": "Inf", "beginRange": "0", "appliesTo": [], "unit": "Hrs"}}', term_attributes='{}', json='test.test2') DBSession.add(data) data = AwsProduct( sku='test', location='US East (N. Virginia)', instance_type='m4.xlarge', current_generation=True, tenancy='Shared', usage_type='test:test', operation='test:test', operating_system='Linux', json= '{"sku": "test", "productFamily": "Compute Instance", "attributes": {"enhancedNetworkingSupported": "Yes", "networkPerformance": "High", "preInstalledSw": "NA", "instanceFamily": "Storage optimized", "vcpu": "9000", "locationType": "AWS Region", "usagetype": "test:test"", "storage": "100 x 100 MFM", "currentGeneration": "Yes", "operatingSystem": "Linux", "processorArchitecture": "8-bit", "tenancy": "Shared", "licenseModel": "No License required", "servicecode": "test", "memory": "1 ZiB", "processorFeatures": "Shiny; Hot; Metal", "clockSpeed": "0.1 MHz", "operation": "testStuff", "physicalProcessor": "IBM 8088", "instanceType": "m4.xlarge", "location": "US East (N. Virginia)"}}' ) DBSession.add(data)