Thursday, June 9, 2016

self help portal for taking backups of VM instances. 

A cloud provider has valuable assets in the form of virtual machine instances. These instances need to be backed up to protect against disaster and to aid recovery. The backups should contain sufficient information to restore to original state. The cloud provider may have many datacenters one for each region from where the virtual machine instances can be loaned from.  These  virtual machine instances will be requested to be backed up on demand with the push of a button on the portal. The user may need to see the last few times the backups were taken for this virtual machine if any even if it means going through a pile of data of all inventory in a datacenter to come up with the backups. The schedule should include user description as well as time the backup was taken. The virtual machines should appear with the information on the backup contents such as the files included. Even if the backup is in the form of an encrypted tar ball that the user never sees or touches, he should be able to refer to it with a locating universal resource identifier and request basic management activities such as create, delete, detail and restore.  Before the next backup is taken, the VM should be found in the datacenter failing which the backup should not be honored. Incremental backup from last state should be the default if one full backup was taken. This can be overridden with a full backup if the user requests it. The backups should also be listed with the VMs they were taken from and the VM properties that may be relevant to the backup. All the backups should be shown against their VM only. This means the user wants to list the backups rolled up as Virtual Machines. Only when the user presses the detail on a Virtual machine does she see all the backups of the virtual machine. The backups should be taken regardless of the flavor of the operating system on the virtual machine. In addition any storage volumes associated with the virtual machine must also be backed up if they show up as mapped devices to the Virtual Machine. The Virtual machines can appear individually as requested from a cloud provider such as VMWare or it may appear in a group as in a cluster which may be requested from say Openstack. In all cases, the VM should be listed one by one together with their attributes of the cluster or group it is part of. The details page of each VM will show the memberships to clusters and other containers. The actions on each VM will be the same regardless of the virtual machine's identity. The actions may target the cloud provider of the region in which the virtual machines live. Consequently the VMs must be fetched from all regions and shown in flat table. The take backup control should be made visible for each virtual machine should the user wish to initiate it. Backups have status that shows whether the request was initiated, pending, complete or canceled. More states may need to be added if the user will benefit from seeing the state. If the states update asynchronously, the page should refresh automatically on periodic intervals. 



#coding exercises  (yes a few more continued)
find first occurrence of 1 in a sorted series of zeros and ones
int GetOne(List<int> digits)
{
for (int i = 0; i < digits.count; i++)
{
if (digits[i] == 1)
    return i;
}
//not found
return -1;
}
//binary search
int GetOneBinaryChop(List<int>digits, int start, int end)
{
if (start == end) {
    if (digits[start] == 1)
         return start;
    else
         return -1;
}
int mid = (start + end) / 2;
if (digits[mid] == 0)
    return GetOneBinaryChop(digits, mid+1, end);
else
   return GetOneBinaryChop(digits, start, mid);
}

Output nearest number greater than given number such that output is palindrome
int nextPalindrome(int n)
{
var digits = n.toDigits();
int len = digits.Count;
int mid = len/2;
if (len%2 == 0)
{
// new_number = the digits from mid+1 to len-1 should be reverse of 0 to mid
if (new_number > n) return new_number
// new_number = Add 1 to the number from 0 to mid with carryover and padding to the right
return nextPalindrome(new_number)
}else{
//new_number = the digits from mid+1 to len-1 should be reverse of 0 to mid -1
if (new_number > n) return new_number
// new_number = Add 1 to the number from 0 to mid with carryover and padding to the right
return nextPalindrome(new_number)
}
}


Void carryforward (ref list <int> digits, int index, int val)

{
Sum = digits[index] + val;
Carry = Sum - 10;
If (carry > 0){
Digits [index] =0;
If (index == 0){
Digits.insert (0, carry);
Return 
}
Carryforward ( ref digits, index - 1, carry)
}else  {
Digits [index] = sum;
}
}

No comments:

Post a Comment