Entity's Tech Blog

Azure Import & Export script for Servicedesks

by on Feb.07, 2013, under Azure, Ideas, Problems, Scripting, Solutions

A small introduction:

The company I work for has a few Microsoft Azure test-cases which are ongoing and to cut down on costs for the development / internal environment a few things where needed:

  • The ability to “shut down” machines overnight to save on billing
  • The ability to “start up” machines in the morning without too much hassle.

Off course, the easy solution is to write a small script, perhaps hard-coded which can just import / export the needed Virtual Machines by the press of a button.
I wrote a script for them that would do just that but it basically took all of 5 minutes to do, cost little to no effort and did the trick.

The problem with this (as you might have guessed by now) is that by hard-coding everything into the script itself you are basically forced to do changes to the code of the script every time a new machine gets provisioned or decommissioned  This was a big “no-go” as in the long run the company I’m working for has plans to offer Azure hosting & storage for their machines / environments, such as Sharepoint or alike, as a part of the maintenance contracts.

Doing this all manually meant just too much work to maintain and not efficient at all.So, I decided to help the people of Servicedesk and write a fully fledged, automated script that could easily be scheduled to run at for instance 8PM in the evening and take down the Virtual Machines and run at 6AM to bring them back up, ready for another hard day’s work.

With the introduction out of the way, I won’t bore you all too much with the nitty-gritty. If you want to look at the code by all means hack away at it and improve on it if you wish, if you have questions feel free to post’m here.I put the comments in such a way that I hope it’s human-readable by all, from the System Engineer to the student.

The download can be had here:

Download

 

A little explanation:

Enclosed in the ZIP file you’ll find 2 scripts:

  • 1x “Dusk.ps1”
  • 1x “Dawn.ps1”
  • “a” folder structure

“Dusk” is the exporter, which can be scheduled so all VM’s defined in the \toExport\toExport.txt file are saved to XML (in the \xmlFiles\ folder) and de-provisioned on Azure
“Dawn” is the importer which will return the  the VM’s to working order.

 

  • \ini\                                   

  This folder can be ignored, this is a working folder for the script itself

  • \PublishFiles\                 

 .publishsettings files are stored here

  • \toExport\                        

 Here the VM’s which are to be exported/Imported are defined in the “toExport.txt file

  • \xmlFiles\                          

A working folder of the script, here the exported configuration XML’s of the VM’s are stored

 

What is important?

In \PublishFiles the .publishsettings files have to be placed. These have to then be defined in the publishfiles.ini file in the root folder in the following way:

SequenceNumber;fullPublishSettingsFileName

Example:

2;entity_azure.publishsettings

BEWARE: the “;” separator is important, if this isn’t present or another character is used the publishSettings file WILL NOT be accepted / Known inside the script

In \toExport\toExport.txt It is important that the VM’s are defined conform the definition of the .publishSettings files

meaning:

1;TestEntity2
2;TestEntity1

The Script averages about 30 seconds per machine to export and 60 to 90 seconds for importing (this because of a generous sleep-timer inside the script to allow for smooth operation & trouble free execution). This means that the more machines we start exporting/importing, the longer it’ll take for the script to complete.

This is quite simple to negate by using a 2nd instance of the script.

 

Hope it can be of use to some of you out there !

 

Regards,

Entity

Leave a Comment :, , , , , , , more...

Azure Provisioning through Powershell Scripting – Part 2a

by on Nov.12, 2012, under Azure, Scripting, Solutions

Link to Part 1:
http://blog.entity-project.eu/?p=57

Prologue:
Because Part 2 turned into a gargantuan spaghetti of lines and code I’ve decided to split it up into 2 sections, Part 2a and Part 2b, to keep it easy on the eyes and doable to read / execute.
Part 2b will be released after the weekend.

Welcome to Part 2 of the Azure Provisioning Blog series.

In part 1 our script ended up being capable of:

  • Provisioning Azure VM’s
  • “some” form of automation built in

Our “ToDo” list for this installment is:

  • Create automations for the basics such as Storage Accounts
  • Create a way to input INI or lets call them “build” files so that the script has zero input necessary and can, if needed accept input from a third party (application)
  • OPTIONAL: Create some form of logging

In the end we should have a script that once started will build all VM’s to specification as provided in BUILD Files, is clever enough to create storage accounts if and when needed and do all initial prep and config work on its own.

“Before we begin,

As you know from Part 1, my love for all things “cloud” stops at the incessant use of the word itself  I have nothing with off shoring / outsourcing / hosted solutions / virtualization and whatever else these days gets bundled up under the “cloud” name. I do however have an issue with, as stated in part 1, carpet bombing every issue / technical challenge with the “cloud!” word and praying to the kernel gods that all your infrastructure issues and challenges will magically resolve itself.

I received a bit of flack from inside my professional environment stating that “cloud is the future” and basically that I should “Get with the program”. Now, I thought my views and opinions were quite clear but, apparently not so I’ll rehash them again and explain.

In and off itself I do not have any issue with using the term Cloud. The condition for this is if you use it in context and doesn’t use it just to sound “groovy”.

For me Cloud is a solution you rent / buy or provide which is transparent for end users and in some way for yourself, is thoroughly automated and has some form of charge-back.  Slapping together a bunch of servers, a hyper-visor and the likes of Nagios, SCOM or the likes does not a cloud solution make.
Far too many companies are patting themselves on the back for having a “private cloud”, when in reality they just renamed their virtualization solution to sound hip. On-Demand creation of Virtual Machines, Charge-back (even if just to make a point “look you are costing us this much by wanting these specs”), self-service portal, automated monitoring & provisioning (of both VM as-well as software) are just a few of the things that make what for me can be called a cloud solution. 

I hope this settles the debate on what I consider to be “cloud” and hopefully people reading this will use the term Cloud less liberally. Used too often and too liberal, the power and meaning of a word, a concept, an idea will go to waste, and this should not happen if we as IT Professionals hope to change the way we think, work and do. “

 

Now that is over, let’s get down to the nitty-gritty shall?
We will start off with what I consider easiest and making most sense, using BUILD files (.INI) to automate the creating and deployment further.

Essentially what we wish to become in terms of flow is the following:

read INI files
for each INI file create Virtual Machine

Seems stupendously logical and that is because, it is! No need to over complicate things. Read files –> do “stuff” –> profit all the while leaning back in your chair and waiting for the script to do your work for you.

So how does this look ? (partially done)

#Get Root Dir from where script runs
$localDir =  Split-Path $script:MyInvocation.MyCommand.Path
#Get Build files, located in 'rootdir\vms\'
$buildList = Get-ChildItem ($Localdir + '\vms\')
#For every buildfile we have, make a config
foreach ($buildfile in $buildList) {
	#Read the build file
	$buildContent = Get-Content $buildfile
	#Declare variables we will need / support at this time
	$vmname = ''
	$cloudSvcName = ''
	$adminPassword=''
	$image=''
	$Size= ''
	[array]$disklabel
	[array]$diskSize
	[array]$LunCounter

	#Create the actual Config
	#To Be Written Later
	}

So, I’ve started off with showing you this first, reason being is that you might notice something “peculiar”. All variables are just that, single purpose variables, strings even, except anything that has to do with the extra disk’s. Reason for this is because when I wrote this I ran into the issue where I questioned myself on how many data-disk’s I should support? The easy answer would have been “One”, easy to justify and just make the argument that “the script is specifically written like this to standardize the automation, any particulars you want will have to be manually added, the addition of a multitude of data-disk’s is one of those

Now, I’m all for being lazy when it comes to work … Heck most of my scripts are born because I can’t be bothered doing xx amount of clicks.

What’s that? Do manual labor?! To hell with that, SCRIPT IT!

In most cases being lazy is the right approach but either I make an effort now and make the script such that it is truly generic in the way it handles input and have it support “unlimited” data-disk  or I don’t and I end up having to do a load of click-work in the future because some people want 20x 5Gb disks or some such.

So, to make the Data-disks not limited in how many you can use, we use Array’s. Pretty simple and logical approach no? How we’ll handle this will come later in this post. For now, let’s get reading & filling variables:

On to filling up all variables!

	foreach ($line in $buildContent){
			switch -wildcard ($line) 
    		{ 
		        "vmName*" {
					[array]$Catline=$line.split(";")
					$vmname=$Catline[1]
				} 

		        "dcLocation*" {
					[array]$Catline=$line.split(";")
					$dclocation=$Catline[1]
				} 

			    "cloudSrvName*" {
					[array]$Catline=$line.split(";")
					$cloudSvcName=$Catline[1]
				}

		        "adminPassword*" {
					[array]$Catline=$line.split(";")
					$adminPassword=$Catline[1]
				}

		        "imageUsed*" {
					[array]$Catline=$line.split(";")
					$image=$Catline[1]
				} 

			   "vmSize*" {
					[array]$Catline=$line.split(";")
					$Size=$Catline[1]
				} 

				"dataDiskLabel*" {
					[array]$Catline=$line.split(";")
					[array]$disklabel +=$Catline[1]
				}

				"dataDiskSize*" {
					[array]$Catline=$line.split(";")
					[array]$diskSize +=$Catline[1]
				}

				"dataDiskLun*" {
					[array]$Catline=$line.split(";")
					[array]$Lun+=$Catline[1]
				}

				"dcLocation*" {
					[array]$Catline=$line.split(";")
					$dclocation=$Catline[1]
				}
		    }
	}

As some may, or may not, know, the SWITCH statement is the Case Select / Select Case as we know it in VB.net (or as I learned it in Uni) so instead of using IF loops like I had in the past, this looked a bit nicer and better.
The -wildcard parameter signals that we’ll be using a wildcard (in this case the * sign).

The script will now search (for instance) for each line whether it starts with ‘vmName’. If it does, the code associated with it will be run and processed.

After this came creating the vm Config:

#Create the actual Config
	$vm=New-AzureVMConfig -Name $vmname -InstanceSize $Size -ImageName $image | Add-AzureProvisioningConfig -Windows -Password $adminPassword 

	$counter = 0
	foreach ($disk in $disklabel){
	$vm = $vm | Add-AzureDataDisk -CreateNew -DiskSizeInGB $diskSize[$counter] -DiskLabel $disk -LUN $Lun[$counter]
	$counter+=1
	}

Ok so, what did we do here? Quit simple, I created a new AzureVMConfig, assigned it to the $vm parameter and then “the magic” began, … with magic I mean I created another loop.

This time it’s quite simple, for every $disk (ie: disklabel) we have in the diskLabel Array we will add a AzureDataDisk. Simply put, and as you can see, we add the $vm parameter with the pipeline to add a new disk. The counter we declared at the beginning is used simply to signal to the $diskSize and $Lun Array which parameter they need to use.

Now that we are done we can start implementing all of this code into the “old” codebase (read: the old semi-automated script from part 1). When we do that, this is what we become:

#Windows Azure Scripting Test Environment
#Import Azure Mods, NEED TO BE INSTALLED
Import-Module 'C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1'
#Import PublishSettings File 
Import-AzurePublishSettingsFile 'F:\GoogleDrive\Google Drive\Project Azure\azure-ms.publishsettings'

#Default DC Location is 'North Europe' specific one can be defined in BUILD file
$defaultdclocation = 'North Europe'

Set-AzureSubscription -SubscriptionName 'SubScriptionName' -CurrentStorageAccount 'portalvhdxxxxxxxxx'

## BEGIN IMPLEMENTATION PART 2
#Define Names
#Get Root Dir from where script runs
$localDir =  Split-Path $script:MyInvocation.MyCommand.Path
#Get Build files, located in 'rootdir\vms\'
$buildList = Get-ChildItem ($Localdir + '\vms\')
#For every buildfile we have, make a config
foreach ($buildfile in $buildList) {
	#Read the build file
	$fileToGet =  $localdir + '\vms\' + $buildfile
	$buildContent = Get-Content $fileToGet
	#Default Variables - can be set optional in the BUILD files
	$dclocation=$defaultdclocation
	#Declare variables we will need / support at this time
	$vmname = ''
	$cloudSvcName = ''
	$adminPassword=''
	$image=''
	$Size= ''
	[array]$disklabel
	[array]$diskSize
	[array]$Lun

	#read the lines of the buildfile (ie: buildcontent) and process
	foreach ($line in $buildContent){
			switch -wildcard ($line) 
    		{ 
		        "vmName*" {
					[array]$Catline=$line.split(";")
					$vmname=$Catline[1]
				} 

		        "dcLocation*" {
					[array]$Catline=$line.split(";")
					$dclocation=$Catline[1]
				} 

			    "cloudSrvName*" {
					[array]$Catline=$line.split(";")
					$cloudSvcName=$Catline[1]
				}

		        "adminPassword*" {
					[array]$Catline=$line.split(";")
					$adminPassword=$Catline[1]
				}

		        "imageUsed*" {
					[array]$Catline=$line.split(";")
					$image=$Catline[1]
				} 

			   "vmSize*" {
					[array]$Catline=$line.split(";")
					$Size=$Catline[1]
				} 

				"dataDiskLabel*" {
					[array]$Catline=$line.split(";")
					[array]$disklabel +=$Catline[1]
				}

				"dataDiskSize*" {
					[array]$Catline=$line.split(";")
					[array]$diskSize +=$Catline[1]
				}

				"dataDiskLun*" {
					[array]$Catline=$line.split(";")
					[array]$Lun+=$Catline[1]
				}

				"dcLocation*" {
					[array]$Catline=$line.split(";")
					$dclocation=$Catline[1]
				}
		    }
	}

	#Create the actual Config
	$vm=New-AzureVMConfig -Name $vmname -InstanceSize $Size -ImageName $image | Add-AzureProvisioningConfig -Windows -Password $adminPassword 

	$counter = 0
	foreach ($disk in $disklabel){
	$vm = $vm | Add-AzureDataDisk -CreateNew -DiskSizeInGB $diskSize[$counter] -DiskLabel $disk -LUN $Lun[$counter]
	$counter+=1
	}

	#Time To Create a VM
	$outcome = Test-AzureName -Service $cloudSvcName
	if ($outcome -eq $true){
	New-AzureVM -ServiceName $cloudSvcName -VMs $vm
	}elseif ($outcome -eq $false){
	New-AzureVM -location $dclocation -ServiceName $cloudSvcName -VMs $vm
	}
}

This gives us a script that is automated in such a way that it will:

  • Accept BUILD files and build VM’s
  • Is tolerant towards Cloud Service Names who don’t yet exist
  • Supports “infinite” (read: however much Azure supports) Data-disk’s

Now we can even further improve on this, but won’t yet. Right now what bothers me is that we still have hard-coded:

  • Publish Settings File
  • SubscriptionName
  • CurrentStorageAccount

We have 2 ways to resolve this, either we:

  1. Expand the build files further so that the script is truly generic
  2. Keep some things hard-coded (like the publish settings file) so that a certain script will ALWAYS deploy to a specific account (could be useful for customers so you don’t accidentally deploy to another customer’s account because of a wrong option in the BUILD file)

I don’t have any real preference on the approach; there is merit to the both of them. For now and to make it “easy” I’ll stick with expanding the BUILD files and doing it that way.

To do this we’ll need to the following:

#Variables for:
#StorageAccount
$storageAcc
#SubscriptionName
$subName
#PublishSettings file
$publishSettFile

Simply create these variables and add the SWITCH statement associated with them to the script.

"storageAccount*" {
	[array]$Catline=$line.split(";")
	$storageAccount =$Catline[1]
			}

"subScriptionName*" {
	[array]$Catline=$line.split(";")
	$subName=$Catline[1]
			}
"publishSettingsFile*" {
	[array]$Catline=$line.split(";")
	$publishSettFile=$Catline[1]
		}

BEWARE:

Create the variables INSIDE the initial for each loop so that these var’s have a lifespan for the duration of the BUILD file. If you declare them outside the foreach loop, we will run into issues at a later date when we add error handling.

An example of how our BUILD file will look like:

storageAccount; EntityBlogStorageSub
subScriptionName; EntityBlogSub
publishSettingsFile; Entity-Blogpublishsettings
vmName;Entity-Blog-vmName
dcLocation;North Europe
cloudSrvName;Entity-CloudService
adminPassword;12345
imageUsed;isoImageEntityTestImage
vmSize;ExtraLarge
dataDiskLabel;test-disk1
dataDiskSize;100
dataDiskLun;0
dataDiskLabel;test-disk2
dataDiskSize;200
dataDiskLun;1
dataDiskLabel;test-disk3
dataDiskSize;300
dataDiskLun;2

Ok, onto the final straight to finish this off ! We need to now rewrite a part of the script so that it will use what the build files give them.
We do this by moving the following lines of code:

#Import PublishSettings File 
Import-AzurePublishSettingsFile 'F:\GoogleDrive\Google Drive\Project Azure\azure-ms.publishsettings'
Set-AzureSubscription -SubscriptionName 'SubScriptionName' -CurrentStorageAccount 'portalvhdxxxxxxxxx'

before the section marked with

#Time To Create a VM

Then we re-write this so that it will use the variables previously defined like so:

#Import PublishSettings File 
	Import-AzurePublishSettingsFile $Localdir + '\publishFiles\' + $publishSettFile
	#Set Azure Subscription
	Set-AzureSubscription -SubscriptionName $subName -CurrentStorageAccount $storageAcc

This leaves us with a script that is completely generic and is completely dictated by the BUILD files on how / what / where to deploy Virtual Machines.

I’m going to end Part 2a here; as I fear I am in danger of turning Part 2a into something gargantuan and unpleasant to read otherwise.
Part 2b will be published after the weekend and will include the following to round up Part 2:

  • Create a storage account if the one given does not exist
  • See about reducing the variable count. Can’t we automate certain things? For instance the Subscription Name?
  • build in some check’s to prevent mishaps

addendum: I am well aware that most of my PowerShell scripts could be written easier, in less lines. However, as stated in part 1 my PowerShell Expertise isn’t that extensive and I’m trying to keep everything as open ended and easy to understand as can be. So I will use for example 2 lines to do something, instead of 1 just to keep everything more understandable

1 Comment :, , , , , , more...

Azure Provisioning through Powershell Scripting – Part 1

by on Nov.06, 2012, under Azure, Scripting, Solutions

Link to part 2:
http://blog.entity-project.eu/?p=79 

A small introduction is perhaps in order;

As a Virtualization consultant I often overhear people using the term “cloud” as often as they can to look “hip” and “cutting edge” and many other trending words that I myself wouldn’t touch with a 10 foot pole, so when asked to write a script so that we could mass-provision Azure machines for clients & customers that required minimal input from our end, I cringed and though “oh no … here comes the cloud-bandwagon”.

Turns out, I was right. The bandwagon rolled in and everyone on the management & sales teams hopped on and rode off into the sunset, leaving everyone in the Development and Infrastructure (me) teams grasping for dear life as we tried to explain that “cloud” solutions aren’t a one-stop-shop for all your IT needs and that you can’t carpet bomb every issue with the term “in the cloud” till it goes away.

None the less we where “forced” to put up and shut up and deliver what was asked on a time-frame that would make superman cringe and moan about not being “that fast”, as such I set to work.

 

Now that we have the introduction out of the way, and my general feeling & dismay for the generalization of the term “cloud” is known lets describe the work that had to be done and what was required to be delivered (initially).

  • A script that would deploy Azure VM’s so that DEV-teams could do their magic on it (so blank Virtual machines)
  • The script had to be self sufficient and require zero input from our end once it had been launched
  • It had to be made in such a way now, that would have an open ended input and allow for future integration with company and customer tools
  • the inevitable “we need it yesterday”

 

So how does one go about doing this I asked myself. Having limited PowerShell experience going into this, I set sail for Google and found that someone had beat me to it and had already set up a “how-to” on provisioning through script.

Michael Washam:
http://michaelwasham.com/2012/06/08/automating-windows-azure-virtual-machines-with-powershell/

Michael’s “a bit” more proficient at Azure then I am and I must say I enjoyed his website / blog a lot to get the info I needed. Props to him and give’m a look if you are interested in using Azure for “serious business”

So from this I got the “basics”, being how to connect, provision and create VM’s using PowerShell and Azure.

The result of following Michael’s guide looks something like this:

#Windows Azure Scripting Test Environment
#Import Azure Mods, NEED TO BE INSTALLED
Import-Module 'C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1'
#Import PublishSettings
File Import-AzurePublishSettingsFile 'F:\GoogleDrive\Google Drive\Project Azure\azure-ms.publishsettings'

#VARS THAT NEED POPULATING
$dclocation = 'North Europe'
$cloudSvcName = ''
$image = ''

#POSSIBLE IMAGES:

Set-AzureSubscription -SubscriptionName 'SubScriptionName' -CurrentStorageAccount 'portalvhdxxxxxxxxx'
#Advanced Creation of VM's
#Define Names
$vmname1 = 'poc-sp-app-1'
$vmname2 = 'poc-sp-app-2'
$vmname3 = 'poc-sp-sql-1'
$vmname4 = 'poc-sp-wfe-1'
$vmname5 = 'poc-sp-dc'

#define options
$cloudSvcName = 'poc-sp'
#Define 'Static' options
$adminPassword='EntityTechBlog'
$image='MSFT__Win2K8R2SP1-Datacenter-201208.01-en.us-30GB.vhd'

$vm1=New-AzureVMConfig -Name $vmname1 -InstanceSize ExtraLarge -ImageName $image | Add-AzureProvisioningConfig -Windows -Password $adminPassword | Add-AzureDataDisk -CreateNew -DiskSizeInGB 100 -DiskLabel 'poc-sp-app-1-datadisk1' -LUN 0

$vm2=New-AzureVMConfig -Name $vmname2 -InstanceSize ExtraLarge -ImageName $image | Add-AzureProvisioningConfig -Windows -Password $adminPassword | Add-AzureDataDisk -CreateNew -DiskSizeInGB 100 -DiskLabel 'poc-sp-app-2-datadisk1' -LUN 0

$vm3=New-AzureVMConfig -Name $vmname3 -InstanceSize ExtraLarge -ImageName $image | Add-AzureProvisioningConfig -Windows -Password $adminPassword | Add-AzureDataDisk -CreateNew -DiskSizeInGB 250 -DiskLabel 'poc-sp-sql-1-datadisk1' -LUN 0 

$vm4=New-AzureVMConfig -Name $vmname4 -InstanceSize ExtraLarge -ImageName $image | Add-AzureProvisioningConfig -Windows -Password $adminPassword | Add-AzureDataDisk -CreateNew -DiskSizeInGB 100 -DiskLabel 'poc-sp-wfe-1-datadisk1' -LUN 0

$vm5=New-AzureVMConfig -Name $vmname5 -InstanceSize Medium -ImageName $image | Add-AzureProvisioningConfig -Windows -Password $adminPassword | Add-AzureDataDisk -CreateNew -DiskSizeInGB 100 -DiskLabel 'poc-sp-dc-1-datadisk1' -LUN 0

New-AzureVM -ServiceName $cloudSvcName -VMs $vm1, $vm2, $vm3, $vm4, $vm5

#For first time when creating new cloud service name use this:
#New-AzureVM -location $dclocation -ServiceName $cloudSvcName -VMs $vm1, $vm2, $vm3, $vm4, $vm5

 

off course this is still very type-intensive but I ended up with what I needed really for the test, being a full SharePoint test environment with 2 APP servers, 1 DC for domain integration (test domain called test.local), 1 SQL server and 1 WFE server.

Right, so, “test succeeded” we can provision machines the “dumb” way through sharepoint. Lets start “smartening” up the script !

 

First thing that caught my eye was the last 3 lines being

New-AzureVM -ServiceName $cloudSvcName -VMs $vm1, $vm2, $vm3, $vm4, $vm5

#For first time when creating new cloud service name use this:
#New-AzureVM -location $dclocation -ServiceName $cloudSvcName -VMs $vm1, $vm2, $vm3, $vm4, $vm5

This was easy enough to change, and we ended up with the final lines looking like this:

$outcome = Test-AzureName -Service $cloudSvcName
if ($outcome -eq $true){
New-AzureVM -ServiceName $cloudSvcName -VMs $vm1, $vm2, $vm3, $vm4, $vm5
}elseif ($outcome -eq $false){
New-AzureVM -location $dclocation -ServiceName $cloudSvcName -VMs $vm1, $vm2, $vm3, $vm4, $vm5
}

What do we have at this point, and what can we do ?

  • Provision Azure VM’s without all the click-work
  • We have “some” for of automation built in to make the script a bit more “clever”
  • We have the basis on which we will build on and automate the script further.

What is our “ToDo” List for Part 2 (due to be posted next week)

  • Make the script make a storage account if none exist (I created one manually before this script)
  • Make the script so that all the param’s currently in this one, come from either a single, or multiple ini / config files which we specify.

 

Part 3, the final installment of this Thread will feature how to save costs with Azure by stopping & Saving the machines when we don’t need it, and being able to restore them when we do.
Part 3 is scheduled for the  19th of November.

 

1 Comment :, , , , , , , , , more...

Cleaning up AutoMySQL Backup’s

by on Oct.05, 2012, under Linux, Problems, Scripting, Solutions

Quick Post:

As most SysAdmin’s / People who run a server or website, I use a database (MySQL) and I take backups of the aforementioned database. For years I’ve used AutoMySqlBackup and it’s done it’s job more then admirably  However, when I first start running a VPS and my own web server I didn’t think everything through and just configured everything, set up a backup script I found on the internet and off I went.

Over the years this has changed a bit, to getting the script to send me my backups through mail, to putting the backup’s straight on my home NAS Device.

What I never changed however, is the lack of  retention policy.
As an effect of this, I’ve “grown” a large backup set spanning through the ages and on very infrequent times I logged in to my server through VPS and manually cleaned up everything I though irrelevant and didn’t need anymore.

This was a lot of  effort, got forgotten very easily and  to be fair, on more then one occasion this lead to my server halting because the disk was 100% allocated.

To resolve this I’ve got together a very basic, very easy script that will remove all daily backup’s older then 6 Days, all Weekly’s older then 35 Day’s and all Monthly’s older than 90 Day’s that I thought I’d share.

 

#!/bin/bash
#cleanBackups
find /backups/daily/ -type f -mtime +6 -exec rm {} \;
find /backups/weekly/ -type f -mtime +31 -exec rm {} \;
find /backups/monthly/ -type f -mtime +90 -exec rm {} \;

I run this script every 1′st day of the week through Crontab

0 4 * * 0 /utilScript/cleanBackups.sh

This means that in the end I end up with:

  • A full set of Backup’s over time in my therefore created GMAIL account
  • A full set of Backup’s over time on my NAS
  • A “working” set of Backups consisting of 6 Daily’s;  At worst 5 Weekly’s and 3 Monthly’s.

 

This should and has up to this day covered all my needs.

 

The scripting isn’t “high grade” or difficult at all, but if I hope to be able to help someone who is like I was “back then”.

 

Regards,

Entity

Leave a Comment more...

A new concept in security

by on Apr.21, 2011, under Solutions, Uncategorized, Virtualization

Recently released as a first beta is the Qubes OS:

http://qubes-os.org/

This OS is a derived from a Linux, Xen and X Windows Manager and aims to provide security through compartimentalization or better yet, isolation.

Basically what this means is that instead of applying the other 2 principles of security meaning:

  • Security by Correctness (secure coding)
  • Security by Obscurity

This Operating System aims to improve security by seperating all major components and working environment and locking them down from interacting with one another. This translates into the fact that technically speaking your mail application with your work e-mail on it, can not talk to your personal mail client or your private environment. Now, it is off course possible to copy / paste between the different compartments of security that Qubes offers, through a built in secure system, but even though this is a critical component that makes or breaks the system of compartmentalization we’ll disregard it for the time being.

Now, why do I like this concept so much ?

Well it’s quite easy, how many of us have not thought of running Virtual Machines in Seamless Mode so we could have a Firefox, Internet Explorer, Google Chrome or alike integrate perfectly with our “live” Operating System and at the same time still have the security that a throw away Virtual Machine gives. (Throw away either by really throwing it away, or rolling back snapshots )

This is basically exactly the same thing but only more of a in depth and functionally stronger interpretation / product.

Regardless, the Qubes-OS is now in public Beta (Public Beta 1) and I too shall try to install it and give it a go in terms of functional analysis and how the implementation was done.

For now this will be the first thing I say about Qubes-OS but I hope it certainly won’t be the last.

regards,

Entity

Leave a Comment :, , , more...

Quick Update

by on Nov.16, 2010, under Uncategorized

Microsoft is currently running a Beta of the Windows 2008 R2 SP1 Beta (also windows 7 SP 1) and in it are a few upgrades to our liking.

For one, and the most important one, the reason for this quicky is the fact that Microsoft are implementing a feature called:

“Dynamic Memory”

According to Microsoft:

“Dynamic Memory lets Hyper-V administrators pool available memory on a physical host and dynamically distribute it to any virtual machine(s) running on that host. ”

What this basically entails for the people who have trouble understanding this, is that Microsoft is now implementing a feature that’s been known for a while in the VMware platform as “Memory Overcommit”. (not 100% accurate but I’ll explain later)

In the past (right now, the non Beta version of Hyper-V R2) you assign memory to a virtual machine, and the hypervisor (Hyper-V R2) reserves this memory. Now only the machine it has been assigned to can use the memory, and no other machine.

In itself not a bad feature since you know that your machines will have their RAM always available and always assigned, but this is a problem if you want to consolidate resources (one of the main reasons behind Virtualization) and if you have machines that alternate load.

what I mean with that last statement is, you may have Terminal Servers who in the day consume vast amounts of Memory but at night, your Terminal Servers are not used and instead your Database Servers come under heavy load doing nightly processing.

If you run this under a “normal” Hyper-V R2 scenario, then you will need to have enough memory to assign to all of the servers installed in your machine. With Dynamic Memory however, Memory is pooled and (simply put) handed out whenever it is needed.

So your Terminal Server farm can consume 80% of the RAM pool by day, but at night all the unconsumed RAM will go back in the pool, available for your Database / nightly processing to consume.

In all fairness, this is something that should have been in R2 from the start for Microsoft to have a competing advantage… that being said however, if they release this feature in their “Hyper-V R2 Free” edition then this means that Microsoft’s Hyper-visor will have a edition that is:

- Free
- Supports Fail Over
- Supports Live Migration
- Supports “memory overcommit” like features

These are features, or a combination of features that, if you would want these in any other bare-metal hyper-visor that you would have to pay for …

(exception being Xen Hyper-visor but it isn’t as nicely packaged / ease of use as the other ones)

Too conclude, because this “quick” update has become a lot less quick then anticipated, I can’t wait to see how the new version of Microsoft’s Hyper-Visor performs with these features. To add to this, I’m also quite delighted that another hurdle has been removed in using Microsoft’s Hyper-visor in a fully fledged production environment.

Leave a Comment : more...

Progress status and a new competitor, Citrix XenServer !

by on May.06, 2010, under Hyper-V, Virtualization

Right,

I though it’d be best to supply a quick update since no one has heard from me on this blog in a few weeks, basically the project / research is still going strong. Due to a unexpected turn of events though, I found myself with more time then originally anticipated, so I’ve decided to add a competitor to the pool, Citrix XenServer.
Again we’ll only be using what comes free with the software, nothing else.

Why have I chosen Citrix XenServer ?

Basically I could have compiled my own Xen kernel, deployed it and set everything up myself, but for a production environment or a enterprise level company, that is just too time consuming and not a sound thing to do. In such a scenario you are better off using a established product like Citrix’s XenServer, since its basically a pre-made Xen kernel like you would make / deploy yourself, only a little bit more polished and with some Citrix code / UI plugged into it. Also, even though the setup for this research has at its core the “Free” or at least “Very Cheap” aspect (since every platform can do everything if you throw enough cash at it) there is still such a thing as “support” and “SLA” that vendors offer (such as VMWare, Citrix and Microsoft do on their Hypervisor products).

What this means is, even though we now look at the solutions from a free or cheap mindset, in the end you’ll always want support from the vendor if things go horribly wrong. For this reason its “best” to use an established product because in case of emergency you can contact the vendor for help, instead of needing your own in house Xen Guru to figure it out.
There are other reason granted, and they will be included in the final document and a later writeup that I’ll be doing, but for now this is it.

On the Hyper-V R2 Core (Free) Documentation:

Its finished and being proof-read by a few friends of mine. As soon as I get the “OK” from all of them I’ll post the document on here.

Estimated time to publication: A few days from now at most, so keep your eyes on this blog if you wish to become the Hyper-V R2 Core (Free) Document.

Leave a Comment :, , , , more...

Hyper-V R2 vs ESXi Stage 1 Completed

by on Apr.02, 2010, under Hyper-V, Solutions, Virtualization

Well,

thought a status update’d be in order seeing as I’ve now completed stage 1 of my Hyper-V R2 vs EXi Comparative study.

I’ve got a Hyper-V R2 Cluster running in high availability & Failover clustering mode and it’s all working fine and dandy.

Hardware used where 2 HP DL380 G5′s, with a HP DL 380 G4 Operating as makeshift NAS (Running OPEN-E DSSV6).

I’ll add a “how-to” page this weekend after I’ve decided whether  or not I should set up a Wiki (TRAC software) to host it all on or not.
My conclusions so far are pretty much the same as what everyones has been saying since the release of the Hypervisor. It’s good, it sure ain’t bad and for what people might like to do with it, it does it just fine, however I don’t think Hyper-V R2 is mature enough yet to be called a enterprise level platform. It works, don’t get me wrong, it does all the things it say’s it does, High availability, fail over, live migration… but its not as feature rich as VMware’s solution and that is where the problems start.

If you are looking for  a Virtualization platform which is:

- Cheap
- Fairly easy in setup & Maintenance
- Does not require a great deal of “features”

and you can live with a bit of downtime now and then, then by all means Hyper-V R2 is not a bad platform, it does all the above and it does it good, however….

the options its lacking and which I personally find a shame that it doesn’t posses is data storage migration.

For instance, you can’t say “Move VM1 on LUN 1 over to LUN2 so I can do maintenance on LUN 1″. You have to take the VM offline, then move it over and reboot it and THEN you can take LUN1 down for maintenance.

It’s a “small” problem if you don’t need this functionality, but if you require this level of uptime then, Hyper-V R2 is not for you.

Anyways, more information and a “How To” / Stepping guide to come this weekend when I get some more time.

Leave a Comment :, , , , more...

Introduction to what it is I do ?!

by on Mar.28, 2010, under Uncategorized

Ok, so perhaps a introduction is in order.

I’m a 20 something year old Belgian with a passion for IT & Tech as I stated previously, but what I didn’t say is what I do, how and why I do it.

So, first off, what is it I do ?

Well I’m many things but right now I’m a student, final year of Uni and doing my internship, along with my graduation project. The internship is at the “Digipoint” company (http://www.digipoint.be) here in Belgium.

The role I fulfill there can be best described as Junior System’s Engineer, right now though, I’m working on my graduation Project for the company which is a Comparative study between Hyper-V R2 and ESXi in High Availability & Fail-over Clustering mode. The aim of the study is to be able to put the final documentation in front of a customer and be able to, along with that documentation decide which Virtualisation software / solution is best for their needs.

Now, I know there are other & potentially better/other solutions in the form of ESX 4.0 / Xen / OpenVZ and the regular HYPER-V R2 (non free) version, but this study is for people who “need” virtualisation, and at the same time don’t need it hard enough to warrant buying expensive licences for the more advanced / feature rich solutions.

So, now you know what I do, how I do it is pretty straightforward, I’ve got a few servers to my disposal (courtesy of Digipoint) on which I have (in this fase of the project) 2 HYPER-V R2 Core (free version) install’s running. I’ve got 1 system which is dubbing for a NAS right now, running OPEN-E DSS V6 and I’m also using 1 virtual machine on the Digipoint Infrastructure which is playing the role of Active Directory and Management console for the Hyper-V R2 install’s to manage and maintain the cluster I’m running between the both of them.

Once I get everything set up proper & working, and the documentation is made, benchmarks have been run, I will strip and wipe everything, and deploy a VMWare ESXi solution onto the machines.

Why I do all this is on one end obvious, I want to graduate ! On the other end of the spectrum though lies that I’m just enjoying myself playing with expensive server toys and tech. I’ve always said that servers / NAS / Clusters / … High end hardware in general is toys for grownups and I am sticking to it to this day.

Servers, Switches, Routers, High End Computing systems… toys for grownups, and I feel like a kid in a toy factory !

1 Comment :, , , , , more...

Hello world! – Introduction -

by on Mar.26, 2010, under Uncategorized

Well,

It’s up and running this wordpress install so perhaps you should allow me to introduce myself a bit.

My name, on the internet at least, is Entity, I’m a guy with a passion, a passion for IT & Technology. With this passion comes fun, exploration, and comes hardship and frustration.

My aim, with this blog is to put available: thoughts, ideas, projects and solutions to problems I’ve encountered, thoughts I have had and projects I’m working on.

I hope you lot enjoy my blogging as much as able, and don’t forget, constructive Criticism is always appreciated, or partaking in the discussions.

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...