update __pg__ to __doc__
This commit is contained in:
parent
48c48e587e
commit
7969851f3a
@ -6,7 +6,7 @@
|
|||||||
<template #body-content>
|
<template #body-content>
|
||||||
<div class="flex flex-col w-full">
|
<div class="flex flex-col w-full">
|
||||||
<AlertBanner
|
<AlertBanner
|
||||||
v-if="referenceDoctype === 'Team'"
|
v-if="referencePagetype === 'Team'"
|
||||||
title="Notifications will go to the General channel by default. If General isn't available, they'll be delivered to registered email addresses."
|
title="Notifications will go to the General channel by default. If General isn't available, they'll be delivered to registered email addresses."
|
||||||
type="info"
|
type="info"
|
||||||
:showIcon="false"
|
:showIcon="false"
|
||||||
@ -80,7 +80,7 @@ import AlertBanner from './AlertBanner.vue';
|
|||||||
export default {
|
export default {
|
||||||
name: 'CommunicationInfoDialog',
|
name: 'CommunicationInfoDialog',
|
||||||
props: {
|
props: {
|
||||||
referenceDoctype: {
|
referencePagetype: {
|
||||||
type: String,
|
type: String,
|
||||||
validator: (value) => ['Team', 'Site', 'Server'].includes(value),
|
validator: (value) => ['Team', 'Site', 'Server'].includes(value),
|
||||||
required: true,
|
required: true,
|
||||||
@ -104,7 +104,7 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.referenceDoctype && this.referenceName) {
|
if (this.referencePagetype && this.referenceName) {
|
||||||
this.$resources.getCommunicationInfos.submit();
|
this.$resources.getCommunicationInfos.submit();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -114,7 +114,7 @@ export default {
|
|||||||
url: 'jcloude.api.client.run_pg_method',
|
url: 'jcloude.api.client.run_pg_method',
|
||||||
makeParams() {
|
makeParams() {
|
||||||
return {
|
return {
|
||||||
dt: this.referenceDoctype,
|
dt: this.referencePagetype,
|
||||||
dn: this.referenceName,
|
dn: this.referenceName,
|
||||||
method: 'get_communication_infos',
|
method: 'get_communication_infos',
|
||||||
};
|
};
|
||||||
@ -130,7 +130,7 @@ export default {
|
|||||||
url: 'jcloude.api.client.run_pg_method',
|
url: 'jcloude.api.client.run_pg_method',
|
||||||
makeParams() {
|
makeParams() {
|
||||||
return {
|
return {
|
||||||
dt: this.referenceDoctype,
|
dt: this.referencePagetype,
|
||||||
dn: this.referenceName,
|
dn: this.referenceName,
|
||||||
method: 'update_communication_infos',
|
method: 'update_communication_infos',
|
||||||
args: { values: this.currentCommunicationInfos },
|
args: { values: this.currentCommunicationInfos },
|
||||||
@ -258,9 +258,9 @@ export default {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
filteredCommunicationTypes() {
|
filteredCommunicationTypes() {
|
||||||
if (this.referenceDoctype == 'Server') {
|
if (this.referencePagetype == 'Server') {
|
||||||
return ['General', 'Incident', 'Server Activity'];
|
return ['General', 'Incident', 'Server Activity'];
|
||||||
} else if (this.referenceDoctype == 'Site') {
|
} else if (this.referencePagetype == 'Site') {
|
||||||
return ['General', 'Site Activity'];
|
return ['General', 'Site Activity'];
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
|
|||||||
@ -92,7 +92,7 @@ function getSiteActionHandler(action) {
|
|||||||
function onNotificationSettings() {
|
function onNotificationSettings() {
|
||||||
return renderDialog(
|
return renderDialog(
|
||||||
h(CommunicationInfoDialog, {
|
h(CommunicationInfoDialog, {
|
||||||
referenceDoctype: 'Site',
|
referencePagetype: 'Site',
|
||||||
referenceName: site.pg.name,
|
referenceName: site.pg.name,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -74,7 +74,7 @@ function onNotificationSettings() {
|
|||||||
if (!server?.pg) return;
|
if (!server?.pg) return;
|
||||||
return renderDialog(
|
return renderDialog(
|
||||||
h(CommunicationInfoDialog, {
|
h(CommunicationInfoDialog, {
|
||||||
referenceDoctype: 'Server',
|
referencePagetype: 'Server',
|
||||||
referenceName: server.pg.name,
|
referenceName: server.pg.name,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
>
|
>
|
||||||
<lucide-alert-triangle class="mr-4 inline-block h-6 w-6" />
|
<lucide-alert-triangle class="mr-4 inline-block h-6 w-6" />
|
||||||
<div>
|
<div>
|
||||||
All <b>doctypes</b> & <b>modules</b>, along with all the
|
All <b>pagetypes</b> & <b>modules</b>, along with all the
|
||||||
<b>data</b> within this app will be removed from the site.
|
<b>data</b> within this app will be removed from the site.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -6,7 +6,7 @@ published: 1
|
|||||||
|
|
||||||
## The Marketplace App PageType
|
## The Marketplace App PageType
|
||||||
|
|
||||||
The main master for marketplace is the “Marketplace App” PageType around which all the other doctypes revolve around.
|
The main master for marketplace is the “Marketplace App” PageType around which all the other pagetypes revolve around.
|
||||||
|
|
||||||
## Release Management
|
## Release Management
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@ Assume a case, you want to create a webhook event whenever the site status got u
|
|||||||
|
|
||||||
It may not work because in agent job update process functions and other places, we use `set_value` call. So, we need to call this `create_webhook_event` function at those places as well.
|
It may not work because in agent job update process functions and other places, we use `set_value` call. So, we need to call this `create_webhook_event` function at those places as well.
|
||||||
|
|
||||||
Related Doctypes
|
Related Pagetypes
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
1. **Jcloude Webhook Event** - Type of webhook events (e.g. *Site Status Update*).
|
1. **Jcloude Webhook Event** - Type of webhook events (e.g. *Site Status Update*).
|
||||||
|
|||||||
@ -4,13 +4,13 @@ allow_guest: 1
|
|||||||
published: 1
|
published: 1
|
||||||
---
|
---
|
||||||
|
|
||||||
This is information about doctypes required to manage benches and apps on FC
|
This is information about pagetypes required to manage benches and apps on FC
|
||||||
from [desk](https://jcloud.jingrow.com/app). Roughly, the build process goes
|
from [desk](https://jcloud.jingrow.com/app). Roughly, the build process goes
|
||||||
through these doctypes (that you're concerned with) in order.
|
through these pagetypes (that you're concerned with) in order.
|
||||||
|
|
||||||
App => App Source => Release Group => Deploy Candidate => Bench
|
App => App Source => Release Group => Deploy Candidate => Bench
|
||||||
|
|
||||||
To build a bench, we need documents of the following doctypes.
|
To build a bench, we need documents of the following pagetypes.
|
||||||
|
|
||||||
## App
|
## App
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ This page describes how Subscription Management works in Jingrow Cloud.
|
|||||||
|
|
||||||
## PageTypes
|
## PageTypes
|
||||||
|
|
||||||
These are the key doctypes that are related to subscription:
|
These are the key pagetypes that are related to subscription:
|
||||||
|
|
||||||
1. [Plan](/app/plan): List of plans
|
1. [Plan](/app/plan): List of plans
|
||||||
2. [Subscription](/app/subscription): Record of active subscriptions
|
2. [Subscription](/app/subscription): Record of active subscriptions
|
||||||
|
|||||||
@ -100,7 +100,7 @@ test files (for organization reasons). These functions will be doing the bare
|
|||||||
minimum to make a valid document of that pagetype.
|
minimum to make a valid document of that pagetype.
|
||||||
|
|
||||||
Eg: `create_test_bench` in `test_bench.py` can be imported and used whenever
|
Eg: `create_test_bench` in `test_bench.py` can be imported and used whenever
|
||||||
you need a valid bench (which itself has dependencies on many other doctypes)
|
you need a valid bench (which itself has dependencies on many other pagetypes)
|
||||||
|
|
||||||
You can also add default args to these utility functions as you come across the
|
You can also add default args to these utility functions as you come across the
|
||||||
need. Just append to end so you won't have to rewrite pre-existing tests.
|
need. Just append to end so you won't have to rewrite pre-existing tests.
|
||||||
|
|||||||
@ -1064,10 +1064,10 @@ def get_permission_options(name, ptype):
|
|||||||
available_actions,
|
available_actions,
|
||||||
)
|
)
|
||||||
|
|
||||||
doctypes = jingrow.get_all("Jcloude Method Permission", pluck="document_type", distinct=True)
|
pagetypes = jingrow.get_all("Jcloude Method Permission", pluck="document_type", distinct=True)
|
||||||
|
|
||||||
options = []
|
options = []
|
||||||
for pagetype in doctypes:
|
for pagetype in pagetypes:
|
||||||
pg = jingrow.qb.PageType(pagetype)
|
pg = jingrow.qb.PageType(pagetype)
|
||||||
perm_pg = jingrow.qb.PageType("Jcloude User Permission")
|
perm_pg = jingrow.qb.PageType("Jcloude User Permission")
|
||||||
subtable = (
|
subtable = (
|
||||||
|
|||||||
@ -112,7 +112,7 @@ def get_list(
|
|||||||
if filters is None:
|
if filters is None:
|
||||||
filters = {}
|
filters = {}
|
||||||
|
|
||||||
# these doctypes doesn't have a team field to filter by but are used in get or run_pg_method
|
# these pagetypes doesn't have a team field to filter by but are used in get or run_pg_method
|
||||||
if pagetype in ["Team", "User SSH Key"]:
|
if pagetype in ["Team", "User SSH Key"]:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@ -183,18 +183,18 @@ def get_list_query(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if meta.istable and jingrow.get_meta(filters.get("parenttype")).has_field("team"):
|
if meta.istable and jingrow.get_meta(filters.get("parenttype")).has_field("team"):
|
||||||
ParentDocType = jingrow.qb.PageType(filters.get("parenttype"))
|
ParentPageType = jingrow.qb.PageType(filters.get("parenttype"))
|
||||||
ChildDocType = jingrow.qb.PageType(pagetype)
|
ChildPageType = jingrow.qb.PageType(pagetype)
|
||||||
|
|
||||||
query = (
|
query = (
|
||||||
query.join(ParentDocType)
|
query.join(ParentPageType)
|
||||||
.on(ParentDocType.name == ChildDocType.parent)
|
.on(ParentPageType.name == ChildPageType.parent)
|
||||||
.where(ParentDocType.team == jingrow.local.team().name)
|
.where(ParentPageType.team == jingrow.local.team().name)
|
||||||
)
|
)
|
||||||
|
|
||||||
if document_options and isinstance(document_options, list):
|
if document_options and isinstance(document_options, list):
|
||||||
QueryDoctype = jingrow.qb.PageType(pagetype)
|
QueryPagetype = jingrow.qb.PageType(pagetype)
|
||||||
query = query.where(QueryDoctype.name.isin(document_options))
|
query = query.where(QueryPagetype.name.isin(document_options))
|
||||||
|
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
|||||||
@ -30,11 +30,11 @@ if TYPE_CHECKING:
|
|||||||
from jcloude.jcloude.pagetype.server_plan.server_plan import ServerPlan
|
from jcloude.jcloude.pagetype.server_plan.server_plan import ServerPlan
|
||||||
|
|
||||||
|
|
||||||
def poly_get_pg(doctypes, name):
|
def poly_get_pg(pagetypes, name):
|
||||||
for pagetype in doctypes:
|
for pagetype in pagetypes:
|
||||||
if jingrow.db.exists(pagetype, name):
|
if jingrow.db.exists(pagetype, name):
|
||||||
return jingrow.get_pg(pagetype, name)
|
return jingrow.get_pg(pagetype, name)
|
||||||
return jingrow.get_pg(doctypes[-1], name)
|
return jingrow.get_pg(pagetypes[-1], name)
|
||||||
|
|
||||||
|
|
||||||
def get_mount_point(server: str, server_type=None) -> str:
|
def get_mount_point(server: str, server_type=None) -> str:
|
||||||
|
|||||||
@ -50,21 +50,21 @@ if TYPE_CHECKING:
|
|||||||
from jcloude.jcloude.pagetype.team.team import Team
|
from jcloude.jcloude.pagetype.team.team import Team
|
||||||
|
|
||||||
|
|
||||||
def protected(doctypes):
|
def protected(pagetypes):
|
||||||
"""
|
"""
|
||||||
This decorator is stupid. It works in magical ways. It checks whether the
|
This decorator is stupid. It works in magical ways. It checks whether the
|
||||||
owner of the Pagetype (one of `doctypes`) is the same as the current team.
|
owner of the Pagetype (one of `pagetypes`) is the same as the current team.
|
||||||
|
|
||||||
The stupid magical part of this decorator is how it gets the name of the
|
The stupid magical part of this decorator is how it gets the name of the
|
||||||
Pagetype (see: `get_protected_pagetype_name`); in order of precedence:
|
Pagetype (see: `get_protected_pagetype_name`); in order of precedence:
|
||||||
1. kwargs value with key `name`
|
1. kwargs value with key `name`
|
||||||
2. first value in kwargs value with key `filters` i.e. ≈ `kwargs['filters'].values()[0]`
|
2. first value in kwargs value with key `filters` i.e. ≈ `kwargs['filters'].values()[0]`
|
||||||
3. first value in the args tuple
|
3. first value in the args tuple
|
||||||
4. kwargs value with key `snake_case(doctypes[0])`
|
4. kwargs value with key `snake_case(pagetypes[0])`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not isinstance(doctypes, list):
|
if not isinstance(pagetypes, list):
|
||||||
doctypes = [doctypes]
|
pagetypes = [pagetypes]
|
||||||
|
|
||||||
@wrapt.decorator
|
@wrapt.decorator
|
||||||
def wrapper(wrapped, instance, args, kwargs):
|
def wrapper(wrapped, instance, args, kwargs):
|
||||||
@ -77,11 +77,11 @@ def protected(doctypes):
|
|||||||
return wrapped(*args, **kwargs)
|
return wrapped(*args, **kwargs)
|
||||||
|
|
||||||
# Get the name of the document being accessed.
|
# Get the name of the document being accessed.
|
||||||
if not (docname := get_protected_pagetype_name(args, kwargs, doctypes)):
|
if not (docname := get_protected_pagetype_name(args, kwargs, pagetypes)):
|
||||||
jingrow.throw("Name not found, API access not permitted", jingrow.PermissionError)
|
jingrow.throw("Name not found, API access not permitted", jingrow.PermissionError)
|
||||||
|
|
||||||
current_team = get_current_team()
|
current_team = get_current_team()
|
||||||
for pagetype in doctypes:
|
for pagetype in pagetypes:
|
||||||
document_team = jingrow.db.get_value(pagetype, docname, "team")
|
document_team = jingrow.db.get_value(pagetype, docname, "team")
|
||||||
if document_team == current_team or has_support_access(pagetype, docname):
|
if document_team == current_team or has_support_access(pagetype, docname):
|
||||||
return wrapped(*args, **kwargs)
|
return wrapped(*args, **kwargs)
|
||||||
@ -92,7 +92,7 @@ def protected(doctypes):
|
|||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
def get_protected_pagetype_name(args: list, kwargs: dict, doctypes: list[str]):
|
def get_protected_pagetype_name(args: list, kwargs: dict, pagetypes: list[str]):
|
||||||
# 1. Name from kwargs["name"] or kwargs["pg_name"]
|
# 1. Name from kwargs["name"] or kwargs["pg_name"]
|
||||||
if name := (kwargs.get("name") or kwargs.get("pg_name")):
|
if name := (kwargs.get("name") or kwargs.get("pg_name")):
|
||||||
return name
|
return name
|
||||||
@ -106,11 +106,11 @@ def get_protected_pagetype_name(args: list, kwargs: dict, doctypes: list[str]):
|
|||||||
if len(args) >= 1 and args[0]:
|
if len(args) >= 1 and args[0]:
|
||||||
return args[0]
|
return args[0]
|
||||||
|
|
||||||
if len(doctypes) == 0:
|
if len(pagetypes) == 0:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# 4. Name from snakecased first `doctypes` name
|
# 4. Name from snakecased first `pagetypes` name
|
||||||
pagetype = doctypes[0]
|
pagetype = pagetypes[0]
|
||||||
key = pagetype.lower().replace(" ", "_")
|
key = pagetype.lower().replace(" ", "_")
|
||||||
return kwargs.get(key)
|
return kwargs.get(key)
|
||||||
|
|
||||||
|
|||||||
@ -435,7 +435,7 @@ page_renderer = ["jcloude.metrics.MetricsRenderer"]
|
|||||||
|
|
||||||
export_python_type_annotations = True
|
export_python_type_annotations = True
|
||||||
|
|
||||||
default_log_clearing_doctypes = {
|
default_log_clearing_pagetypes = {
|
||||||
"Alertmanager Webhook Log": 60,
|
"Alertmanager Webhook Log": 60,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,10 +470,10 @@ persistent_cache_keys = [
|
|||||||
"defaults",
|
"defaults",
|
||||||
"pagetype_form_meta",
|
"pagetype_form_meta",
|
||||||
"pagetype_meta",
|
"pagetype_meta",
|
||||||
"doctypes_with_web_view",
|
"pagetypes_with_web_view",
|
||||||
"document_cache::*",
|
"document_cache::*",
|
||||||
"document_naming_rule_map",
|
"document_naming_rule_map",
|
||||||
"domain_restricted_doctypes",
|
"domain_restricted_pagetypes",
|
||||||
"domain_restricted_pages",
|
"domain_restricted_pages",
|
||||||
"energy_point_rule_map",
|
"energy_point_rule_map",
|
||||||
"jingrow.utils.scheduler.schedule_jobs_based_on_activity*", # dormant checks
|
"jingrow.utils.scheduler.schedule_jobs_based_on_activity*", # dormant checks
|
||||||
|
|||||||
@ -225,14 +225,14 @@ class IncidentInvestigator(Document):
|
|||||||
@property
|
@property
|
||||||
def steps(self) -> dict[str, list[tuple[str, "Callable"]]]:
|
def steps(self) -> dict[str, list[tuple[str, "Callable"]]]:
|
||||||
investigation_steps = [
|
investigation_steps = [
|
||||||
(self.has_high_disk_usage.__pg__, self.has_high_disk_usage.__name__),
|
(self.has_high_disk_usage.__doc__, self.has_high_disk_usage.__name__),
|
||||||
(self.has_high_memory_usage.__pg__, self.has_high_memory_usage.__name__),
|
(self.has_high_memory_usage.__doc__, self.has_high_memory_usage.__name__),
|
||||||
(self.has_high_cpu_load.__pg__, self.has_high_cpu_load.__name__),
|
(self.has_high_cpu_load.__doc__, self.has_high_cpu_load.__name__),
|
||||||
(self.has_high_system_load.__pg__, self.has_high_system_load.__name__),
|
(self.has_high_system_load.__doc__, self.has_high_system_load.__name__),
|
||||||
]
|
]
|
||||||
return {
|
return {
|
||||||
"proxy_investigation_steps": [
|
"proxy_investigation_steps": [
|
||||||
(self.are_sites_on_proxy_down.__pg__, self.are_sites_on_proxy_down.__name__),
|
(self.are_sites_on_proxy_down.__doc__, self.are_sites_on_proxy_down.__name__),
|
||||||
# *investigation_steps[1:],
|
# *investigation_steps[1:],
|
||||||
], # Don't care about disk usage in proxy's case
|
], # Don't care about disk usage in proxy's case
|
||||||
"server_investigation_steps": investigation_steps,
|
"server_investigation_steps": investigation_steps,
|
||||||
|
|||||||
@ -583,7 +583,7 @@ class VirtualDiskResize(Document):
|
|||||||
for method, wait_for_completion in methods:
|
for method, wait_for_completion in methods:
|
||||||
steps.append(
|
steps.append(
|
||||||
{
|
{
|
||||||
"step": method.__pg__,
|
"step": method.__doc__,
|
||||||
"method": method.__name__,
|
"method": method.__name__,
|
||||||
"wait_for_completion": wait_for_completion,
|
"wait_for_completion": wait_for_completion,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -309,7 +309,7 @@ class VirtualMachineMigration(Document):
|
|||||||
for method, wait_for_completion in methods:
|
for method, wait_for_completion in methods:
|
||||||
steps.append(
|
steps.append(
|
||||||
{
|
{
|
||||||
"step": method.__pg__,
|
"step": method.__doc__,
|
||||||
"method": method.__name__,
|
"method": method.__name__,
|
||||||
"wait_for_completion": wait_for_completion,
|
"wait_for_completion": wait_for_completion,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -113,7 +113,7 @@ class VirtualMachineReplacement(Document):
|
|||||||
for method, wait_for_completion in methods:
|
for method, wait_for_completion in methods:
|
||||||
steps.append(
|
steps.append(
|
||||||
{
|
{
|
||||||
"step": method.__pg__,
|
"step": method.__doc__,
|
||||||
"method": method.__name__,
|
"method": method.__name__,
|
||||||
"wait_for_completion": wait_for_completion,
|
"wait_for_completion": wait_for_completion,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ jcloude.patches.v0_0_1.add_domains_to_site_config
|
|||||||
execute:jingrow.reload_pg('jcloude', 'pagetype', 'Remote File')
|
execute:jingrow.reload_pg('jcloude', 'pagetype', 'Remote File')
|
||||||
# jcloude.patches.v0_0_1.add_site_to_remote_file # 2020-11-12 run via run-patch command in active site state
|
# jcloude.patches.v0_0_1.add_site_to_remote_file # 2020-11-12 run via run-patch command in active site state
|
||||||
jcloude.patches.v0_0_1.new_onboarding
|
jcloude.patches.v0_0_1.new_onboarding
|
||||||
jcloude.patches.v0_0_1.remove_obsolete_doctypes
|
jcloude.patches.v0_0_1.remove_obsolete_pagetypes
|
||||||
jcloude.patches.v0_0_1.make_default_site_domain
|
jcloude.patches.v0_0_1.make_default_site_domain
|
||||||
jcloude.patches.v0_0_1.update_site_config_pg
|
jcloude.patches.v0_0_1.update_site_config_pg
|
||||||
jcloude.patches.v0_0_1.create_certificate_authorities
|
jcloude.patches.v0_0_1.create_certificate_authorities
|
||||||
@ -75,7 +75,7 @@ jcloude.patches.v0_0_1.add_domains_in_site_config_preview
|
|||||||
jcloude.patches.v0_0_1.use_private_ip_for_upstreams
|
jcloude.patches.v0_0_1.use_private_ip_for_upstreams
|
||||||
jcloude.jcloude.pagetype.site.patches.set_plan_in_site
|
jcloude.jcloude.pagetype.site.patches.set_plan_in_site
|
||||||
jcloude.jcloude.pagetype.app_release.patches.set_status_to_draft
|
jcloude.jcloude.pagetype.app_release.patches.set_status_to_draft
|
||||||
jcloude.patches.v0_0_4.remove_legacy_billing_doctypes
|
jcloude.patches.v0_0_4.remove_legacy_billing_pagetypes
|
||||||
# jcloude.jcloude.pagetype.invoice.patches.set_free_credits # 2021-08-11 run via run-patch command
|
# jcloude.jcloude.pagetype.invoice.patches.set_free_credits # 2021-08-11 run via run-patch command
|
||||||
jcloude.jcloude.pagetype.team.patches.set_payment_mode
|
jcloude.jcloude.pagetype.team.patches.set_payment_mode
|
||||||
jcloude.patches.v0_0_1.add_team_name_as_default_notify_email
|
jcloude.patches.v0_0_1.add_team_name_as_default_notify_email
|
||||||
@ -109,7 +109,7 @@ jcloude.jcloude.pagetype.virtual_disk_snapshot.patches.rename_aws_fields
|
|||||||
jcloude.jcloude.pagetype.virtual_machine_volume.patches.rename_aws_fields
|
jcloude.jcloude.pagetype.virtual_machine_volume.patches.rename_aws_fields
|
||||||
jcloude.patches.v0_7_0.convert_marketplace_description_to_html
|
jcloude.patches.v0_7_0.convert_marketplace_description_to_html
|
||||||
jcloude.jcloude.pagetype.team.patches.remove_invalid_email_addresses
|
jcloude.jcloude.pagetype.team.patches.remove_invalid_email_addresses
|
||||||
jcloude.saas.pagetype.product_trial.patches.rename_saas_product_doctypes_to_product_trial
|
jcloude.saas.pagetype.product_trial.patches.rename_saas_product_pagetypes_to_product_trial
|
||||||
|
|
||||||
[post_model_sync]
|
[post_model_sync]
|
||||||
jcloude.patches.v0_7_0.rename_plan_to_site_plan
|
jcloude.patches.v0_7_0.rename_plan_to_site_plan
|
||||||
@ -119,7 +119,7 @@ jcloude.jcloude.pagetype.agent_job.patches.update_status_for_undelivered_jobs #2
|
|||||||
jcloude.jcloude.pagetype.jcloude_role.patches.migrate_permissions
|
jcloude.jcloude.pagetype.jcloude_role.patches.migrate_permissions
|
||||||
jcloude.jcloude.pagetype.jcloude_role.patches.change_fields_from_enable_to_allow
|
jcloude.jcloude.pagetype.jcloude_role.patches.change_fields_from_enable_to_allow
|
||||||
jcloude.jcloude.pagetype.stripe_webhook_log.patches.add_payment_method_for_failed_events
|
jcloude.jcloude.pagetype.stripe_webhook_log.patches.add_payment_method_for_failed_events
|
||||||
jcloude.patches.v0_7_0.add_team_field_for_site_related_doctypes
|
jcloude.patches.v0_7_0.add_team_field_for_site_related_pagetypes
|
||||||
jcloude.patches.v0_7_0.add_team_field_for_site_backups_archived
|
jcloude.patches.v0_7_0.add_team_field_for_site_backups_archived
|
||||||
jcloude.jcloude.pagetype.server_storage_plan.patches.add_subscription_for_servers_with_additional_disk
|
jcloude.jcloude.pagetype.server_storage_plan.patches.add_subscription_for_servers_with_additional_disk
|
||||||
jcloude.jcloude.pagetype.jcloude_notification.patches.link_reference_pagetype_to_notifications
|
jcloude.jcloude.pagetype.jcloude_notification.patches.link_reference_pagetype_to_notifications
|
||||||
|
|||||||
@ -9,7 +9,7 @@ def execute():
|
|||||||
jingrow.reload_pg("jcloude", "pagetype", "cluster")
|
jingrow.reload_pg("jcloude", "pagetype", "cluster")
|
||||||
cluster = jingrow.get_pg({"pagetype": "Cluster", "name": "Default", "default": True})
|
cluster = jingrow.get_pg({"pagetype": "Cluster", "name": "Default", "default": True})
|
||||||
cluster.insert()
|
cluster.insert()
|
||||||
doctypes = ["Server", "Proxy Server", "Database Server", "Bench", "Site"]
|
pagetypes = ["Server", "Proxy Server", "Database Server", "Bench", "Site"]
|
||||||
for pagetype in doctypes:
|
for pagetype in pagetypes:
|
||||||
jingrow.reload_pg("jcloude", "pagetype", jingrow.scrub(pagetype))
|
jingrow.reload_pg("jcloude", "pagetype", jingrow.scrub(pagetype))
|
||||||
jingrow.db.set_value(pagetype, {"name": ("like", "%")}, "cluster", "Default")
|
jingrow.db.set_value(pagetype, {"name": ("like", "%")}, "cluster", "Default")
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import jingrow
|
|||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
obsolete_doctypes = [
|
obsolete_pagetypes = [
|
||||||
"Credit Ledger Entry",
|
"Credit Ledger Entry",
|
||||||
"Custom Domain",
|
"Custom Domain",
|
||||||
"Site Analytics",
|
"Site Analytics",
|
||||||
@ -16,6 +16,6 @@ def execute():
|
|||||||
"Usage Report",
|
"Usage Report",
|
||||||
"User Account",
|
"User Account",
|
||||||
]
|
]
|
||||||
for pagetype in obsolete_doctypes:
|
for pagetype in obsolete_pagetypes:
|
||||||
if jingrow.db.exists("PageType", pagetype):
|
if jingrow.db.exists("PageType", pagetype):
|
||||||
jingrow.delete_pg("PageType", pagetype)
|
jingrow.delete_pg("PageType", pagetype)
|
||||||
|
|||||||
@ -6,8 +6,8 @@ import jingrow
|
|||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
doctypes = ["Server", "Proxy Server", "Database Server"]
|
pagetypes = ["Server", "Proxy Server", "Database Server"]
|
||||||
for pagetype in doctypes:
|
for pagetype in pagetypes:
|
||||||
jingrow.reload_pg("jcloude", "pagetype", jingrow.scrub(pagetype))
|
jingrow.reload_pg("jcloude", "pagetype", jingrow.scrub(pagetype))
|
||||||
servers = jingrow.get_all(pagetype, {"hostname": ("is", "not set")})
|
servers = jingrow.get_all(pagetype, {"hostname": ("is", "not set")})
|
||||||
domain = jingrow.db.get_single_value("Jcloude Settings", "domain")
|
domain = jingrow.db.get_single_value("Jcloude Settings", "domain")
|
||||||
|
|||||||
@ -6,6 +6,6 @@ import jingrow
|
|||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
# these doctypes are only deleted from PageType table, their tables will exist
|
# these pagetypes are only deleted from PageType table, their tables will exist
|
||||||
doctypes = ["Payment", "Payment Ledger Entry"]
|
pagetypes = ["Payment", "Payment Ledger Entry"]
|
||||||
jingrow.db.sql("DELETE from tabDocType where name in %s", [doctypes])
|
jingrow.db.sql("DELETE from tabPageType where name in %s", [pagetypes])
|
||||||
|
|||||||
@ -566,31 +566,31 @@ class PlanAudit(Audit):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Check for plan and virtual machine discrepancies"""
|
"""Check for plan and virtual machine discrepancies"""
|
||||||
VirtualMachineDocType = jingrow.qb.PageType("Virtual Machine")
|
VirtualMachinePageType = jingrow.qb.PageType("Virtual Machine")
|
||||||
ServerPlan = jingrow.qb.PageType("Server Plan")
|
ServerPlan = jingrow.qb.PageType("Server Plan")
|
||||||
server_types = ["Server", "Database Server"]
|
server_types = ["Server", "Database Server"]
|
||||||
server_level_discrepancies = {}
|
server_level_discrepancies = {}
|
||||||
|
|
||||||
for server_type in server_types:
|
for server_type in server_types:
|
||||||
ServerDoctype = jingrow.qb.PageType(server_type)
|
ServerPagetype = jingrow.qb.PageType(server_type)
|
||||||
query = (
|
query = (
|
||||||
jingrow.qb.from_(ServerDoctype)
|
jingrow.qb.from_(ServerPagetype)
|
||||||
.select(
|
.select(
|
||||||
ServerDoctype.name,
|
ServerPagetype.name,
|
||||||
ServerDoctype.plan,
|
ServerPagetype.plan,
|
||||||
VirtualMachineDocType.machine_type,
|
VirtualMachinePageType.machine_type,
|
||||||
VirtualMachineDocType.ram.as_("vm_memory"),
|
VirtualMachinePageType.ram.as_("vm_memory"),
|
||||||
VirtualMachineDocType.disk_size.as_("vm_disk_size"),
|
VirtualMachinePageType.disk_size.as_("vm_disk_size"),
|
||||||
ServerPlan.disk.as_("plan_disk_size"),
|
ServerPlan.disk.as_("plan_disk_size"),
|
||||||
ServerPlan.memory.as_("plan_memory"),
|
ServerPlan.memory.as_("plan_memory"),
|
||||||
)
|
)
|
||||||
.join(VirtualMachineDocType)
|
.join(VirtualMachinePageType)
|
||||||
.on(VirtualMachineDocType.name == ServerDoctype.name)
|
.on(VirtualMachinePageType.name == ServerPagetype.name)
|
||||||
.join(ServerPlan)
|
.join(ServerPlan)
|
||||||
.on(ServerDoctype.plan == ServerPlan.name)
|
.on(ServerPagetype.plan == ServerPlan.name)
|
||||||
.where(ServerDoctype.status == "Active")
|
.where(ServerPagetype.status == "Active")
|
||||||
.where(ServerDoctype.is_self_hosted == False) # noqa: E712
|
.where(ServerPagetype.is_self_hosted == False) # noqa: E712
|
||||||
.where(ServerDoctype.cluster != "Hybrid")
|
.where(ServerPagetype.cluster != "Hybrid")
|
||||||
)
|
)
|
||||||
server_plan_info: list[ServerPlanInfo] = query.run(as_dict=True)
|
server_plan_info: list[ServerPlanInfo] = query.run(as_dict=True)
|
||||||
discrepancies = self.audit_plan_discrepancies(server_plan_info)
|
discrepancies = self.audit_plan_discrepancies(server_plan_info)
|
||||||
|
|||||||
@ -207,7 +207,7 @@ def update_with_row_size_too_large_err(details: Details, job: AgentJob):
|
|||||||
details[
|
details[
|
||||||
"message"
|
"message"
|
||||||
] = f"""<p>The server encountered a row size too large error while migrating the site <b>{job.site}</b>.</p>
|
] = f"""<p>The server encountered a row size too large error while migrating the site <b>{job.site}</b>.</p>
|
||||||
<p>This tends to happen on doctypes with many custom fields</p>
|
<p>This tends to happen on pagetypes with many custom fields</p>
|
||||||
<p>To rectify this issue, please follow the steps mentioned in <i>Help</i>.</p>
|
<p>To rectify this issue, please follow the steps mentioned in <i>Help</i>.</p>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@ -254,7 +254,7 @@ class AlertmanagerWebhookLog(Document):
|
|||||||
return jingrow.render_template(TELEGRAM_NOTIFICATION_TEMPLATE, context)
|
return jingrow.render_template(TELEGRAM_NOTIFICATION_TEMPLATE, context)
|
||||||
|
|
||||||
def guess_pagetype(self, name):
|
def guess_pagetype(self, name):
|
||||||
doctypes = [
|
pagetypes = [
|
||||||
"Site",
|
"Site",
|
||||||
"Bench",
|
"Bench",
|
||||||
"Server",
|
"Server",
|
||||||
@ -268,7 +268,7 @@ class AlertmanagerWebhookLog(Document):
|
|||||||
"Trace Server",
|
"Trace Server",
|
||||||
"NFS Server",
|
"NFS Server",
|
||||||
]
|
]
|
||||||
for pagetype in doctypes:
|
for pagetype in pagetypes:
|
||||||
if jingrow.db.exists(pagetype, name):
|
if jingrow.db.exists(pagetype, name):
|
||||||
return pagetype
|
return pagetype
|
||||||
return None
|
return None
|
||||||
|
|||||||
@ -247,7 +247,7 @@ class Cluster(Document):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def images_available(self) -> float:
|
def images_available(self) -> float:
|
||||||
return len(self.get_same_region_vmis()) / len(self.server_doctypes)
|
return len(self.get_same_region_vmis()) / len(self.server_pagetypes)
|
||||||
|
|
||||||
def validate_cidr_block(self):
|
def validate_cidr_block(self):
|
||||||
if not self.cidr_block:
|
if not self.cidr_block:
|
||||||
@ -674,15 +674,15 @@ class Cluster(Document):
|
|||||||
return VirtualMachineImage.get_available_for_series(series, self.region, platform=platform)
|
return VirtualMachineImage.get_available_for_series(series, self.region, platform=platform)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def server_doctypes(self):
|
def server_pagetypes(self):
|
||||||
server_doctypes = {**self.base_servers}
|
server_pagetypes = {**self.base_servers}
|
||||||
if not self.public:
|
if not self.public:
|
||||||
server_doctypes = {**server_doctypes, **self.private_servers}
|
server_pagetypes = {**server_pagetypes, **self.private_servers}
|
||||||
return server_doctypes
|
return server_pagetypes
|
||||||
|
|
||||||
def get_same_region_vmis(self, platform="x86_64", get_series=False) -> list[str]:
|
def get_same_region_vmis(self, platform="x86_64", get_series=False) -> list[str]:
|
||||||
vmis = []
|
vmis = []
|
||||||
for series in list(self.server_doctypes.values()):
|
for series in list(self.server_pagetypes.values()):
|
||||||
vmis.extend(
|
vmis.extend(
|
||||||
jingrow.get_all(
|
jingrow.get_all(
|
||||||
"Virtual Machine Image",
|
"Virtual Machine Image",
|
||||||
@ -704,7 +704,7 @@ class Cluster(Document):
|
|||||||
|
|
||||||
def get_other_region_vmis(self, platform="x86_64", get_series=False) -> list[str]:
|
def get_other_region_vmis(self, platform="x86_64", get_series=False) -> list[str]:
|
||||||
vmis = []
|
vmis = []
|
||||||
for series in list(self.server_doctypes.values()):
|
for series in list(self.server_pagetypes.values()):
|
||||||
vmis.extend(
|
vmis.extend(
|
||||||
jingrow.get_all(
|
jingrow.get_all(
|
||||||
"Virtual Machine Image",
|
"Virtual Machine Image",
|
||||||
|
|||||||
@ -226,7 +226,7 @@ class LogicalReplicationBackup(Document):
|
|||||||
continue
|
continue
|
||||||
steps.append(
|
steps.append(
|
||||||
{
|
{
|
||||||
"step": method.__pg__,
|
"step": method.__doc__,
|
||||||
"method": method.__name__,
|
"method": method.__name__,
|
||||||
"is_async": is_async,
|
"is_async": is_async,
|
||||||
"wait_for_completion": wait_for_completion,
|
"wait_for_completion": wait_for_completion,
|
||||||
|
|||||||
@ -114,7 +114,7 @@ class PhysicalBackupRestoration(Document):
|
|||||||
for method, is_async, wait_for_completion, is_cleanup_step in methods:
|
for method, is_async, wait_for_completion, is_cleanup_step in methods:
|
||||||
steps.append(
|
steps.append(
|
||||||
{
|
{
|
||||||
"step": method.__pg__,
|
"step": method.__doc__,
|
||||||
"method": method.__name__,
|
"method": method.__name__,
|
||||||
"is_async": is_async,
|
"is_async": is_async,
|
||||||
"wait_for_completion": wait_for_completion,
|
"wait_for_completion": wait_for_completion,
|
||||||
|
|||||||
@ -24,11 +24,11 @@ class PressMethodPermission(Document):
|
|||||||
|
|
||||||
def available_actions():
|
def available_actions():
|
||||||
result = {}
|
result = {}
|
||||||
doctypes = jingrow.get_all(
|
pagetypes = jingrow.get_all(
|
||||||
"Jcloude Method Permission", pluck="document_type", distinct=True
|
"Jcloude Method Permission", pluck="document_type", distinct=True
|
||||||
)
|
)
|
||||||
|
|
||||||
for pagetype in doctypes:
|
for pagetype in pagetypes:
|
||||||
result[pagetype] = {
|
result[pagetype] = {
|
||||||
perm["checkbox_label"]: perm["method"]
|
perm["checkbox_label"]: perm["method"]
|
||||||
for perm in jingrow.get_all(
|
for perm in jingrow.get_all(
|
||||||
|
|||||||
@ -9,7 +9,7 @@ from jingrow.model.document import Document
|
|||||||
from jcloude.api.client import dashboard_whitelist
|
from jcloude.api.client import dashboard_whitelist
|
||||||
|
|
||||||
DEFAULT_PERMISSIONS = {
|
DEFAULT_PERMISSIONS = {
|
||||||
"*": {"*": {"*": True}} # all doctypes # all documents # all methods
|
"*": {"*": {"*": True}} # all pagetypes # all documents # all methods
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class PressPermissionGroup(Document):
|
|||||||
return
|
return
|
||||||
|
|
||||||
for pagetype, pagetype_perms in permissions.items():
|
for pagetype, pagetype_perms in permissions.items():
|
||||||
if pagetype not in get_all_restrictable_doctypes() and pagetype != "*":
|
if pagetype not in get_all_restrictable_pagetypes() and pagetype != "*":
|
||||||
jingrow.throw(f"{pagetype} is not a valid pagetype.")
|
jingrow.throw(f"{pagetype} is not a valid pagetype.")
|
||||||
|
|
||||||
if not isinstance(pagetype_perms, dict):
|
if not isinstance(pagetype_perms, dict):
|
||||||
@ -158,7 +158,7 @@ class PressPermissionGroup(Document):
|
|||||||
if not (jingrow.local.system_user() or user_belongs_to_group or user_is_team_owner):
|
if not (jingrow.local.system_user() or user_belongs_to_group or user_is_team_owner):
|
||||||
jingrow.throw(f"{user} does not belong to {self.name}")
|
jingrow.throw(f"{user} does not belong to {self.name}")
|
||||||
|
|
||||||
if pagetype not in get_all_restrictable_doctypes():
|
if pagetype not in get_all_restrictable_pagetypes():
|
||||||
jingrow.throw(f"{pagetype} is not a valid restrictable pagetype.")
|
jingrow.throw(f"{pagetype} is not a valid restrictable pagetype.")
|
||||||
|
|
||||||
restrictable_methods = get_all_restrictable_methods(pagetype)
|
restrictable_methods = get_all_restrictable_methods(pagetype)
|
||||||
@ -218,7 +218,7 @@ def has_method_permission(pagetype: str, name: str, method: str, group_names: li
|
|||||||
|
|
||||||
user = jingrow.session.user
|
user = jingrow.session.user
|
||||||
|
|
||||||
if pagetype not in get_all_restrictable_doctypes():
|
if pagetype not in get_all_restrictable_pagetypes():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if method not in get_all_restrictable_methods(pagetype):
|
if method not in get_all_restrictable_methods(pagetype):
|
||||||
@ -240,7 +240,7 @@ def has_method_permission(pagetype: str, name: str, method: str, group_names: li
|
|||||||
def get_permitted_methods(pagetype: str, name: str, group_names: list | None = None) -> list:
|
def get_permitted_methods(pagetype: str, name: str, group_names: list | None = None) -> list:
|
||||||
user = jingrow.session.user
|
user = jingrow.session.user
|
||||||
|
|
||||||
if pagetype not in get_all_restrictable_doctypes():
|
if pagetype not in get_all_restrictable_pagetypes():
|
||||||
jingrow.throw(f"{pagetype} is not a valid restrictable pagetype.")
|
jingrow.throw(f"{pagetype} is not a valid restrictable pagetype.")
|
||||||
|
|
||||||
permissions_by_group = {}
|
permissions_by_group = {}
|
||||||
@ -314,7 +314,7 @@ def resolve_pg_permissions(pagetype, permissions_by_group: dict) -> dict: # noq
|
|||||||
return method_perms
|
return method_perms
|
||||||
|
|
||||||
|
|
||||||
def get_all_restrictable_doctypes() -> list:
|
def get_all_restrictable_pagetypes() -> list:
|
||||||
return ["Site", "Release Group"]
|
return ["Site", "Release Group"]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -130,11 +130,11 @@ class TestPressPermissionGroup(FrappeTestCase):
|
|||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
jingrow.ValidationError,
|
jingrow.ValidationError,
|
||||||
self.perm_group.get_all_document_permissions,
|
self.perm_group.get_all_document_permissions,
|
||||||
"InvalidDoctype",
|
"InvalidPagetype",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Test case 4: No restrictable methods for the pagetype
|
# Test case 4: No restrictable methods for the pagetype
|
||||||
self.assertRaises(jingrow.ValidationError, self.perm_group.get_all_document_permissions, "DocType2")
|
self.assertRaises(jingrow.ValidationError, self.perm_group.get_all_document_permissions, "PageType2")
|
||||||
|
|
||||||
|
|
||||||
# utils
|
# utils
|
||||||
|
|||||||
@ -953,7 +953,7 @@ class BaseServer(Document, TagHelpers):
|
|||||||
|
|
||||||
volumes = self.get_volume_mounts()
|
volumes = self.get_volume_mounts()
|
||||||
if volumes or self.has_data_volume:
|
if volumes or self.has_data_volume:
|
||||||
# Adding this condition since this method is called from both server and database server doctypes
|
# Adding this condition since this method is called from both server and database server pagetypes
|
||||||
if self.pagetype == "Server":
|
if self.pagetype == "Server":
|
||||||
mountpoint = BENCH_DATA_MNT_POINT
|
mountpoint = BENCH_DATA_MNT_POINT
|
||||||
elif self.pagetype == "Database Server":
|
elif self.pagetype == "Database Server":
|
||||||
|
|||||||
@ -21,7 +21,7 @@ class SiteAnalytics(Document):
|
|||||||
)
|
)
|
||||||
from jcloude.jcloude.pagetype.site_analytics_app.site_analytics_app import SiteAnalyticsApp
|
from jcloude.jcloude.pagetype.site_analytics_app.site_analytics_app import SiteAnalyticsApp
|
||||||
from jcloude.jcloude.pagetype.site_analytics_pagetype.site_analytics_pagetype import (
|
from jcloude.jcloude.pagetype.site_analytics_pagetype.site_analytics_pagetype import (
|
||||||
SiteAnalyticsDocType,
|
SiteAnalyticsPageType,
|
||||||
)
|
)
|
||||||
from jcloude.jcloude.pagetype.site_analytics_login.site_analytics_login import (
|
from jcloude.jcloude.pagetype.site_analytics_login.site_analytics_login import (
|
||||||
SiteAnalyticsLogin,
|
SiteAnalyticsLogin,
|
||||||
@ -42,7 +42,7 @@ class SiteAnalytics(Document):
|
|||||||
language: DF.Data | None
|
language: DF.Data | None
|
||||||
last_active: DF.Table[SiteAnalyticsActive]
|
last_active: DF.Table[SiteAnalyticsActive]
|
||||||
last_logins: DF.Table[SiteAnalyticsLogin]
|
last_logins: DF.Table[SiteAnalyticsLogin]
|
||||||
sales_data: DF.Table[SiteAnalyticsDocType]
|
sales_data: DF.Table[SiteAnalyticsPageType]
|
||||||
scheduler_enabled: DF.Check
|
scheduler_enabled: DF.Check
|
||||||
setup_complete: DF.Check
|
setup_complete: DF.Check
|
||||||
site: DF.Link
|
site: DF.Link
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
from jingrow.model.document import Document
|
from jingrow.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
class SiteAnalyticsDocType(Document):
|
class SiteAnalyticsPageType(Document):
|
||||||
# begin: auto-generated types
|
# begin: auto-generated types
|
||||||
# This code is auto-generated. Do not modify anything in this block.
|
# This code is auto-generated. Do not modify anything in this block.
|
||||||
|
|
||||||
|
|||||||
@ -312,7 +312,7 @@ class SiteMigration(Document):
|
|||||||
|
|
||||||
def _add_setup_redirects_step(self):
|
def _add_setup_redirects_step(self):
|
||||||
step = {
|
step = {
|
||||||
"step_title": self.setup_redirects.__pg__,
|
"step_title": self.setup_redirects.__doc__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
"method_name": self.setup_redirects.__name__,
|
"method_name": self.setup_redirects.__name__,
|
||||||
}
|
}
|
||||||
@ -405,7 +405,7 @@ class SiteMigration(Document):
|
|||||||
self.append(
|
self.append(
|
||||||
"steps",
|
"steps",
|
||||||
{
|
{
|
||||||
"step_title": self.archive_site_on_destination_server.__pg__,
|
"step_title": self.archive_site_on_destination_server.__doc__,
|
||||||
"method_name": self.archive_site_on_destination_server.__name__,
|
"method_name": self.archive_site_on_destination_server.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
@ -500,47 +500,47 @@ class SiteMigration(Document):
|
|||||||
def add_steps_for_cluster_migration(self):
|
def add_steps_for_cluster_migration(self):
|
||||||
steps = [
|
steps = [
|
||||||
{
|
{
|
||||||
"step_title": self.deactivate_site_on_source_server.__pg__,
|
"step_title": self.deactivate_site_on_source_server.__doc__,
|
||||||
"method_name": self.deactivate_site_on_source_server.__name__,
|
"method_name": self.deactivate_site_on_source_server.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.backup_source_site.__pg__,
|
"step_title": self.backup_source_site.__doc__,
|
||||||
"method_name": self.backup_source_site.__name__,
|
"method_name": self.backup_source_site.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.restore_site_on_destination_server.__pg__,
|
"step_title": self.restore_site_on_destination_server.__doc__,
|
||||||
"method_name": self.restore_site_on_destination_server.__name__,
|
"method_name": self.restore_site_on_destination_server.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.restore_site_on_destination_proxy.__pg__,
|
"step_title": self.restore_site_on_destination_proxy.__doc__,
|
||||||
"method_name": self.restore_site_on_destination_proxy.__name__,
|
"method_name": self.restore_site_on_destination_proxy.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.remove_site_from_source_proxy.__pg__,
|
"step_title": self.remove_site_from_source_proxy.__doc__,
|
||||||
"method_name": self.remove_site_from_source_proxy.__name__,
|
"method_name": self.remove_site_from_source_proxy.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.archive_site_on_source.__pg__,
|
"step_title": self.archive_site_on_source.__doc__,
|
||||||
"method_name": self.archive_site_on_source.__name__,
|
"method_name": self.archive_site_on_source.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.update_site_record_fields.__pg__,
|
"step_title": self.update_site_record_fields.__doc__,
|
||||||
"method_name": self.update_site_record_fields.__name__,
|
"method_name": self.update_site_record_fields.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.reset_site_status_on_destination.__pg__,
|
"step_title": self.reset_site_status_on_destination.__doc__,
|
||||||
"method_name": self.reset_site_status_on_destination.__name__,
|
"method_name": self.reset_site_status_on_destination.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.adjust_plan_if_required.__pg__,
|
"step_title": self.adjust_plan_if_required.__doc__,
|
||||||
"method_name": self.adjust_plan_if_required.__name__,
|
"method_name": self.adjust_plan_if_required.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
@ -551,47 +551,47 @@ class SiteMigration(Document):
|
|||||||
def add_steps_for_server_migration(self):
|
def add_steps_for_server_migration(self):
|
||||||
steps = [
|
steps = [
|
||||||
{
|
{
|
||||||
"step_title": self.deactivate_site_on_source_server.__pg__,
|
"step_title": self.deactivate_site_on_source_server.__doc__,
|
||||||
"method_name": self.deactivate_site_on_source_server.__name__,
|
"method_name": self.deactivate_site_on_source_server.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.backup_source_site.__pg__,
|
"step_title": self.backup_source_site.__doc__,
|
||||||
"method_name": self.backup_source_site.__name__,
|
"method_name": self.backup_source_site.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.restore_site_on_destination_server.__pg__,
|
"step_title": self.restore_site_on_destination_server.__doc__,
|
||||||
"method_name": self.restore_site_on_destination_server.__name__,
|
"method_name": self.restore_site_on_destination_server.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.archive_site_on_source.__pg__,
|
"step_title": self.archive_site_on_source.__doc__,
|
||||||
"method_name": self.archive_site_on_source.__name__,
|
"method_name": self.archive_site_on_source.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.remove_site_from_source_proxy.__pg__,
|
"step_title": self.remove_site_from_source_proxy.__doc__,
|
||||||
"method_name": self.remove_site_from_source_proxy.__name__,
|
"method_name": self.remove_site_from_source_proxy.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.restore_site_on_destination_proxy.__pg__,
|
"step_title": self.restore_site_on_destination_proxy.__doc__,
|
||||||
"method_name": self.restore_site_on_destination_proxy.__name__,
|
"method_name": self.restore_site_on_destination_proxy.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.update_site_record_fields.__pg__,
|
"step_title": self.update_site_record_fields.__doc__,
|
||||||
"method_name": self.update_site_record_fields.__name__,
|
"method_name": self.update_site_record_fields.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.reset_site_status_on_destination.__pg__,
|
"step_title": self.reset_site_status_on_destination.__doc__,
|
||||||
"method_name": self.reset_site_status_on_destination.__name__,
|
"method_name": self.reset_site_status_on_destination.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"step_title": self.adjust_plan_if_required.__pg__,
|
"step_title": self.adjust_plan_if_required.__doc__,
|
||||||
"method_name": self.adjust_plan_if_required.__name__,
|
"method_name": self.adjust_plan_if_required.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
},
|
},
|
||||||
|
|||||||
@ -332,7 +332,7 @@ def create_usage_records_of_date(
|
|||||||
def paid_plans():
|
def paid_plans():
|
||||||
paid_plans = []
|
paid_plans = []
|
||||||
|
|
||||||
doctypes = [
|
pagetypes = [
|
||||||
"Site Plan",
|
"Site Plan",
|
||||||
"Marketplace App Plan",
|
"Marketplace App Plan",
|
||||||
"Server Plan",
|
"Server Plan",
|
||||||
@ -340,7 +340,7 @@ def paid_plans():
|
|||||||
"Cluster Plan",
|
"Cluster Plan",
|
||||||
]
|
]
|
||||||
|
|
||||||
for name in doctypes:
|
for name in pagetypes:
|
||||||
pagetype = jingrow.qb.PageType(name)
|
pagetype = jingrow.qb.PageType(name)
|
||||||
if name in ("Server Plan", "Site Plan"):
|
if name in ("Server Plan", "Site Plan"):
|
||||||
paid_plans += (
|
paid_plans += (
|
||||||
|
|||||||
@ -180,7 +180,7 @@ class TLSCertificate(Document):
|
|||||||
|
|
||||||
@jingrow.whitelist()
|
@jingrow.whitelist()
|
||||||
def trigger_server_tls_setup_callback(self):
|
def trigger_server_tls_setup_callback(self):
|
||||||
server_doctypes = [
|
server_pagetypes = [
|
||||||
"Proxy Server",
|
"Proxy Server",
|
||||||
"Server",
|
"Server",
|
||||||
"Database Server",
|
"Database Server",
|
||||||
@ -191,7 +191,7 @@ class TLSCertificate(Document):
|
|||||||
"Trace Server",
|
"Trace Server",
|
||||||
]
|
]
|
||||||
|
|
||||||
for server_pagetype in server_doctypes:
|
for server_pagetype in server_pagetypes:
|
||||||
servers = jingrow.get_all(
|
servers = jingrow.get_all(
|
||||||
server_pagetype,
|
server_pagetype,
|
||||||
filters={
|
filters={
|
||||||
@ -420,7 +420,7 @@ def update_server_tls_certifcate(server, certificate):
|
|||||||
|
|
||||||
|
|
||||||
def retrigger_failed_wildcard_tls_callbacks():
|
def retrigger_failed_wildcard_tls_callbacks():
|
||||||
server_doctypes = [
|
server_pagetypes = [
|
||||||
"Proxy Server",
|
"Proxy Server",
|
||||||
"Server",
|
"Server",
|
||||||
"Database Server",
|
"Database Server",
|
||||||
@ -430,7 +430,7 @@ def retrigger_failed_wildcard_tls_callbacks():
|
|||||||
"Analytics Server",
|
"Analytics Server",
|
||||||
"Trace Server",
|
"Trace Server",
|
||||||
]
|
]
|
||||||
for server_pagetype in server_doctypes:
|
for server_pagetype in server_pagetypes:
|
||||||
servers = jingrow.get_all(
|
servers = jingrow.get_all(
|
||||||
server_pagetype, filters={"status": "Active"}, fields=["name", "tls_certificate_renewal_failed"]
|
server_pagetype, filters={"status": "Active"}, fields=["name", "tls_certificate_renewal_failed"]
|
||||||
)
|
)
|
||||||
|
|||||||
@ -56,7 +56,7 @@ if typing.TYPE_CHECKING:
|
|||||||
from jcloude.jcloude.pagetype.virtual_disk_snapshot.virtual_disk_snapshot import VirtualDiskSnapshot
|
from jcloude.jcloude.pagetype.virtual_disk_snapshot.virtual_disk_snapshot import VirtualDiskSnapshot
|
||||||
|
|
||||||
|
|
||||||
server_doctypes = [
|
server_pagetypes = [
|
||||||
"Server",
|
"Server",
|
||||||
"Database Server",
|
"Database Server",
|
||||||
"Proxy Server",
|
"Proxy Server",
|
||||||
@ -666,7 +666,7 @@ class VirtualMachine(Document):
|
|||||||
return jingrow.render_template(cloud_init_template, context, is_path=True)
|
return jingrow.render_template(cloud_init_template, context, is_path=True)
|
||||||
|
|
||||||
def get_server(self):
|
def get_server(self):
|
||||||
for pagetype in server_doctypes:
|
for pagetype in server_pagetypes:
|
||||||
server = jingrow.db.get_value(pagetype, {"virtual_machine": self.name}, "name")
|
server = jingrow.db.get_value(pagetype, {"virtual_machine": self.name}, "name")
|
||||||
if server:
|
if server:
|
||||||
return jingrow.get_pg(pagetype, server)
|
return jingrow.get_pg(pagetype, server)
|
||||||
@ -1088,7 +1088,7 @@ class VirtualMachine(Document):
|
|||||||
"Terminated": "Archived",
|
"Terminated": "Archived",
|
||||||
"Stopped": "Pending",
|
"Stopped": "Pending",
|
||||||
}
|
}
|
||||||
for pagetype in server_doctypes:
|
for pagetype in server_pagetypes:
|
||||||
server = jingrow.get_all(pagetype, {"virtual_machine": self.name}, pluck="name")
|
server = jingrow.get_all(pagetype, {"virtual_machine": self.name}, pluck="name")
|
||||||
if server:
|
if server:
|
||||||
server = server[0]
|
server = server[0]
|
||||||
|
|||||||
@ -38,8 +38,8 @@ COLUMNS = [
|
|||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "protected_doctypes",
|
"fieldname": "protected_pagetypes",
|
||||||
"label": "Protected Doctypes",
|
"label": "Protected Pagetypes",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -61,7 +61,7 @@ class FunctionAnalysis:
|
|||||||
function_name: str
|
function_name: str
|
||||||
line_number: int
|
line_number: int
|
||||||
is_protected: bool = False
|
is_protected: bool = False
|
||||||
protected_doctypes: list[str] = field(default_factory=list)
|
protected_pagetypes: list[str] = field(default_factory=list)
|
||||||
has_get_pg_with_input: bool = False
|
has_get_pg_with_input: bool = False
|
||||||
parameters: list[str] = field(default_factory=list)
|
parameters: list[str] = field(default_factory=list)
|
||||||
allow_guest: bool = False
|
allow_guest: bool = False
|
||||||
@ -72,7 +72,7 @@ class FunctionAnalysis:
|
|||||||
"function_name": self.function_name,
|
"function_name": self.function_name,
|
||||||
"line_number": self.line_number,
|
"line_number": self.line_number,
|
||||||
"is_protected": 1 if self.is_protected else 0,
|
"is_protected": 1 if self.is_protected else 0,
|
||||||
"protected_doctypes": ", ".join(self.protected_doctypes),
|
"protected_pagetypes": ", ".join(self.protected_pagetypes),
|
||||||
"is_get_pg_with_input": 1 if self.has_get_pg_with_input else 0,
|
"is_get_pg_with_input": 1 if self.has_get_pg_with_input else 0,
|
||||||
"parameters": ", ".join(self.parameters),
|
"parameters": ", ".join(self.parameters),
|
||||||
"allow_guest": 1 if self.allow_guest else 0,
|
"allow_guest": 1 if self.allow_guest else 0,
|
||||||
@ -111,7 +111,7 @@ class ASTAnalyzer:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_protected_doctypes(node: ast.FunctionDef) -> list[str] | None:
|
def get_protected_pagetypes(node: ast.FunctionDef) -> list[str] | None:
|
||||||
for decorator in node.decorator_list:
|
for decorator in node.decorator_list:
|
||||||
if isinstance(decorator, ast.Call):
|
if isinstance(decorator, ast.Call):
|
||||||
func = decorator.func
|
func = decorator.func
|
||||||
@ -178,7 +178,7 @@ class EndpointAuditor:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
parameters = self.analyzer.get_function_parameters(node)
|
parameters = self.analyzer.get_function_parameters(node)
|
||||||
protected_doctypes = self.analyzer.get_protected_doctypes(node)
|
protected_pagetypes = self.analyzer.get_protected_pagetypes(node)
|
||||||
allow_guest = self.analyzer.get_allow_guest(node)
|
allow_guest = self.analyzer.get_allow_guest(node)
|
||||||
|
|
||||||
has_get_pg_with_input = any(
|
has_get_pg_with_input = any(
|
||||||
@ -191,8 +191,8 @@ class EndpointAuditor:
|
|||||||
file_path=relative_path,
|
file_path=relative_path,
|
||||||
function_name=node.name,
|
function_name=node.name,
|
||||||
line_number=node.lineno,
|
line_number=node.lineno,
|
||||||
is_protected=protected_doctypes is not None,
|
is_protected=protected_pagetypes is not None,
|
||||||
protected_doctypes=protected_doctypes or [],
|
protected_pagetypes=protected_pagetypes or [],
|
||||||
has_get_pg_with_input=has_get_pg_with_input,
|
has_get_pg_with_input=has_get_pg_with_input,
|
||||||
parameters=parameters,
|
parameters=parameters,
|
||||||
allow_guest=allow_guest,
|
allow_guest=allow_guest,
|
||||||
|
|||||||
@ -399,7 +399,7 @@ class StepHandler:
|
|||||||
"""Generate a list of steps to be executed for NFS volume attachment."""
|
"""Generate a list of steps to be executed for NFS volume attachment."""
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"step_name": method.__pg__,
|
"step_name": method.__doc__,
|
||||||
"method_name": method.__name__,
|
"method_name": method.__name__,
|
||||||
"status": "Pending",
|
"status": "Pending",
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
### New SaaS Flow (Product Trial)
|
### New SaaS Flow (Product Trial)
|
||||||
|
|
||||||
It has 2 doctypes.
|
It has 2 pagetypes.
|
||||||
|
|
||||||
1. **Product Trial** - Hold the configuration for a specific product.
|
1. **Product Trial** - Hold the configuration for a specific product.
|
||||||
2. **Product Trial Request** - This holds the records of request for a specific product from a user.
|
2. **Product Trial Request** - This holds the records of request for a specific product from a user.
|
||||||
|
|||||||
@ -7,11 +7,11 @@ from jingrow.model.utils.rename_field import rename_field
|
|||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
rename_doctypes()
|
rename_pagetypes()
|
||||||
rename_fields()
|
rename_fields()
|
||||||
|
|
||||||
|
|
||||||
def rename_doctypes():
|
def rename_pagetypes():
|
||||||
renames = {
|
renames = {
|
||||||
"SaaS Product": "Product Trial",
|
"SaaS Product": "Product Trial",
|
||||||
"SaaS Product App": "Product Trial App",
|
"SaaS Product App": "Product Trial App",
|
||||||
|
|||||||
@ -595,12 +595,12 @@ class ttl_cache:
|
|||||||
return wrapper_func
|
return wrapper_func
|
||||||
|
|
||||||
|
|
||||||
def poly_get_pagetype(doctypes, name):
|
def poly_get_pagetype(pagetypes, name):
|
||||||
"""Get the pagetype value from the given name of a pg from a list of doctypes"""
|
"""Get the pagetype value from the given name of a pg from a list of pagetypes"""
|
||||||
for pagetype in doctypes:
|
for pagetype in pagetypes:
|
||||||
if jingrow.db.exists(pagetype, name):
|
if jingrow.db.exists(pagetype, name):
|
||||||
return pagetype
|
return pagetype
|
||||||
return doctypes[-1]
|
return pagetypes[-1]
|
||||||
|
|
||||||
|
|
||||||
def reconnect_on_failure():
|
def reconnect_on_failure():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user