Created
October 17, 2013 14:12
-
-
Save underscorephil/7025628 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace SLAPI_TEST | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
String username = ""; | |
String apiKey = ""; | |
authenticate authenticate = new authenticate(); | |
authenticate.username = username; | |
authenticate.apiKey = apiKey; | |
SoftLayer_Virtual_GuestService guestService = new SoftLayer_Virtual_GuestService(); | |
guestService.authenticateValue = authenticate; | |
Console.WriteLine("How many instances to create?"); | |
int numInstances = Convert.ToInt32(Console.ReadLine()); | |
Console.WriteLine("What is the base hostname of the instances?"); | |
string baseHostName = Console.ReadLine(); | |
Console.WriteLine("What is the image template name?"); | |
string imageName = Console.ReadLine(); | |
SoftLayer_AccountService accountService = new SoftLayer_AccountService(); | |
accountService.authenticateValue = authenticate; | |
string objectMask = "mask[name, id, globalIdentifier]"; | |
SoftLayer_ObjectMask maskContainer = new SoftLayer_ObjectMask(); | |
maskContainer.mask = objectMask; | |
SoftLayer_Virtual_Guest_Block_Device_Template_Group[] images = accountService.getBlockDeviceTemplateGroups(); | |
string GUID = ""; | |
foreach (SoftLayer_Virtual_Guest_Block_Device_Template_Group image in images) | |
{ | |
if (image.name == imageName) | |
{ | |
GUID = image.globalIdentifier; | |
break; | |
} | |
else | |
{ | |
continue; | |
} | |
} | |
Console.WriteLine("Creating " + numInstances + " Instances with hostname " + baseHostName); | |
int i = 0; | |
while (i < numInstances) | |
{ | |
SoftLayer_Virtual_Guest newGuest = new SoftLayer_Virtual_Guest(); | |
newGuest.hostname = baseHostName + (i + 1); | |
newGuest.domain = "example.com"; | |
newGuest.startCpus = 1; | |
newGuest.maxMemory = 2048; | |
newGuest.hourlyBillingFlag = true; | |
newGuest.localDiskFlag = false; | |
newGuest.blockDeviceTemplateGroup = new SoftLayer_Virtual_Guest_Block_Device_Template_Group(); | |
newGuest.blockDeviceTemplateGroup.globalIdentifier = GUID; | |
newGuest.startCpusSpecified = true; | |
newGuest.maxMemorySpecified = true; | |
newGuest.hourlyBillingFlagSpecified = true; | |
newGuest.localDiskFlagSpecified = true; | |
SoftLayer_Virtual_Guest orderedGuest = guestService.createObject(newGuest); | |
Console.WriteLine("Cloud Computing Insance Created with ID: " + orderedGuest.id); | |
i++; | |
} | |
Console.WriteLine("Instances ordered. Press return to close"); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment