def _create_database_structure(cls): mysql_host = settings.DB_HOST mysql_port = settings.DB_PORT or 3306 cls.mysql_endpoint = '{}:{}'.format(mysql_host, mysql_port) cls.engine_type = factory_physical.EngineTypeFactory(name='mysql') cls.engine = factory_physical.EngineFactory( engine_type=cls.engine_type) cls.disk_offering = factory_physical.DiskOfferingFactory( size_kb=524288) cls.plan = factory_physical.PlanFactory( disk_offering=cls.disk_offering, engine=cls.engine) cls.databaseinfra = factory_physical.DatabaseInfraFactory( name="__test__ mysqlinfra2", user="******", password=settings.DB_PASSWORD, endpoint=cls.mysql_endpoint, engine=cls.engine, disk_offering=cls.disk_offering, plan=cls.plan) cls.hostname = factory_physical.HostFactory() cls.instance = factory_physical.InstanceFactory( address="new_instance.localinstance", port=123, is_active=True, instance_type=Instance.MYSQL, databaseinfra=cls.databaseinfra, hostname=cls.hostname) cls.database = factory_logical.DatabaseFactory( name='test_db_1', databaseinfra=cls.databaseinfra, ) cls.nfsaas_host_attr = factory_physical.NFSaaSHostAttr( host=cls.hostname, # nfsaas_size_kb=cls.database.total_size_in_kb, nfsaas_used_size_kb=cls.database.used_size_in_kb)
def setUp(self): self.today = FAKE_TODAY self.engine_type = factory_physical.EngineTypeFactory(name='mysql') self.engine = factory_physical.EngineFactory( engine_type=self.engine_type) self.plan = factory_physical.PlanFactory(engine=self.engine) self.databaseinfra = factory_physical.DatabaseInfraFactory( name="__test__ mysqlinfra2", user="******", password='******', engine=self.engine, plan=self.plan, ssl_configured=True) self.hostname = factory_physical.HostFactory(ssl_expire_at=FAKE_TODAY + timedelta(days=16)) self.instances = self.instance_helper.create_instances_by_quant( instance_type=Instance.MYSQL, qt=1, infra=self.databaseinfra, hostname=self.hostname) self.instance = self.instances[0] self.database = factory_logical.DatabaseFactory( name='test_db_1', databaseinfra=self.databaseinfra, ) self.one_month_later = self.today + timedelta(days=30)
def handle(self, *args, **options): # engine was created by initial_data.yml my_engine = Engine.objects.get(version='2.4.10', engine_type__name='mongodb') my_host = factory.HostFactory(hostname='localhost') my_env = factory.EnvironmentFactory(name='laboratory') my_plan = factory.PlanFactory(name='small', engine_type=my_engine.engine_type, environments=[my_env]) my_infradb = factory.DatabaseInfraFactory(name='local_infra', plan=my_plan, environment=my_env, engine=my_engine, capacity=10) factory.InstanceFactory(databaseinfra=my_infradb, hostname=my_host) my_role = Role.objects.get_or_create(name="role_dba")[0] organization = Organization.objects.get_or_create( name='fake_organization')[0] my_team = Team.objects.get_or_create(name="my team", role=my_role, organization=organization)[0] my_admin = User.objects.create_superuser('admin', email='*****@*****.**', password='******') my_team.users.add(my_admin)
def _create_database_structure(cls): mysql_host = settings.DB_HOST mysql_port = settings.DB_PORT or 3306 cls.mysql_endpoint = '{}:{}'.format(mysql_host, mysql_port) cls.engine_type = factory_physical.EngineTypeFactory(name=cls.ENGINE) cls.engine = factory_physical.EngineFactory( engine_type=cls.engine_type) cls.disk_offering = factory_physical.DiskOfferingFactory( size_kb=524288) cls.plan = factory_physical.PlanFactory( disk_offering=cls.disk_offering, engine=cls.engine) cls.databaseinfra = factory_physical.DatabaseInfraFactory( name="__test__ mysqlinfra2", user="******", password=settings.DB_PASSWORD, endpoint=cls.mysql_endpoint, engine=cls.engine, disk_offering=cls.disk_offering, plan=cls.plan) cls.hostname = factory_physical.HostFactory() cls.instances = cls.instance_helper.create_instances_by_quant( instance_type=Instance.MYSQL, qt=cls.instances_quantity, infra=cls.databaseinfra, hostname=cls.hostname) cls.instance = cls.instances[0] cls.database = factory_logical.DatabaseFactory( name='test_db_1', databaseinfra=cls.databaseinfra, ) cls.volume = factory_physical.VolumeFactory( host=cls.hostname, used_size_kb=cls.database.used_size_in_kb)
def _create_database(self, env_name='fake_env', infra_name='__test__ mysqlinfra2'): environment = factory_physical.EnvironmentFactory( name=env_name ) databaseinfra = factory_physical.DatabaseInfraFactory( name=infra_name, user="******", password='******', engine=self.engine, plan=self.plan, ssl_configured=True, environment=environment ) hostname = factory_physical.HostFactory( ssl_expire_at=FAKE_TODAY + timedelta(days=16) ) self.instance_helper.create_instances_by_quant( instance_type=Instance.MYSQL, qt=1, infra=databaseinfra, hostname=hostname ) database = factory_logical.DatabaseFactory( name='test_db_1', databaseinfra=databaseinfra, ) return environment, databaseinfra, hostname, database
def setUpClass(cls): cls.databaseinfra = factory.DatabaseInfraFactory( name="__test__ mysqlinfra", user="******", password='******') cls.hostname = factory.HostFactory() cls.instance = factory.InstanceFactory( address="new_instance.localinstance", port=123, is_active=True, databaseinfra=cls.databaseinfra, hostname=cls.hostname) cls.nfaas_host_attr = factory.NFSaaSHostAttr(host=cls.hostname) cs_offering = factory.CloudStackOfferingFactory(memory_size_mb=9) cls.infra_offering = factory.DatabaseInfraOfferingFactory( databaseinfra=cls.databaseinfra, offering=cs_offering)
def setUpClass(cls, instances_mock): cls.databaseinfra = factory.DatabaseInfraFactory( name="__test__ mysqlinfra", user="******", password='******') cls.hostname = factory.HostFactory() cls.instance = factory.InstanceFactory( address="new_instance.localinstance", port=123, is_active=True, databaseinfra=cls.databaseinfra, hostname=cls.hostname) cls.volume = factory.VolumeFactory(host=cls.hostname) offering = factory.OfferingFactory(memory_size_mb=9) offering.environments.add(cls.databaseinfra.environment) plan = cls.databaseinfra.plan plan.provider = 1 plan.stronger_offering = offering plan.weaker_offering = offering plan.save() instances_mock.return_value = [cls.instance] cls.instance.hostname.offering = offering cls.instance.hostname.save()
def setUp(self): host = self.host or '127.0.0.1' port = self.port or 3306 self.infra_endpoint = '{}:{}'.format(host, port) self.databaseinfra = factory_physical.DatabaseInfraFactory( password=self.db_password, endpoint="{}:{}".format(host, port), engine__engine_type__name=self.engine_name, user=self.db_user ) hostname = factory_physical.HostFactory() self.volume = factory_physical.VolumeFactory( host=hostname, used_size_kb=float(40.0/1024.0) ) self.instances = self.instance_helper.create_instances_by_quant( infra=self.databaseinfra, port=self.port, qt=self.instances_quantity, total_size_in_bytes=0, used_size_in_bytes=0, instance_type=self.instance_type, hostname=hostname ) self.instance = self.instances[0] self.instance_endpoint = "{}:{}".format(self.instance.address, self.instance.port) self.driver = self.driver_class(databaseinfra=self.databaseinfra) self._driver_client = None
def setUpClass(cls, instances_mock): cls.databaseinfra = factory.DatabaseInfraFactory( name="__test__ mysqlinfra", user="******", password='******') cls.hostname = factory.HostFactory() cls.instance = factory.InstanceFactory( address="new_instance.localinstance", port=123, is_active=True, databaseinfra=cls.databaseinfra, hostname=cls.hostname) cls.nfaas_host_attr = factory.NFSaaSHostAttr(host=cls.hostname) cs_offering = factory.CloudStackOfferingFactory(memory_size_mb=9) cls.infra_offering = factory.DatabaseInfraOfferingFactory( databaseinfra=cls.databaseinfra, offering=cs_offering) instances_mock.return_value = [cls.instance] factory.PlanAttrFactory.create(plan=cls.databaseinfra.plan) cls.instance.hostname.offering = cs_offering cls.instance.hostname.save() offering = cls.databaseinfra.offering offering.memory_size_mb = 9 offering.save() cls.databaseinfra.plan.provider = 1 cls.databaseinfra.plan.save()