forked from github/plane
dev: remove license engine communication
This commit is contained in:
parent
956d7acfa6
commit
1984a242d0
@ -28,10 +28,6 @@ app.conf.beat_schedule = {
|
|||||||
"task": "plane.bgtasks.file_asset_task.delete_file_asset",
|
"task": "plane.bgtasks.file_asset_task.delete_file_asset",
|
||||||
"schedule": crontab(hour=0, minute=0),
|
"schedule": crontab(hour=0, minute=0),
|
||||||
},
|
},
|
||||||
"check-instance-verification": {
|
|
||||||
"task": "plane.license.bgtasks.instance_verification_task.instance_verification_task",
|
|
||||||
"schedule": crontab(minute=0, hour='*/4'),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Load task modules from all registered Django app configs.
|
# Load task modules from all registered Django app configs.
|
||||||
|
@ -30,13 +30,11 @@ class Command(BaseCommand):
|
|||||||
# Load JSON content from the file
|
# Load JSON content from the file
|
||||||
data = json.load(file)
|
data = json.load(file)
|
||||||
|
|
||||||
machine_signature = options.get("machine_signature", False)
|
machine_signature = options.get("machine_signature", "machine-signature")
|
||||||
|
|
||||||
if not machine_signature:
|
if not machine_signature:
|
||||||
raise CommandError("Machine signature is required")
|
raise CommandError("Machine signature is required")
|
||||||
|
|
||||||
# Check if machine is online
|
|
||||||
headers = {"Content-Type": "application/json"}
|
|
||||||
payload = {
|
payload = {
|
||||||
"instance_key": settings.INSTANCE_KEY,
|
"instance_key": settings.INSTANCE_KEY,
|
||||||
"version": data.get("version", 0.1),
|
"version": data.get("version", 0.1),
|
||||||
@ -44,35 +42,6 @@ class Command(BaseCommand):
|
|||||||
"user_count": User.objects.filter(is_bot=False).count(),
|
"user_count": User.objects.filter(is_bot=False).count(),
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
|
||||||
response = requests.post(
|
|
||||||
f"{settings.LICENSE_ENGINE_BASE_URL}/api/instances/",
|
|
||||||
headers=headers,
|
|
||||||
data=json.dumps(payload),
|
|
||||||
timeout=30
|
|
||||||
)
|
|
||||||
|
|
||||||
if response.status_code == 201:
|
|
||||||
data = response.json()
|
|
||||||
# Create instance
|
|
||||||
instance = Instance.objects.create(
|
|
||||||
instance_name="Plane Free",
|
|
||||||
instance_id=data.get("id"),
|
|
||||||
license_key=data.get("license_key"),
|
|
||||||
api_key=data.get("api_key"),
|
|
||||||
version=data.get("version"),
|
|
||||||
last_checked_at=timezone.now(),
|
|
||||||
user_count=data.get("user_count", 0),
|
|
||||||
is_verified=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.stdout.write(
|
|
||||||
self.style.SUCCESS(
|
|
||||||
f"Instance successfully registered and verified"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return
|
|
||||||
except requests.RequestException as _e:
|
|
||||||
instance = Instance.objects.create(
|
instance = Instance.objects.create(
|
||||||
instance_name="Plane Free",
|
instance_name="Plane Free",
|
||||||
instance_id=secrets.token_hex(12),
|
instance_id=secrets.token_hex(12),
|
||||||
@ -82,13 +51,12 @@ class Command(BaseCommand):
|
|||||||
last_checked_at=timezone.now(),
|
last_checked_at=timezone.now(),
|
||||||
user_count=payload.get("user_count", 0),
|
user_count=payload.get("user_count", 0),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.stdout.write(
|
self.stdout.write(
|
||||||
self.style.SUCCESS(
|
self.style.SUCCESS(
|
||||||
f"Instance successfully registered"
|
f"Instance registered"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return
|
|
||||||
raise CommandError("Instance could not be registered")
|
|
||||||
else:
|
else:
|
||||||
self.stdout.write(
|
self.stdout.write(
|
||||||
self.style.SUCCESS(
|
self.style.SUCCESS(
|
||||||
|
@ -287,7 +287,6 @@ CELERY_IMPORTS = (
|
|||||||
"plane.bgtasks.issue_automation_task",
|
"plane.bgtasks.issue_automation_task",
|
||||||
"plane.bgtasks.exporter_expired_task",
|
"plane.bgtasks.exporter_expired_task",
|
||||||
"plane.bgtasks.file_asset_task",
|
"plane.bgtasks.file_asset_task",
|
||||||
"plane.license.bgtasks.instance_verification_task",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Sentry Settings
|
# Sentry Settings
|
||||||
|
Loading…
Reference in New Issue
Block a user