def clone(cls, database, clone_name, plan, environment, user):
        from notification.tasks import clone_database
        from notification.models import TaskHistory

        task_history = TaskHistory()
        task_history.task_name = "clone_database"
        task_history.task_status = task_history.STATUS_WAITING
        task_history.arguments = "Database name: {}".format(database.name)
        task_history.user = user
        task_history.save()

        clone_database.delay(origin_database=database, clone_name=clone_name,
                             plan=plan, environment=environment, user=user,
                             task_history=task_history
                             )
    def clone(cls, database, clone_name, plan, environment, user):
        # try:
        #    cloned_database = Database.objects.get(pk=database.pk)
        #    cloned_database.name = clone_name
        #    cloned_database.pk = None
        #    if not databaseinfra:
        #        cloned_database.databaseinfra = DatabaseInfra.best_for(database.plan, database.environment)
        #    else:
        #        cloned_database.databaseinfra = databaseinfra
        #    cloned_database.save()
        # except:
        #    transaction.rollback()
        #    raise
        # else:
        #    transaction.commit()
        # call task
        #    from notification.tasks import clone_database
        #    result = clone_database.delay(database, cloned_database, user=user)
        from notification.tasks import clone_database

        result = clone_database.delay(database,
                                      clone_name,
                                      plan,
                                      environment,
                                      user=user)
Beispiel #3
0
    def clone(cls, database, clone_name, plan, environment, user):
        from notification.tasks import clone_database
        from notification.models import TaskHistory

        task_history = TaskHistory()
        task_history.task_name = "clone_database"
        task_history.task_status = task_history.STATUS_WAITING
        task_history.arguments = "Database name: {}".format(database.name)
        task_history.user = user
        task_history.save()

        clone_database.delay(origin_database=database,
                             clone_name=clone_name,
                             plan=plan,
                             environment=environment,
                             user=user,
                             task_history=task_history)
    def clone(cls, database, clone_name, user):
        try:
            cloned_database = Database.objects.get(pk=database.pk)
            cloned_database.name = clone_name
            cloned_database.pk = None
            cloned_database.save()
        except:
            transaction.rollback()
            raise
        else:
            transaction.commit()
            # call task
            from notification.tasks import clone_database

            result = clone_database.delay(database, cloned_database, user=user)
	def clone(cls, database, clone_name, user):
		# try:
		#    cloned_database = Database.objects.get(pk=database.pk)
		#    cloned_database.name = clone_name
		#    cloned_database.pk = None
		#    if not databaseinfra:
		#        cloned_database.databaseinfra = DatabaseInfra.best_for(database.plan, database.environment)
		#    else:
		#        cloned_database.databaseinfra = databaseinfra
		#    cloned_database.save()
		#except:
		#    transaction.rollback()
		#    raise
		#else:
		#    transaction.commit()
		#    #call task
		#    from notification.tasks import clone_database
		#    result = clone_database.delay(database, cloned_database, user=user)
		from notification.tasks import clone_database

		result = clone_database.delay(database, clone_name, user=user)