Skip to content

Instantly share code, notes, and snippets.

@Cyreex
Last active March 7, 2017 14:43
Show Gist options
  • Save Cyreex/f9af89a04374b198d2155ba114dc0c54 to your computer and use it in GitHub Desktop.
Save Cyreex/f9af89a04374b198d2155ba114dc0c54 to your computer and use it in GitHub Desktop.
var promise, requestPromise,
i,
networks = [],
deferred = $.Deferred(), vmNet;
var virtualNetworks = data.vmNetworks;
var networkId = data.network;
if (networkId && virtualNetworks && virtualNetworks.length > 0) {
for (i = 0; i < virtualNetworks.length; i++) {
if (virtualNetworks[i].id === networkId) {
vmNet = virtualNetworks[i];
break;
}
}
}
networks.push(vmNet.name);
promise = ajax.createVMInstanceFromTemplate({
subscriptionId: data.subscriptionId,
templateId: data.templateId,
osType: data.osType,
name: data.name,
adminAccount: data.userName,
password: data.password,
productKey: data.productKey,
sshKey: data.sshKey,
networks: networks,
shielded: data.shielded,
vmShieldingDataId: data.vmShieldingDataId
});
promise
.done(function(result) {
global.VMExtension.Utilities.addVMPlaceholder(result.virtualMachine);
deferred.resolve(result);
})
.fail(function(result) {
deferred.reject(result);
});
return deferred.promise();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment