const co = require('co');
const config = require('./config');
const fts = require('./fts');
const addEnclosure = require('./addEnclosure');
const addProfile = require('./addProfile');
const addStorageSystem = require('./addStorageSystem');
const addVolume = require('./addVolume');

co(function*() {
  const { oneviews, staticIPs } = config;
  const promises = oneviews.map((oneviewIP, index) => {
    return co(function *() {
      yield fts(oneviewIP, staticIPs[index]);
      yield addEnclosure(staticIPs[index]);
      yield addProfile(staticIPs[index]);
      yield addStorageSystem(staticIPs[index]);
      yield addVolume(staticIPs[index]);
    });
  });
  yield Promise.all(promises);
}).then(() => {
  console.log('Done');
}).catch((err) => {
  if (err instanceof Error) {
    console.error(`${err.message}, stack:${err.stack}`);
  } else {
    console.error(JSON.stringify(err));
  }
});

@@ -1,16 +1,64 @@
+const child_process = require('child_process');%0A
 const co = requi
@@ -63,24 +63,24 @@
 uire('co');%0A
-
 const config
@@ -324,16 +324,1556 @@
 ume');%0A%0A
+const addSshPass = function(ip) %7B%0A  return new Promise((resolve, reject) =%3E %7B%0A    child_process.exec(%60sh addSshPass.sh $%7Bip%7D%60, (err, stdout, stderr) =%3E %7B%0A      if (err) %7B%0A        console.error(%60addSshPass fail: $%7Berr%7D, stderr: $%7Bstderr%7D%60);%0A        reject(err);%0A        return;%0A      %7D%0A      console.log(%60%5B$%7Bip%7D%5D addSshPass succeed: $%7Bstdout%7D%60);%0A      resolve();%0A    %7D);%0A  %7D);%0A%7D;%0Aconst getDCS = function(ip) %7B%0A  return new Promise((resolve, reject) =%3E %7B%0A    child_process.exec(%60ssh $%7Bip%7D dcs status%60, (err, stdout, stderr) =%3E %7B%0A      console.log(%60%5B$%7Bip%7D%5D getDCS succeed: $%7Bstderr%7D $%7Bstdout%7D%60);%0A      resolve(stdout);%0A    %7D);%0A  %7D);%0A%7D;%0Aconst changeDCS = function(ip) %7B%0A  return new Promise((resolve, reject) =%3E %7B%0A    child_process.exec(%60ssh $%7Bip%7D dcs stop; ssh $%7Bip%7D dcs start $%7Bconfig.dcsSchema%7D cold%60, (err, stdout, stderr) =%3E %7B%0A      console.log(%60%5B$%7Bip%7D%5D changeDCS succeed: $%7Bstderr%7D $%7Bstdout%7D%60);%0A      resolve();%0A    %7D);%0A  %7D);%0A%7D;%0Aconst waitForDCS = function(ip) %7B%0A  return co(function*() %7B%0A    let isDCSRunning;%0A    let matchSchema;%0A    do %7B%0A      const dcs = yield getDCS(ip);%0A      isRunning = dcs.search(/DCS is Running/);%0A      matchSchema = dcs.search(new RegExp('Schematic used:  ' + config.dcsSchema));%0A      console.log(%60%5B$%7Bip%7D%5D dcs isRunning=$%7BisRunning%7D matchSchema=$%7BmatchSchema%7D%60);%0A      if (isRunning === -1 %7C%7C matchSchema === -1) %7B%0A        yield changeDCS(ip);%0A        yield new Promise((resolve, reject) =%3E %7B%0A          setTimeout(resolve, 3000);%0A        %7D);%0A      %7D else %7B%0A        break;%0A      %7D%0A    %7D while (true)%0A  %7D);%0A%7D%0A%0A
 co(funct
@@ -1975,24 +1975,24 @@
 index) =%3E %7B%0A
-
     return c
@@ -2004,24 +2004,96 @@
 ction *() %7B%0A
+      //yield addSshPass(oneviewIP);%0A      yield waitForDCS(oneviewIP);%0A
       yield 

Add dcs setup before fts