UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

423 lines (169 loc) 19.9 kB
/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ "use strict"; var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; var profile = require("../../../util/profile"); var utils = require("../../../util/utils"); var dtlUtils = require("./devTestLabs.utils"); var $ = utils.getLocaleString; exports.init = function(cli) { var labCommands = cli.category("lab").description($("Commands to manage your DevTest Labs")); var vmsPerLabPolicyCommands = labCommands.category("vms-per-lab-policy").description($("Commands to manage total allowed virtual machines per lab policy")); vmsPerLabPolicyCommands.command("set").description($("Set max allowed virtual machines per lab policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-c, --vm-count <vm-count>", $("the total vms allowed in the lab")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __1(options, _) { var subscription, client, policy, result; var __frame = { name: "__1", line: 24 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; if (!options.vmCount) { return _(null, cli.missingArgument("vm-count")); } ; policy = { status: dtlUtils.policyConstants.policyStatus.enabled, factName: dtlUtils.policyConstants.factNames.labVmCount, threshold: options.vmCount.toString(), evaluatorType: dtlUtils.policyConstants.evaluators.maxValuePolicy }; return client.policyOperations.createOrUpdateResource(options.resourceGroup, options.labName, dtlUtils.policyConstants.defaultPolicySetName, dtlUtils.policyConstants.policyNames.maxVmsAllowedPerLab, policy, __cb(_, __frame, 19, 41, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); vmsPerLabPolicyCommands.command("show").description($("Get allowed virtual machines per lab policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __2(options, _) { var subscription, client, result; var __frame = { name: "__2", line: 56 }; return __func(_, this, arguments, __2, 1, __frame, function __$__2() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; return client.policyOperations.getResource(options.resourceGroup, options.labName, dtlUtils.policyConstants.defaultPolicySetName, dtlUtils.policyConstants.policyNames.maxVmsAllowedPerLab, __cb(_, __frame, 9, 41, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); vmsPerLabPolicyCommands.command("delete").description($("Delete allowed virtual machines per lab policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __3(options, _) { var subscription, client, result; var __frame = { name: "__3", line: 78 }; return __func(_, this, arguments, __3, 1, __frame, function __$__3() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; return client.policyOperations.deleteResource(options.resourceGroup, options.labName, dtlUtils.policyConstants.defaultPolicySetName, dtlUtils.policyConstants.policyNames.maxVmsAllowedPerLab, __cb(_, __frame, 9, 41, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); var vmsPerUserPolicyCommands = labCommands.category("vms-per-user-policy").description($("Commands to manage max allowed virtual machines per user policy")); vmsPerUserPolicyCommands.command("set").description($("Set allowed virtual machines per user policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-c, --vm-count <vm-count>", $("the total vms allowed in the lab")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __4(options, _) { var subscription, client, policy, result; var __frame = { name: "__4", line: 104 }; return __func(_, this, arguments, __4, 1, __frame, function __$__4() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; if (!options.vmCount) { return _(null, cli.missingArgument("vm-count")); } ; policy = { status: dtlUtils.policyConstants.policyStatus.enabled, factName: dtlUtils.policyConstants.factNames.labVmCount, threshold: options.vmCount.toString(), evaluatorType: dtlUtils.policyConstants.evaluators.maxValuePolicy }; return client.policyOperations.createOrUpdateResource(options.resourceGroup, options.labName, dtlUtils.policyConstants.defaultPolicySetName, dtlUtils.policyConstants.policyNames.maxVmsAllowedPerUser, policy, __cb(_, __frame, 19, 41, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); vmsPerUserPolicyCommands.command("show").description($("Get allowed virtual machines per user policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __5(options, _) { var subscription, client, result; var __frame = { name: "__5", line: 136 }; return __func(_, this, arguments, __5, 1, __frame, function __$__5() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; return client.policyOperations.getResource(options.resourceGroup, options.labName, dtlUtils.policyConstants.defaultPolicySetName, dtlUtils.policyConstants.policyNames.maxVmsAllowedPerUser, __cb(_, __frame, 9, 41, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); vmsPerUserPolicyCommands.command("delete").description($("Delete allowed virtual machines per user policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __6(options, _) { var subscription, client, result; var __frame = { name: "__6", line: 158 }; return __func(_, this, arguments, __6, 1, __frame, function __$__6() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; return client.policyOperations.deleteResource(options.resourceGroup, options.labName, dtlUtils.policyConstants.defaultPolicySetName, dtlUtils.policyConstants.policyNames.maxVmsAllowedPerUser, __cb(_, __frame, 9, 41, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); var vmSizePolicyCommands = labCommands.category("vm-size-policy").description($("Commands to manage allowed virtual machine sizes policy")); vmSizePolicyCommands.command("set").description($("Set allowed virtual machine sizes policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-z, --vm-sizes <vm-sizes>", $("allowed virtual machine sizes, example value: Standard_A0,StandardA1")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __7(options, _) { var subscription, client, policy, result; var __frame = { name: "__7", line: 185 }; return __func(_, this, arguments, __7, 1, __frame, function __$__7() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; if (!options.vmSizes) { return _(null, cli.missingArgument("vm-sizes")); } ; policy = { status: dtlUtils.policyConstants.policyStatus.enabled, factName: dtlUtils.policyConstants.factNames.labVmSize, threshold: JSON.stringify(options.vmSizes.split(",")), evaluatorType: dtlUtils.policyConstants.evaluators.allowedValuesPolicy }; return client.policyOperations.createOrUpdateResource(options.resourceGroup, options.labName, dtlUtils.policyConstants.defaultPolicySetName, dtlUtils.policyConstants.policyNames.allowedVmSizesInLab, policy, __cb(_, __frame, 19, 41, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); vmSizePolicyCommands.command("show").description($("Get allowed virtual machine sizes policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __8(options, _) { var subscription, client, result; var __frame = { name: "__8", line: 217 }; return __func(_, this, arguments, __8, 1, __frame, function __$__8() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; return client.policyOperations.getResource(options.resourceGroup, options.labName, dtlUtils.policyConstants.defaultPolicySetName, dtlUtils.policyConstants.policyNames.allowedVmSizesInLab, __cb(_, __frame, 9, 41, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); vmSizePolicyCommands.command("delete").description($("Delete allowed virtual machine sizes policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __9(options, _) { var subscription, client, result; var __frame = { name: "__9", line: 239 }; return __func(_, this, arguments, __9, 1, __frame, function __$__9() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; return client.policyOperations.deleteResource(options.resourceGroup, options.labName, dtlUtils.policyConstants.defaultPolicySetName, dtlUtils.policyConstants.policyNames.allowedVmSizesInLab, __cb(_, __frame, 9, 41, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); var autoShutdownPolicyCommands = labCommands.category("auto-shutdown-policy").description($("Commands to manage auto-shutdown policy")); autoShutdownPolicyCommands.command("set").description($("Set virtual machine daily auto-shutdown policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-t, --time <time>", $("the time (in UTC) to shutdown virtual machines everyday, example: 1905 means 7:05pm")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __10(options, _) { var subscription, client, schedule, result; var __frame = { name: "__10", line: 266 }; return __func(_, this, arguments, __10, 1, __frame, function __$__10() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; if (!options.time) { return _(null, cli.missingArgument("time")); } ; schedule = { status: dtlUtils.scheduleConstants.scheduleStatus.enabled, taskType: dtlUtils.scheduleConstants.taskTypes.labVmsShutdownTask, timeZoneId: "UTC" }; schedule.dailyRecurrence = { time: options.time }; return client.scheduleOperations.createOrUpdateResource(options.resourceGroup, options.labName, dtlUtils.scheduleConstants.scheduleNames.labVmsShutdown, schedule, __cb(_, __frame, 22, 43, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); autoShutdownPolicyCommands.command("show").description($("Get virtual machine auto-shutdown policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __11(options, _) { var subscription, client, result; var __frame = { name: "__11", line: 301 }; return __func(_, this, arguments, __11, 1, __frame, function __$__11() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; return client.scheduleOperations.getResource(options.resourceGroup, options.labName, dtlUtils.scheduleConstants.scheduleNames.labVmsShutdown, __cb(_, __frame, 9, 43, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); autoShutdownPolicyCommands.command("delete").description($("Delete virtual machine auto-shutdown policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __12(options, _) { var subscription, client, result; var __frame = { name: "__12", line: 323 }; return __func(_, this, arguments, __12, 1, __frame, function __$__12() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; return client.scheduleOperations.deleteResource(options.resourceGroup, options.labName, dtlUtils.scheduleConstants.scheduleNames.labVmsShutdown, __cb(_, __frame, 9, 43, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); var autoStartPolicyCommands = labCommands.category("auto-start-policy").description($("Commands to manage auto-start policy")); autoStartPolicyCommands.command("set").description($("Set virtual machine auto-start policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-w, --weekly <weekly>.", $("selected weekdays to start machines. example: Monday,Friday means start machines on Monday and Friday.")).option("-t, --time <time>", $("the time (in UTC) to start virtual machines on the selected weekday, example: 0815 means 8:15am")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __13(options, _) { var subscription, client, schedule, result; var __frame = { name: "__13", line: 351 }; return __func(_, this, arguments, __13, 1, __frame, function __$__13() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; if (!options.time) { return _(null, cli.missingArgument("time")); } ; schedule = { status: dtlUtils.scheduleConstants.scheduleStatus.enabled, taskType: dtlUtils.scheduleConstants.taskTypes.labVmsStartupTask, timeZoneId: "UTC" }; schedule.weeklyRecurrence = { weekdays: options.weekly.split(","), time: options.time }; return client.scheduleOperations.createOrUpdateResource(options.resourceGroup, options.labName, dtlUtils.scheduleConstants.scheduleNames.labVmsAutoStart, schedule, __cb(_, __frame, 23, 43, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); autoStartPolicyCommands.command("show").description($("Get virtual machine auto-start policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __14(options, _) { var subscription, client, result; var __frame = { name: "__14", line: 387 }; return __func(_, this, arguments, __14, 1, __frame, function __$__14() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; return client.scheduleOperations.getResource(options.resourceGroup, options.labName, dtlUtils.scheduleConstants.scheduleNames.labVmsAutoStart, __cb(_, __frame, 9, 43, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); }); autoStartPolicyCommands.command("delete").description($("Delete virtual machine auto-start policy.")).option("-g, --resource-group <resource-group>", $("the resource group name of the lab")).option("-l, --lab-name <lab-name>", $("the lab name")).option("-s, --subscription <id>", $("the subscription identifier")).execute(function __15(options, _) { var subscription, client, result; var __frame = { name: "__15", line: 409 }; return __func(_, this, arguments, __15, 1, __frame, function __$__15() { subscription = profile.current.getSubscription(options.subscription); client = utils.createDevTestLabsClient(subscription); if (!options.labName) { return _(null, cli.missingArgument("lab-name")); } ; return client.scheduleOperations.deleteResource(options.resourceGroup, options.labName, dtlUtils.scheduleConstants.scheduleNames.labVmsAutoStart, __cb(_, __frame, 9, 43, function ___(__0, __1) { result = __1; if (result) { cli.output.json(result); } ; _(); }, true)); }); });};