Skip to content
Merged
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
13 changes: 13 additions & 0 deletions cli/src/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,21 @@ const generateConfig = async () => {
// Add name to config
config.name = configData.name.toLowerCase().replace(/\s/g, '-');

// Add nodesRole to config
config.nodesRole = configData.nodesRole;

// Add nexmoApiKey to config
config.nexmoApiKey = configData.nexmoApiKey;

// Add nexmoApiSecret to config
config.nexmoApiSecret = configData.nexmoApiSecret;

// Add nexmoPhoneNumber to config
config.nexmoPhoneNumber = configData.nexmoPhoneNumber;

// Add outletPhoneNumber to config
config.outletPhoneNumber = configData.outletPhoneNumber;

// Add node number to config
config.nodesNumber = externalIPAddresses.length;

Expand Down
6 changes: 5 additions & 1 deletion cli/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ const {
const configTemplate = {
name: 'Archipel Name',
publicIps: '1.1.1.1,2.2.2.2,3.3.3.3,4.4.4.4,5.5.5.5,6.6.6.6',
nodesRole: 'operator,operator,operator,sentry,sentry,sentry'
nodesRole: 'operator,operator,operator,sentry,sentry,sentry',
nexmoApiKey :'null,null,null,null,null,null',
nexmoApiSecret :'null,null,null,null,null,null',
nexmoPhoneNumber:'null,null,null,null,null,null',
outletPhoneNumber:'null,null,null,null,null,null'
};

const initConfig = async service => {
Expand Down
67 changes: 67 additions & 0 deletions deployer/archipel/start-orchestrator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,56 @@ if [ ! -z "$CONFIG_FILE" ]; then
NODE_ROLE=${rolesArray[index]}
fi

#get nexmoApiKey
if [ -z "$NEXMO_API_KEY" ]; then
NEXMO_API_KEY_LIST=$(cat /config/config.json | jq ".nexmoApiKey")
check_cmd $? 'retrieve NEXMO_API_KEY_LIST'
if [ "$NEXMO_API_KEY_LIST" != "null" ]; then
IFS=',' read -ra apikeysArray <<< "$NEXMO_API_KEY_LIST"
index=$(( $NODE_ID - 1 ))
value=${apikeysArray[index]}
if [ "$value" != "null" ]; then
NEXMO_API_KEY=${apikeysArray[index]}
fi
fi
fi

#get nexmoApiSecret
if [ -z "$NEXMO_API_SECRET" ]; then
NEXMO_API_SECRET_LIST=$(cat /config/config.json | jq ".nexmoApiSecret")
check_cmd $? 'retrieve NEXMO_API_SECRET_LIST'
if [ "$NEXMO_API_SECRET_LIST" != "null" ]; then
IFS=',' read -ra apiSecretArray <<< "$NEXMO_API_SECRET_LIST"
index=$(( $NODE_ID - 1 ))
value=${apiSecretArray[index]}
if [ "$value" != "null" ]; then
NEXMO_API_SECRET=${apiSecretArray[index]}
fi
fi
fi

#get TWILOIPhoneNumber
if [ -z "$NEXMO_PHONE_NUMBER" ]; then
NEXMO_PHONE_NUMBER_LIST=$(cat /config/config.json | jq ".nexmoPhoneNumber")
check_cmd $? 'retrieve NEXMO_PHONE_NUMBER_LIST'
if [ "$NEXMO_PHONE_NUMBER_LIST" != "null" ]; then
IFS=',' read -ra phoneNumbersArray <<< "$NEXMO_PHONE_NUMBER_LIST"
index=$(( $NODE_ID - 1 ))
value=${phoneNumbersArray[index]}
if [ "$value" != "null" ]; then
NEXMO_PHONE_NUMBER=${phoneNumbersArray[index]}
fi
fi
fi

if [ -z "$OUTLET_PHONE_NUMBER_LIST" ]; then
OUTLET_PHONE_NUMBER_LIST=$(cat /config/config.json | jq ".outletPhoneNumber")
check_cmd $? 'retrieve OUTLET_PHONE_NUMBERS'
if [ "$OUTLET_PHONE_NUMBERS" != "null" ]; then
OUTLET_PHONE_NUMBER_LIST=$OUTLET_PHONE_NUMBER_LIST
fi
fi

#get ARCHIPEL_KEY_SEED
if [ -z "$ARCHIPEL_KEY_SEED" ]; then
ARCHIPEL_KEY_SEED=$(cat /config/config.json | jq ".archipelNodes[$(( $NODE_ID - 1))].seed" | sed 's/\"//g')
Expand Down Expand Up @@ -105,7 +155,15 @@ if [ -z "$NODE_ROLE" ]; then
fi
echo "NODE_ROLE=$NODE_ROLE"

if [ -z "$SMS_STONITH_ACTIVE" ]; then
echo "set default value to false for SMS_STONITH_ACTIVE"
SMS_STONITH_ACTIVE="false"
fi

if [ -z "$SMS_STONITH_CALLBACK_MANDATORY" ]; then
echo "set default value to false for SMS_STONITH_CALLBACK_MANDATORY"
SMS_STONITH_CALLBACK_MANDATORY="false"
fi

# Setting Archipel orchestrator variables
NODE_ROLE=$(echo $NODE_ROLE | sed 's/\"//g')
Expand All @@ -119,6 +177,15 @@ export NODES_WALLETS="$ARCHIPEL_AUTHORITIES_SR25519_LIST"
export ARCHIPEL_NAME="$ARCHIPEL_NAME"
export ALIVE_TIME=60000
export SUSPEND_SERVICE="$ARCHIPEL_SUSPEND_SERVICE"
export AUTHORITIES_LIST="$ARCHIPEL_AUTHORITIES_SR25519_LIST"
export SMS_STONITH_ACTIVE="$SMS_STONITH_ACTIVE"
export SMS_STONITH_CALLBACK_MANDATORY="$SMS_STONITH_CALLBACK_MANDATORY"
export NEXMO_API_KEY="$NEXMO_API_KEY"
export NEXMO_API_SECRET="$NEXMO_API_SECRET"
export NEXMO_PHONE_NUMBER="$NEXMO_PHONE_NUMBER"
export OUTLET_PHONE_NUMBER_LIST="$OUTLET_PHONE_NUMBER_LIST"



# Generate env file in shared volume for Archipel UI to auto-detect the local API endpoint
ARCHIPEL_CONTAINER_IP=$(awk 'END{print $1}' /etc/hosts)
Expand Down
1 change: 1 addition & 0 deletions orchestrator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"express": "^4.17.1",
"express-async-handler": "^1.1.4",
"fs-extra": "^8.1.0",
"nexmo": "^2.7.0",
"set-interval-async": "^1.0.30"
},
"devDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions orchestrator/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const mainRoutes = require('./routes/main');
const metricsRoutes = require('./routes/metrics');
const orchestratorRoutes = require('./routes/orchestrator');
const serviceRoutes = require('./routes/service');
const smsRoutes = require('./routes/sms');

// Return not found response
const get404 = (req, res, next) => {
Expand Down Expand Up @@ -54,6 +55,7 @@ const initApi = async orchestrator => {
app.use('/metrics', metricsRoutes.routes);
app.use('/orchestration', orchestratorRoutes.routes);
app.use('/service', serviceRoutes.routes);
app.use('/sms', smsRoutes.routes);

// Add not found middleware
app.use(get404);
Expand Down
30 changes: 28 additions & 2 deletions orchestrator/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const {
initApi
} = require('./api');


// Import env variables from .env file
dotenv.config();
const {
Expand All @@ -25,7 +26,15 @@ const {
NODES_WALLETS,
ARCHIPEL_NAME,
NODE_ROLE,
NODES_ROLE
NODES_ROLE,
SMS_STONITH_ACTIVE,
SMS_STONITH_CALLBACK_MANDATORY,
AUTHORITIES_LIST,
NEXMO_API_KEY,
NEXMO_API_SECRET,
NEXMO_PHONE_NUMBER,
OUTLET_PHONE_NUMBER_LIST

} = process.env;

// Check if all necessary env vars were set
Expand All @@ -39,6 +48,9 @@ const checkEnvVars = () => {
checkVariable(NODES_WALLETS, 'NODES_WALLETS');
checkVariable(NODE_ROLE, 'NODE_ROLE');
checkVariable(NODES_ROLE, 'NODES_ROLE');
checkVariable(SMS_STONITH_ACTIVE, 'SMS_STONITH_ACTIVE');
checkVariable(SMS_STONITH_CALLBACK_MANDATORY, 'SMS_STONITH_CALLBACK_MANDATORY');
checkVariable(AUTHORITIES_LIST, 'AUTHORITIES_LIST');
} catch (error) {
debug('checkEnvVars', error);
throw error;
Expand All @@ -63,7 +75,21 @@ async function main () {
const metrics = new Metrics(nodes);

// Create orchestrator instance
const orchestrator = new Orchestrator(chain, SERVICE, metrics, MNEMONIC, ALIVE_TIME, ARCHIPEL_NAME, NODE_ROLE);
const orchestrator = new Orchestrator(
chain,
SERVICE,
metrics,
MNEMONIC,
ALIVE_TIME,
ARCHIPEL_NAME,
NODE_ROLE,
SMS_STONITH_ACTIVE,
SMS_STONITH_CALLBACK_MANDATORY,
NEXMO_API_KEY.replace(/"/g, ''),
NEXMO_API_SECRET.replace(/"/g, ''),
NEXMO_PHONE_NUMBER.replace(/"/g, ''),
OUTLET_PHONE_NUMBER_LIST.replace(/"/g, ''),
AUTHORITIES_LIST);

// If orchestrator is launched in suspend service mode disabling metrics send and orchestration
if (SUSPEND_SERVICE.includes('true')) {
Expand Down
Loading