Skip to content

Je 69964 #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: v2.2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ categories:
name: Auto-Scalable Magento Cluster v2
logo: /images/magento-enterprise-small-v2.png

baseUrl: https://raw.githubusercontent.com/jelastic-jps/magento-cluster/v2.2.0
baseUrl: https://raw.githubusercontent.com/sych74/magento-cluster/JE-69964

onBeforeInstall: /scripts/beforeinstall.js?_r=${fn.random}
onBeforeInit: /scripts/beforeinit.js?_r=${fn.random}
onBeforeInstall: /scripts/beforeInstall.js?_r=${fn.random}
onBeforeInit: /scripts/beforeInit.js?_r=${fn.random}
nodes: definedInOnBeforeInstall
skipNodeEmails: true

settings:
onBeforeInit: return settings;
fields:
- caption: Scaling Strategy
type: list
Expand Down Expand Up @@ -69,13 +70,6 @@ settings:
disabled: false
tooltip: "Jelastic CDN is an HTTP/3 premium content delivery network of 160+ Super PoPs (points of presence) with bandwidth capacity up to 115 Tbps, advanced caching and acceleration strategies based on best-in-class IP Anycast technology."

- type: displayfield
hideLabel: true
hidden: true
name: bl_count
value: 1
markup:

mixins:
- https://raw.githubusercontent.com/jelastic-jps/magento-cluster/master/configs/vers.yaml

Expand Down Expand Up @@ -256,7 +250,7 @@ actions:
jem service restart
user: root

- env.control.ApplyNodeGroupData[nosqldb]:
- env.control.ApplyData[nosqldb]:
data:
adminUrl: "http://node${nodes.nosqldb.master.id}-${env.domain}:4949"
validation :
Expand Down
154 changes: 154 additions & 0 deletions scripts/beforeInit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
import com.hivext.api.Response;
import org.yaml.snakeyaml.Yaml;
import com.hivext.api.core.utils.Transport;

var cdnAppid = "c05ffa5b45628a2a0c95467ebca8a0b4test";
var lsAppid = "9e6afcf310004ac84060f90ff41a5aba";
var isCDN = jelastic.dev.apps.GetApp(cdnAppid);
var isLS = jelastic.dev.apps.GetApp(lsAppid);

//checking quotas
var perEnv = "environment.maxnodescount",
maxEnvs = "environment.maxcount",
perNodeGroup = "environment.maxsamenodescount",
maxCloudletsPerRec = "environment.maxcloudletsperrec",
extIP = "environment.externalip.enabled",
extIPperEnv = "environment.externalip.maxcount",
extIPperNode = "environment.externalip.maxcount.per.node";

var nodesPerEnvMin = 7,
nodesPerGroupMin = 2,
maxCloudlets = 32,
markup = "", cur = null, prod = true, le_markup = "", le = true, ls = true, warn_text = "";

var hasCollaboration = (parseInt("${fn.compareEngine(7.0)}", 10) >= 0),
quotas = [], group;

if (hasCollaboration) {
quotas = [
{ quota : { name: perEnv, description: getQuotaDescription(perEnv) }, value: parseInt('${quota.environment.maxnodescount}', 10) },
{ quota : { name: maxEnvs, description: getQuotaDescription(maxEnvs) }, value: parseInt('${quota.environment.maxcount}', 10) },
{ quota : { name: perNodeGroup, description: getQuotaDescription(perNodeGroup) }, value: parseInt('${quota.environment.maxsamenodescount}', 10) },
{ quota : { name: maxCloudletsPerRec, description: getQuotaDescription(maxCloudletsPerRec) }, value: parseInt('${quota.environment.maxcloudletsperrec}', 10) },
{ quota : { name: extIP, description: getQuotaDescription(extIP) }, value: parseInt('${quota.environment.externalip.enabled}', 10) },
{ quota : { name: extIPperEnv, description: getQuotaDescription(extIPperEnv) }, value: parseInt('${quota.environment.externalip.maxcount}', 10) },
{ quota : { name: extIPperNode, description: getQuotaDescription(extIPperNode) }, value: parseInt('${quota.environment.externalip.maxcount.per.node}', 10) }
];
group = { groupType: '${account.groupType}' };
} else {
quotas.push(jelastic.billing.account.GetQuotas(perEnv).array[0]);
quotas.push(jelastic.billing.account.GetQuotas(maxEnvs).array[0]);
quotas.push(jelastic.billing.account.GetQuotas(perNodeGroup).array[0]);
quotas.push(jelastic.billing.account.GetQuotas(maxCloudletsPerRec).array[0]);
quotas.push(jelastic.billing.account.GetQuotas(extIP).array[0]);
quotas.push(jelastic.billing.account.GetQuotas(extIPperEnv).array[0]);
quotas.push(jelastic.billing.account.GetQuotas(extIPperNode).array[0]);
group = jelastic.billing.account.GetAccount(appid, session);
}

var settings = jps.settings;
var fields = {};
for (var i = 0, field; field = jps.settings.fields[i]; i++)
fields[field.name] = field;

for (var i = 0; i < quotas.length; i++){
var q = quotas[i], n = toNative(q.quota.name);

if (n == maxCloudletsPerRec && maxCloudlets > q.value){
markup = err(q, "required", maxCloudlets);
prod = false; break;
}

if (n == perEnv && nodesPerEnvMin > q.value){
markup = err(q, "required", nodesPerEnvMin);
prod = false; break;
}

if (n == perNodeGroup && nodesPerGroupMin > q.value){
markup = err(q, "required", nodesPerGroupMin);
prod = false; break;
}

if (n == extIP && !q.value){
le_markup = err(q, "required", 1);
le = false; break;
}

if (n == extIPperEnv && q.value < 1){
le_markup = err(q, "required", 1);
le = false; break;
}

if (n == extIPperNode && q.value < 1){
le_markup = err(q, "required", 1);
le = false; break;
}

if (!(isLS.result == 0 || isLS.result == Response.PERMISSION_DENIED)) {
ls = false;
prod = false; break;
}

if (isCDN.result == 0 || isCDN.result == Response.PERMISSION_DENIED) {
fields["cdn_addon"].hidden = false;
fields["cdn_addon"].value = true;
} else {
disableFields(["cdn_addon"]);
}
}

if (!le) {
disableFields(["le_addon"]);
setDisplayWarning("displayfield", "Some advanced features are not available.", 25);
warn_text = warn_text + " L'ets Encrypt is not available. " + le_markup + "Please upgrade your account.";
addDisplayWarning(warn_text, 30);
}

if (!prod || group.groupType == 'trial') {
disableFields(["loadGrowth", "waf", "le_addon", "cdn_addon"]);
setDisplayWarning("displayfield", "Advanced features are not available.", 25);
warn_text = (group.groupType == 'trial')
? "Magento cluster is not available for " + group.groupType + ". Please upgrade your account."
: "Magento cluster is not available. " + markup + " Please upgrade your account.";
if (!ls)
warn_text = "LiteSpeed software stack templates are not supported at the moment for the current Hosting Provider (Partner)";
addDisplayWarning(warn_text, 30);
settings.submitType = 'upgrade';
}

function getQuotaDescription(name) {
return jelastic.billing.account.GetQuotas(name).array[0].quota.description;
}

function disableFields(names) {
for (var i = 0; i < names.length; i++) {
if (fields[names[i]]) {
fields[names[i]].value = false;
fields[names[i]].disabled = true;
}
}
}

function addDisplayWarning(warn_text, height) {
settings.fields.push(
{"type": "displayfield", "cls": "warning", "height": height, "hideLabel": true, "markup": warn_text}
);
}

function setDisplayWarning(field, warn_text, height) {
fields[field].markup = warn_text;
fields[field].cls = "warning";
fields[field].hideLabel = true;
fields[field].hidden = false;
fields[field].height = height;
}

function err(e, text, cur){
var m = (e.quota.description || e.quota.name) + " - " + e.value + ", " + text + " - " + cur + ". ";
return m;
}

return {
result: 0,
settings: settings
};
5 changes: 2 additions & 3 deletions scripts/beforeinstall.js → scripts/beforeInstall.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var db_cluster = '${settings.galera}' == 'true' ? "galera" : "master";
var resp = {
result: 0,
nodes: []
Expand All @@ -24,13 +23,13 @@ resp.nodes.push({
restartDelay: 10,
skipNodeEmails: true,
cluster: {
scheme: db_cluster,
scheme: "master",
db_user: "${globals.DB_USER}",
db_pass: "${globals.DB_PASS}",
is_proxysql: false,
},
env: {
SCHEME: db_cluster,
SCHEME: "master",
DB_USER: "${globals.DB_USER}",
DB_PASS: "${globals.DB_PASS}",
IS_PROXYSQL: false
Expand Down
116 changes: 0 additions & 116 deletions scripts/beforeinit.js

This file was deleted.