Sunday, December 18, 2016

We were reviewing the vSPC.py library. This is a virtual serial port concentrator that makes the use of VMware telnet extensions.The mechanism is based on RFC2217 - compatible telnet server.
When a remote system makes a connection request to the target on the ESX server, one virtual machine acts as a virtual serial port server and another acts as a client  The proxy listens for connection requests from the remote system and forwards it to the target This is true in the opposite direction as well. The proxy forwards both ways.
The proxy which  operates as a serial port concentrator has internal connections to several virtual machines in a datacenter and an external connection to a remote system. The concentrator provides a remote system with access to multiple virtual machines that act as serial port servers.
 This is a many to one mapping. The communication happens over a network serial port which uses a network socket on the host computer. A network socket is the endpoint of a network connection and is represented by an IP address, protocol and a port number. The network serial port must be supported by the ESX and then created or reconfigured on a virtual machine.
Virtual serial ports come in handy for backup and backing option.  They remain up even when the virtual machines go through vMotion.  To support this kind of persistent connection, the proxy makes two telnet connections for the virtual machine.  The ESX server supports a telnet extension specific to VMWare that allows the proxy to postpone the vMotion event until it finishes forwarding content. The ESX server sends a vmotion-begin  command and the proxy responds with a vmotion-goahead command. During this time, the proxy buffers any additional data it receives from the remote system. When the vMotion is complete, the proxy continues the content transmission to the new instance of the virtual machine.  When the new instance of the virtual machine boots up, the ESX server configures network backing for the virtual serial port and establishes  a second telnet connection with the proxy. Before continuing with the vMotion operation, the new virtual machine instance and the proxy renegotiate the telnet COM-PORT-OPTION without the proxy losing the com-port-option for the original instance. The proxy now supports one telnet connection for each instance. After the proxy accepts a new virtual machine instance as a peer, the ESX host on the new instance sends a vmotion-complete to the proxy so that it can release the original telnet connection.

Console access is available even from DRAC over ip as shown here : http://www.slac.stanford.edu/grp/cd/soft/unix/EnableSerialConsoleAccessViaSSH.htm

and explained here : https://1drv.ms/w/s!Ashlm-Nw-wnWlk6DmH-B9_C1dul6 

#codingexercise

Given  a binary tree with positive and negative values, find the maximum sum in a path through the parent. The path may start and end at any node in the tree.

int GetMaxPath(node root, ref int sum)
{
if (root == null) return 0;

var left  = GetMaxPath(root, ref sum);
var right = GetMaxPath(root, ref sum);
var max_one = max(root.data,
                                 max(left, right) + root.data));
sum =  Max(max_one,
                   left + right + root.data,
                   sum);
return max_one;
}
GetMaxPath(tree_top, int_min);


Determine if two trees are isomorphic
Two trees are isomorphic if the left tree and the right tree are identical.
bool isIsomorphic(Node root1, Node root2)
{
if (root1 == null && root2 == null) return true;
if (root1 == null || root2 == null) return false;
if (root1.data != root2.data) return false;
 if   (((isIsomorphic(root1.left, root2.left) && isIsomorphic(root1.right, root2.right)) ||
      ((isIsomorphic(root1.left, root2.right) && isIsomorphic(root1.right, root2.left)))
{
return true;
}
return false;
}

find the length of the longest arithmetic progression in an array

int GetLongestAP(List<int>numbers)
{
var progressions = new List<List<int>>();
var candidate = new List<int>();
numbers.ForEach( x => candidate.Add(-1));
int start = 0;
int level = 0;
Combine(numbers, ref candidate, ref progressions, start, level); // already implemented in this blog
but with the enhancement that we reject combinations that are not isAP();
return progressions.Max(x => x.Count(y => y != -1)).count;
}

bool isAP(List<int> numbers)
{
if (numbers == null || numbers.count <=2) return false;
int diff = numbers[1] - numbers[0] ;
for (int i = 2; i <numbers.count; i++)
    if (numbers[i]-numbers[i-1] != diff)
        return false;
return true;
}

No comments:

Post a Comment