Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3 from christav/site-restart

Implmented azure site restart command
  • Loading branch information...
commit 7122c8b94b81eb0a1774d8ef5c76892d2ea798c2 2 parents 616e302 + ec0a180
Chris Tavares christav authored
121 lib/cli/commands/site.js
View
@@ -659,7 +659,7 @@ exports.init = function(cli) {
- site.command("start [name]").whiteListPowershell().description("Start a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __8(name, options, _) { var context, progress, result; var __frame = { name: "__8", line: 666 }; return __func(_, this, arguments, __8, 2, __frame, function __$__8() {
+ site.command("start [name]").whiteListPowershell().description("Start a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __8(name, options, _) { var context; var __frame = { name: "__8", line: 666 }; return __func(_, this, arguments, __8, 2, __frame, function __$__8() {
@@ -675,42 +675,33 @@ exports.init = function(cli) {
log.info("Starting site", context.site.name);
- progress = cli.progress("Updating site state"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__8() {
+ return updateSiteState(getChannel(), context, "Running", __cb(_, __frame, 12, 10, function __$__8() {
+ log.info((("Site " + context.site.name) + " has been started")); _(); }, true)); }, true)); }); });
+ site.command("stop [name]").whiteListPowershell().description("Stop a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __9(name, options, _) { var context; var __frame = { name: "__9", line: 687 }; return __func(_, this, arguments, __9, 2, __frame, function __$__9() {
+ context = {
+ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
+ site: {
+ name: name } };
- return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).header("Content-Type", "application/xml").PUT(function(req) {
- req.write("<Site xmlns=\"http://schemas.microsoft.com/windowsazure\">");
- req.write("<HostNames>");
- req.write("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">");
- req.write((context.site.name + utils.getHostNameSuffix()));
- req.write("</string>");
- req.write("</HostNames>");
- req.write("<Name>");
- req.write(context.site.name);
- req.write("</Name>");
- req.write("<State>");
- req.write("Running");
- req.write("</State>");
- req.write("</Site>");
-
- req.end(); }, __cb(_, __frame, 22, 25, function ___(__0, __1) { result = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__8() {
-
+ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__9() {
- progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__8() {
+ log.info("Stopping site", context.site.name);
+ return updateSiteState(getChannel(), context, "Stopped", __cb(_, __frame, 12, 10, function __$__9() {
- log.info((("Site " + context.site.name) + " has been started")); _(); }); }); }, true)); }); });
+ log.info((("Site " + context.site.name) + " has been stopped")); _(); }, true)); }, true)); }); });
- site.command("stop [name]").whiteListPowershell().description("Stop a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __9(name, options, _) { var context, progress, result; var __frame = { name: "__9", line: 717 }; return __func(_, this, arguments, __9, 2, __frame, function __$__9() {
+ site.command("restart [name]").whiteListPowershell().description("Stop and then start a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __10(name, options, _) { var context; var __frame = { name: "__10", line: 708 }; return __func(_, this, arguments, __10, 2, __frame, function __$__10() {
@@ -722,65 +713,71 @@ exports.init = function(cli) {
- return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__9() {
+ return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__10() {
log.info("Stopping site", context.site.name);
+ return updateSiteState(getChannel(), context, "Stopped", __cb(_, __frame, 11, 10, function __$__10() {
- progress = cli.progress("Updating site state"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__9() {
+ log.info((("Site " + context.site.name) + " has been stopped, restarting"));
+ return updateSiteState(getChannel(), context, "Running", __cb(_, __frame, 14, 10, function __$__10() {
+ log.info((("Site " + context.site.name) + " has been restarted")); _(); }, true)); }, true)); }, true)); }); });
+ function updateSiteState(channel, context, newState, _) { var progress, result; var __frame = { name: "updateSiteState", line: 726 }; return __func(_, this, arguments, updateSiteState, 3, __frame, function __$updateSiteState() {
+ progress = cli.progress("Updating site state"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$updateSiteState() {
- return getChannel().path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).header("Content-Type", "application/xml").PUT(function(req) {
- req.write("<Site xmlns=\"http://schemas.microsoft.com/windowsazure\">");
- req.write("<HostNames>");
- req.write("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">");
- req.write((context.site.name + utils.getHostNameSuffix()));
- req.write("</string>");
- req.write("</HostNames>");
- req.write("<Name>");
- req.write(context.site.name);
- req.write("</Name>");
- req.write("<State>");
- req.write("Stopped");
- req.write("</State>");
- req.write("</Site>");
- req.end(); }, __cb(_, __frame, 22, 25, function ___(__0, __1) { result = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__9() {
+ return channel.path(context.subscription).path("services").path("webspaces").path(context.site.webspace).path("sites").path(context.site.name).header("Content-Type", "application/xml").PUT(function(req) {
+ req.write("<Site xmlns=\"http://schemas.microsoft.com/windowsazure\">");
+ req.write("<HostNames>");
+ req.write("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">");
+ req.write((context.site.name + utils.getHostNameSuffix()));
+ req.write("</string>");
+ req.write("</HostNames>");
+ req.write("<Name>");
+ req.write(context.site.name);
+ req.write("</Name>");
+ req.write("<State>");
+ req.write(newState);
+ req.write("</State>");
+ req.write("</Site>");
- progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__9() {
+ req.end(); }, __cb(_, __frame, 12, 21, function ___(__0, __1) { result = __1; _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$updateSiteState() {
- log.info((("Site " + context.site.name) + " has been stopped")); _(); }); }); }, true)); }); });
+
+ progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };
+
- site.readConfig = function site_readConfig__10(_) { var __frame = { name: "site_readConfig__10", line: 768 }; return __func(_, this, arguments, site_readConfig__10, 0, __frame, function __$site_readConfig__10() {
+ site.readConfig = function site_readConfig__11(_) { var __frame = { name: "site_readConfig__11", line: 765 }; return __func(_, this, arguments, site_readConfig__11, 0, __frame, function __$site_readConfig__11() {
return site.readConfigValue("azure.site.name", __cb(_, __frame, 2, 12, function ___(__0, __2) {
return site.readConfigValue("azure.site.webspace", __cb(_, __frame, 3, 16, function ___(__0, __3) { var __1 = { name: __2, webspace: __3 }; return _(null, __1); }, true)); }, true)); }); };
- site.writeConfig = function site_writeConfig__11(cfg, _) { var __frame = { name: "site_writeConfig__11", line: 775 }; return __func(_, this, arguments, site_writeConfig__11, 1, __frame, function __$site_writeConfig__11() {
- return site.writeConfigValue("azure.site.name", cfg.name, __cb(_, __frame, 1, 4, function __$site_writeConfig__11() {
+ site.writeConfig = function site_writeConfig__12(cfg, _) { var __frame = { name: "site_writeConfig__12", line: 772 }; return __func(_, this, arguments, site_writeConfig__12, 1, __frame, function __$site_writeConfig__12() {
+ return site.writeConfigValue("azure.site.name", cfg.name, __cb(_, __frame, 1, 4, function __$site_writeConfig__12() {
return site.writeConfigValue("azure.site.webspace", cfg.webspace, __cb(_, __frame, 2, 4, _, true)); }, true)); }); };
- site.readConfigValue = function site_readConfigValue__12(name, _) { var result; var __frame = { name: "site_readConfigValue__12", line: 780 }; return __func(_, this, arguments, site_readConfigValue__12, 1, __frame, function __$site_readConfigValue__12() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_readConfigValue__12() {
+ site.readConfigValue = function site_readConfigValue__13(name, _) { var result; var __frame = { name: "site_readConfigValue__13", line: 777 }; return __func(_, this, arguments, site_readConfigValue__13, 1, __frame, function __$site_readConfigValue__13() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_readConfigValue__13() {
return exec(("git config --get " + name), __cb(_, __frame, 2, 19, function ___(__0, __1) { result = __1;
- return _(null, ((result.stdout + result.stderr)).trim()); }, true)); }); })(function ___(err, __result) { __tryCatch(_, function __$site_readConfigValue__12() { if (err) {
+ return _(null, ((result.stdout + result.stderr)).trim()); }, true)); }); })(function ___(err, __result) { __tryCatch(_, function __$site_readConfigValue__13() { if (err) {
log.silly("Unable to read config", err);
@@ -788,7 +785,7 @@ exports.init = function(cli) {
- site.writeConfigValue = function site_writeConfigValue__13(name, value, _) { var __frame = { name: "site_writeConfigValue__13", line: 791 }; return __func(_, this, arguments, site_writeConfigValue__13, 2, __frame, function __$site_writeConfigValue__13() {
+ site.writeConfigValue = function site_writeConfigValue__14(name, value, _) { var __frame = { name: "site_writeConfigValue__14", line: 788 }; return __func(_, this, arguments, site_writeConfigValue__14, 2, __frame, function __$site_writeConfigValue__14() {
return exec(((("git config " + name) + " ") + value), __cb(_, __frame, 1, 4, _, true)); }); };
@@ -886,10 +883,10 @@ exports.init = function(cli) {
- site.doSpacesGet = function site_doSpacesGet__14(options, _) { var progress, result, spaces; var __frame = { name: "site_doSpacesGet__14", line: 889 }; return __func(_, this, arguments, site_doSpacesGet__14, 1, __frame, function __$site_doSpacesGet__14() {
+ site.doSpacesGet = function site_doSpacesGet__15(options, _) { var progress, result, spaces; var __frame = { name: "site_doSpacesGet__15", line: 886 }; return __func(_, this, arguments, site_doSpacesGet__15, 1, __frame, function __$site_doSpacesGet__15() {
log.verbose("Subscription", options.subscription);
- progress = cli.progress("Enumerating locations"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doSpacesGet__14() {
+ progress = cli.progress("Enumerating locations"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doSpacesGet__15() {
@@ -900,15 +897,15 @@ exports.init = function(cli) {
log.json("silly", result);
spaces = toArray(result.WebSpace);
- return cacheUtils.saveSpaces(options, spaces, __cb(_, __frame, 14, 6, function __$site_doSpacesGet__14() {
- return _(null, spaces); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$site_doSpacesGet__14() {
+ return cacheUtils.saveSpaces(options, spaces, __cb(_, __frame, 14, 6, function __$site_doSpacesGet__15() {
+ return _(null, spaces); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$site_doSpacesGet__15() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };
- site.doSitesGet = function site_doSitesGet__15(options, _) { var spaces, channel, progress, result, sites; var __frame = { name: "site_doSitesGet__15", line: 911 }; return __func(_, this, arguments, site_doSitesGet__15, 1, __frame, function __$site_doSitesGet__15() {
+ site.doSitesGet = function site_doSitesGet__16(options, _) { var spaces, channel, progress, result, sites; var __frame = { name: "site_doSitesGet__16", line: 908 }; return __func(_, this, arguments, site_doSitesGet__16, 1, __frame, function __$site_doSitesGet__16() {
log.verbose("Subscription", options.subscription);
return site.doSpacesGet(options, __cb(_, __frame, 3, 17, function ___(__0, __2) { spaces = __2;
@@ -918,9 +915,9 @@ exports.init = function(cli) {
channel = getChannel().path(options.subscription).path("services").path("webspaces");
- progress = cli.progress("Enumerating sites"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doSitesGet__15() {
+ progress = cli.progress("Enumerating sites"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doSitesGet__16() {
- return async.map(spaces, function __1(webspace, _) { var __frame = { name: "__1", line: 925 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
+ return async.map(spaces, function __1(webspace, _) { var __frame = { name: "__1", line: 922 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
@@ -939,8 +936,8 @@ exports.init = function(cli) {
result = sites;
log.json("verbose", sites);
- return cacheUtils.saveSites(options, result, __cb(_, __frame, 31, 6, function __$site_doSitesGet__15() {
- return _(null, sites); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$site_doSitesGet__15() {
+ return cacheUtils.saveSites(options, result, __cb(_, __frame, 31, 6, function __$site_doSitesGet__16() {
+ return _(null, sites); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$site_doSitesGet__16() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }, true)); }); };
@@ -999,7 +996,7 @@ exports.init = function(cli) {
- site.doSiteConfigPUT = function site_doSiteConfigPUT__16(config, options, _) { var progress, xmlConfig; var __frame = { name: "site_doSiteConfigPUT__16", line: 1002 }; return __func(_, this, arguments, site_doSiteConfigPUT__16, 2, __frame, function __$site_doSiteConfigPUT__16() {
+ site.doSiteConfigPUT = function site_doSiteConfigPUT__17(config, options, _) { var progress, xmlConfig; var __frame = { name: "site_doSiteConfigPUT__17", line: 999 }; return __func(_, this, arguments, site_doSiteConfigPUT__17, 2, __frame, function __$site_doSiteConfigPUT__17() {
progress = cli.progress("Updating site config information");
if (!config.SiteConfig) {
@@ -1021,13 +1018,13 @@ exports.init = function(cli) {
- site.doRepositoryGet = function site_doRepositoryGet__17(options, _) { var siteData; var __frame = { name: "site_doRepositoryGet__17", line: 1024 }; return __func(_, this, arguments, site_doRepositoryGet__17, 1, __frame, function __$site_doRepositoryGet__17() {
+ site.doRepositoryGet = function site_doRepositoryGet__18(options, _) { var siteData; var __frame = { name: "site_doRepositoryGet__18", line: 1021 }; return __func(_, this, arguments, site_doRepositoryGet__18, 1, __frame, function __$site_doRepositoryGet__18() {
return site.doSiteGet(options, __cb(_, __frame, 1, 19, function ___(__0, __1) { siteData = __1;
return _(null, getRepositoryUri(siteData)); }, true)); }); };
- site.doPublishingUsersGet = function site_doPublishingUsersGet__18(options, _) { var progress, publishingUsers; var __frame = { name: "site_doPublishingUsersGet__18", line: 1029 }; return __func(_, this, arguments, site_doPublishingUsersGet__18, 1, __frame, function __$site_doPublishingUsersGet__18() {
- progress = cli.progress("Retrieving user information"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doPublishingUsersGet__18() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doPublishingUsersGet__18() {
+ site.doPublishingUsersGet = function site_doPublishingUsersGet__19(options, _) { var progress, publishingUsers; var __frame = { name: "site_doPublishingUsersGet__19", line: 1026 }; return __func(_, this, arguments, site_doPublishingUsersGet__19, 1, __frame, function __$site_doPublishingUsersGet__19() {
+ progress = cli.progress("Retrieving user information"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doPublishingUsersGet__19() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doPublishingUsersGet__19() {
@@ -1039,10 +1036,10 @@ exports.init = function(cli) {
return getChannel().path(options.subscription).path("services").path("webspaces").path("").query("properties", "publishingUsers").GET(__cb(_, __frame, 10, 36, function ___(__0, __1) { publishingUsers = clean(__1);
log.verbose("PublishingUsers", publishingUsers);
- return _(null, publishingUsers); }, true)); }); })(function ___(e, __result) { __tryCatch(_, function __$site_doPublishingUsersGet__18() { if (e) {
+ return _(null, publishingUsers); }, true)); }); })(function ___(e, __result) { __tryCatch(_, function __$site_doPublishingUsersGet__19() { if (e) {
- return _(null, ["","",]); } else { _(null, __result); } ; }); }); })(function ___() { __tryCatch(_, function __$site_doPublishingUsersGet__18() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$site_doPublishingUsersGet__18() {
+ return _(null, ["","",]); } else { _(null, __result); } ; }); }); })(function ___() { __tryCatch(_, function __$site_doPublishingUsersGet__19() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$site_doPublishingUsersGet__19() {
121 lib/cli/commands/site_.js
View
@@ -675,37 +675,7 @@ exports.init = function (cli) {
log.info('Starting site', context.site.name);
- var progress = cli.progress('Updating site state');
- try {
- var result = getChannel()
- .path(context.subscription)
- .path('services')
- .path('webspaces')
- .path(context.site.webspace)
- .path('sites')
- .path(context.site.name)
- .header('Content-Type', 'application/xml')
- .PUT(function (req) {
- req.write('<Site xmlns="http://schemas.microsoft.com/windowsazure">');
- req.write('<HostNames>');
- req.write('<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">');
- req.write(context.site.name + utils.getHostNameSuffix());
- req.write('</string>');
- req.write('</HostNames>');
- req.write('<Name>');
- req.write(context.site.name);
- req.write('</Name>');
- req.write('<State>');
- req.write('Running');
- req.write('</State>');
- req.write('</Site>');
-
- req.end();
- }, _);
- }
- finally {
- progress.end();
- }
+ updateSiteState(getChannel(), context, 'Running', _);
log.info('Site ' + context.site.name + ' has been started');
});
@@ -726,41 +696,68 @@ exports.init = function (cli) {
log.info('Stopping site', context.site.name);
- var progress = cli.progress('Updating site state');
- try {
- var result = getChannel()
- .path(context.subscription)
- .path('services')
- .path('webspaces')
- .path(context.site.webspace)
- .path('sites')
- .path(context.site.name)
- .header('Content-Type', 'application/xml')
- .PUT(function (req) {
- req.write('<Site xmlns="http://schemas.microsoft.com/windowsazure">');
- req.write('<HostNames>');
- req.write('<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">');
- req.write(context.site.name + utils.getHostNameSuffix());
- req.write('</string>');
- req.write('</HostNames>');
- req.write('<Name>');
- req.write(context.site.name);
- req.write('</Name>');
- req.write('<State>');
- req.write('Stopped');
- req.write('</State>');
- req.write('</Site>');
-
- req.end();
- }, _);
- }
- finally {
- progress.end();
- }
+ updateSiteState(getChannel(), context, 'Stopped', _);
log.info('Site ' + context.site.name + ' has been stopped');
});
+ site.command('restart [name]')
+ .whiteListPowershell()
+ .description('Stop and then start a web site')
+ .option('-s, --subscription <id>', 'use the subscription id')
+ .execute(function (name, options, _) {
+ var context = {
+ subscription: cli.category('account').lookupSubscriptionId(options.subscription),
+ site: {
+ name: name
+ }
+ };
+
+ lookupSiteNameAndWebSpace(context, _);
+
+ log.info('Stopping site', context.site.name);
+ updateSiteState(getChannel(), context, 'Stopped', _);
+
+ log.info('Site ' + context.site.name + ' has been stopped, restarting');
+ updateSiteState(getChannel(), context, 'Running', _);
+ log.info('Site ' + context.site.name + ' has been restarted');
+ });
+
+ function updateSiteState(channel, context, newState, _)
+ {
+ var progress = cli.progress('Updating site state');
+ try {
+ var result = channel
+ .path(context.subscription)
+ .path('services')
+ .path('webspaces')
+ .path(context.site.webspace)
+ .path('sites')
+ .path(context.site.name)
+ .header('Content-Type', 'application/xml')
+ .PUT(function (req) {
+ req.write('<Site xmlns="http://schemas.microsoft.com/windowsazure">');
+ req.write('<HostNames>');
+ req.write('<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">');
+ req.write(context.site.name + utils.getHostNameSuffix());
+ req.write('</string>');
+ req.write('</HostNames>');
+ req.write('<Name>');
+ req.write(context.site.name);
+ req.write('</Name>');
+ req.write('<State>');
+ req.write(newState);
+ req.write('</State>');
+ req.write('</Site>');
+
+ req.end();
+ }, _);
+ }
+ finally {
+ progress.end();
+ }
+ }
+
/////////////////
// config and settings
80 test/cli/commands/cli.site-tests.js
View
@@ -15,8 +15,9 @@
var should = require('should');
var url = require('url');
+var uuid = require('node-uuid');
var GitHubApi = require('github');
-
+var util = require('util');
var cli = require('../cli');
var capture = require('../util').capture;
var LinkedRevisionControlClient = require('../../../lib/cli/linkedrevisioncontrol').LinkedRevisionControlClient;
@@ -65,11 +66,11 @@ suite('cli', function(){
});
test('site create', function(done) {
- var siteName = 'cliuttestsite1';
+ var siteName = 'cliuttestsite1' + uuid();
// Create site
var cmd = ('node cli.js site create ' + siteName + ' --json --location').split(' ');
- cmd.push('East US');
+ cmd.push('West US');
capture(function() {
cli.parse(cmd);
@@ -119,11 +120,11 @@ suite('cli', function(){
});
test('site create github', function(done) {
- var siteName = 'cliuttestsite2';
+ var siteName = 'cliuttestsite2b' + uuid();
// Create site
var cmd = ('node cli.js site create ' + siteName + ' --github --json --location').split(' ');
- cmd.push('East US');
+ cmd.push('West US');
cmd.push('--githubusername');
cmd.push(githubUsername);
cmd.push('--githubpassword');
@@ -196,11 +197,11 @@ suite('cli', function(){
});
test('site create github rerun scenario', function(done) {
- var siteName = 'cliuttestsite3';
+ var siteName = 'cliuttestsite3' + uuid();
// Create site
var cmd = ('node cli.js site create ' + siteName + ' --json --location').split(' ');
- cmd.push('East US');
+ cmd.push('West US');
capture(function() {
cli.parse(cmd);
@@ -268,7 +269,7 @@ suite('cli', function(){
siteList = JSON.parse(result.text);
siteExists = siteList.some(function (site) {
- return site.Name.toLowerCase() === siteName.toLowerCase()
+ return site.Name.toLowerCase() === siteName.toLowerCase();
});
siteExists.should.not.be.ok;
@@ -282,5 +283,66 @@ suite('cli', function(){
});
});
});
+
+ test('site restart running site', function (done) {
+ var siteName = 'cliuttestsite4' + uuid();
+
+ // Create site for testing
+ var cmd = util.format('node cli.js site create %s --json --location', siteName).split(' ');
+ cmd.push('West US');
+ capture(function () {
+ cli.parse(cmd);
+ }, function (result) {
+
+ // Restart site, it's created running
+ cmd = util.format('node cli.js site restart %s', siteName).split(' ');
+ capture(function () {
+ cli.parse(cmd);
+ }, function (result) {
+
+ // Delete test site
+
+ cmd = util.format('node cli.js site delete %s', siteName).split(' ');
+ capture(function () {
+ cli.parse(cmd);
+ }, function (result) {
+ done();
+ });
+ });
+ });
+ });
+
+ test('site restart stopped site', function (done) {
+ var siteName = 'cliuttestsite4' + uuid();
+
+ // Create site for testing
+ var cmd = util.format('node cli.js site create %s --json --location', siteName).split(' ');
+ cmd.push('West US');
+ capture(function () {
+ cli.parse(cmd);
+ }, function (result) {
+ // Stop the site
+ cmd = util.format('node cli.js site stop %s', siteName).split(' ');
+ capture(function () {
+ cli.parse(cmd);
+ }, function () {
+ // Restart site
+ cmd = util.format('node cli.js site restart %s', siteName).split(' ');
+ capture(function () {
+ cli.parse(cmd);
+ }, function (result) {
+
+ // Delete test site
+
+ cmd = util.format('node cli.js site delete %s', siteName).split(' ');
+ capture(function () {
+ cli.parse(cmd);
+ }, function (result) {
+ done();
+ });
+ });
+ });
+ });
+ });
});
-});
+});
Please sign in to comment.
Something went wrong with that request. Please try again.