Esempio n. 1
0
 def delete_async(self):
     self._delete_resources()
     LOG.debug("Setting instance %s to deleted..." % self.id)
     # Delete guest queue.
     try:
         guest = self.get_guest()
         guest.delete_queue()
     except Exception as ex:
         LOG.warn(ex)
     time_now = datetime.now()
     self.update_db(deleted=True, deleted_at=time_now,
                    task_status=InstanceTasks.NONE)
     # Delete associated security group
     if CONF.reddwarf_security_groups_support:
         SecurityGroup.delete_for_instance(self.db_info.id,
                                           self.context)
Esempio n. 2
0
 def delete_async(self):
     self._delete_resources()
     LOG.debug("Setting instance %s to deleted..." % self.id)
     # Delete guest queue.
     try:
         guest = self.get_guest()
         guest.delete_queue()
     except Exception as ex:
         LOG.warn(ex)
     time_now = datetime.now()
     self.update_db(deleted=True,
                    deleted_at=time_now,
                    task_status=InstanceTasks.NONE)
     # Delete associated security group
     if CONF.reddwarf_security_groups_support:
         SecurityGroup.delete_for_instance(self.db_info.id, self.context)
Esempio n. 3
0
        def _create_resources():
            client = create_nova_client(context)
            security_groups = None
            try:
                flavor = client.flavors.get(flavor_id)
            except nova_exceptions.NotFound:
                raise exception.FlavorNotFound(uuid=flavor_id)

            if backup_id is not None:
                backup_info = Backup.get_by_id(backup_id)
                if backup_info.is_running:
                    raise exception.BackupNotCompleteError(backup_id=backup_id)

                location = backup_info.location
                LOG.info(_("Checking if backup exist in '%s'") % location)
                if not Backup.check_object_exist(context, location):
                    raise exception.BackupFileNotFound(location=location)

            db_info = DBInstance.create(name=name, flavor_id=flavor_id,
                                        tenant_id=context.tenant,
                                        volume_size=volume_size,
                                        task_status=InstanceTasks.BUILDING)
            LOG.debug(_("Tenant %s created new Reddwarf instance %s...")
                      % (context.tenant, db_info.id))

            service_status = InstanceServiceStatus.create(
                instance_id=db_info.id,
                status=ServiceStatuses.NEW)

            if CONF.reddwarf_dns_support:
                dns_client = create_dns_client(context)
                hostname = dns_client.determine_hostname(db_info.id)
                db_info.hostname = hostname
                db_info.save()

            if CONF.reddwarf_security_groups_support:
                security_group = SecurityGroup.create_for_instance(
                    db_info.id,
                    context)
                security_groups = [security_group["name"]]

            task_api.API(context).create_instance(db_info.id, name, flavor_id,
                                                  flavor.ram, image_id,
                                                  databases, users,
                                                  service_type, volume_size,
                                                  security_groups, backup_id)

            return SimpleInstance(context, db_info, service_status)
Esempio n. 4
0
        def _create_resources():
            client = create_nova_client(context)
            security_groups = None
            try:
                flavor = client.flavors.get(flavor_id)
            except nova_exceptions.NotFound:
                raise exception.FlavorNotFound(uuid=flavor_id)

            if backup_id is not None:
                backup_info = Backup.get_by_id(backup_id)
                if backup_info.is_running:
                    raise exception.BackupNotCompleteError(backup_id=backup_id)

                location = backup_info.location
                LOG.info(_("Checking if backup exist in '%s'") % location)
                if not Backup.check_object_exist(context, location):
                    raise exception.BackupFileNotFound(location=location)

            db_info = DBInstance.create(name=name,
                                        flavor_id=flavor_id,
                                        tenant_id=context.tenant,
                                        volume_size=volume_size,
                                        task_status=InstanceTasks.BUILDING)
            LOG.debug(
                _("Tenant %s created new Reddwarf instance %s...") %
                (context.tenant, db_info.id))

            service_status = InstanceServiceStatus.create(
                instance_id=db_info.id, status=ServiceStatuses.NEW)

            if CONF.reddwarf_dns_support:
                dns_client = create_dns_client(context)
                hostname = dns_client.determine_hostname(db_info.id)
                db_info.hostname = hostname
                db_info.save()

            if CONF.reddwarf_security_groups_support:
                security_group = SecurityGroup.create_for_instance(
                    db_info.id, context)
                security_groups = [security_group["name"]]

            task_api.API(context).create_instance(db_info.id, name, flavor_id,
                                                  flavor.ram, image_id,
                                                  databases, users,
                                                  service_type, volume_size,
                                                  security_groups, backup_id)

            return SimpleInstance(context, db_info, service_status)
Esempio n. 5
0
        def _create_resources():
            client = create_nova_client(context)
            security_groups = None
            try:
                flavor = client.flavors.get(flavor_id)
            except nova_exceptions.NotFound:
                raise exception.FlavorNotFound(uuid=flavor_id)

            db_info = DBInstance.create(name=name,
                                        flavor_id=flavor_id,
                                        tenant_id=context.tenant,
                                        volume_size=volume_size,
                                        task_status=InstanceTasks.BUILDING)
            LOG.debug(
                _("Tenant %s created new Reddwarf instance %s...") %
                (context.tenant, db_info.id))

            service_status = InstanceServiceStatus.create(
                instance_id=db_info.id, status=ServiceStatuses.NEW)

            if CONF.reddwarf_dns_support:
                dns_client = create_dns_client(context)
                hostname = dns_client.determine_hostname(db_info.id)
                db_info.hostname = hostname
                db_info.save()

            if CONF.reddwarf_security_groups_support:
                security_group = SecurityGroup.create_for_instance(
                    db_info.id, context)
                security_groups = [security_group["name"]]

            task_api.API(context).create_instance(db_info.id, name, flavor_id,
                                                  flavor.ram, image_id,
                                                  databases, users,
                                                  service_type, volume_size,
                                                  security_groups)

            return SimpleInstance(context, db_info, service_status)
Esempio n. 6
0
        def _create_resources():
            client = create_nova_client(context)
            security_groups = None
            try:
                flavor = client.flavors.get(flavor_id)
            except nova_exceptions.NotFound:
                raise exception.FlavorNotFound(uuid=flavor_id)

            db_info = DBInstance.create(name=name, flavor_id=flavor_id,
                                        tenant_id=context.tenant,
                                        volume_size=volume_size,
                                        task_status=InstanceTasks.BUILDING)
            LOG.debug(_("Tenant %s created new Reddwarf instance %s...")
                      % (context.tenant, db_info.id))

            service_status = InstanceServiceStatus.create(
                instance_id=db_info.id,
                status=ServiceStatuses.NEW)

            if CONF.reddwarf_dns_support:
                dns_client = create_dns_client(context)
                hostname = dns_client.determine_hostname(db_info.id)
                db_info.hostname = hostname
                db_info.save()

            if CONF.reddwarf_security_groups_support:
                security_group = SecurityGroup.create_for_instance(
                    db_info.id,
                    context)
                security_groups = [security_group["name"]]

            task_api.API(context).create_instance(db_info.id, name, flavor_id,
                                                  flavor.ram, image_id,
                                                  databases, users,
                                                  service_type, volume_size,
                                                  security_groups)

            return SimpleInstance(context, db_info, service_status)