diff --git a/xCAT-UI/xcat/plugins/webportal.pm b/xCAT-UI/xcat/plugins/webportal.pm index 6a2d0fbe7..5df9bdd3b 100644 --- a/xCAT-UI/xcat/plugins/webportal.pm +++ b/xCAT-UI/xcat/plugins/webportal.pm @@ -383,13 +383,17 @@ sub clonezlinux { # Get source node's HCP my $props = xCAT::zvmUtils->getNodeProps( 'zvm', $src_node, ('hcp') ); my $hcp = $props->{'hcp'}; + + # Get source node's nodetype + $props = xCAT::zvmUtils->getNodeProps( 'nodetype', $src_node, ('os', 'arch', 'profile') ); + my $os = $props->{'os'}; + my $arch = $props->{'arch'}; + my $profile = $props->{'profile'}; - # Read in default disk pool and disk size /opt/zhcp/conf/default.conf on zHCP + # Read in default disk pool from /opt/zhcp/conf/default.conf on zHCP # pool = POOL3 # eckd_size = 10016 my $disk_pool; - my $eckd_size; - my $fba_size; my $default_conf = '/opt/zhcp/conf/default.conf'; my $default_direct = '/opt/zhcp/conf/default.direct'; @@ -412,85 +416,45 @@ sub clonezlinux { if ( $_ =~ m/pool =/i ) { $disk_pool = $_; $disk_pool =~ s/pool =//g; - } - - # Get disk size - elsif ( $_ =~ m/eckd_size =/i ) { - $eckd_size = $_; - $eckd_size =~ s/eckd_size =//g; - } - elsif ( $_ =~ m/fba_size = /i ) { - $fba_size = $_; - $fba_size =~ s/fba_size = //g; + $disk_pool =~ s/\s*$//; # Trim right + $disk_pool =~ s/^\s*//; # Trim left } } + + # Create VM + # e.g. webportal provzlinux [group] [hcp] [image] + my ($node, $base_digit) = gennodename( $callback, $group ); + my $userid = 'XCAT' . $base_digit; - println( $callback, "Your virtual machine is ready. It may take a few minutes before you can logon." ); - println( $callback, "Done!" ); + # Set node definitions + $out = `mkdef -t node -o $node userid=$userid hcp=$hcp mgt=zvm groups=$group`; + println( $callback, "$out" ); + + # Set nodetype definitions + $out = `chtab node=$node noderes.netboot=zvm nodetype.nodetype=osi nodetype.provmethod=install nodetype.os=$os nodetype.arch=$arch nodetype.profile=$profile nodetype.comments="owner:$owner"`; + + # Update hosts table and DNS + `makehosts`; + `makedns`; + + # Update DHCP + `makedhcp -a`; + + # Clone virtual machine + $out = `mkvm $node $src_node pool=$disk_pool`; + println( $callback, "$out" ); + if ( $out =~ m/Error/i || $out =~ m/Failed/i ) { + return; + } - return; - - - - -# # Create VM -# # e.g. webportal provzlinux [group] [hcp] [image] -# my ($node, $base_digit) = gennodename( $callback, $group ); -# my $userid = 'XCAT' . $base_digit; -# -# # Set node definitions -# $out = `mkdef -t node -o $node userid=$userid hcp=$hcp mgt=zvm groups=$group`; -# println( $callback, "$out" ); -# -# # Set nodetype definitions -# $out = `chtab node=$node noderes.netboot=zvm nodetype.nodetype=osi nodetype.provmethod=install nodetype.os=$os nodetype.arch=$arch nodetype.profile=$profile nodetype.comments="owner:$owner"`; -# -# # Update hosts table and DNS -# `makehosts`; -# `makedns`; -# -# # Create user directory entry replacing LXUSR with user ID -# # Use /opt/zhcp/conf/default.direct on zHCP as the template -# # USER LXUSR PSWD 512M 1G G -# # INCLUDE LNXDFLT -# # COMMAND SET VSWITCH VSW2 GRANT LXUSR -# $out = `ssh $hcp "sed $default_direct -e s/LXUSR/$userid/g" > /tmp/$node-direct.txt`; -# $out = `mkvm $node /tmp/$node-direct.txt`; -# `rm -rf /tmp/$node-direct.txt`; -# println( $callback, "$out" ); -# if ( $out =~ m/Error/i ) { -# return; -# } -# -# # Update DHCP -# `makedhcp -a`; -# -# # Toggle node power so COMMAND SET will get executed -# `rpower $node on`; -# `rpower $node off`; -# -# # Punch kernel, initrd, and ramdisk to node reader -# $out = `nodeset $node install`; -# println( $callback, "$out" ); -# if ( $out =~ m/Error/i ) { -# return; -# } -# -# # IPL reader and begin installation -# $out = `rnetboot $node ipl=00C`; -# println( $callback, "$out" ); -# if ( $out =~ m/Error/i ) { -# return; -# } -# -# # Configure Ganglia monitoring -# $out = `moncfg gangliamon $node -r`; -# -# # Show node information, e.g. IP, hostname, and root password -# $out = `lsdef $node | egrep "ip=|hostnames="`; -# my $rootpw = getsysrootpw(); -# println( $callback, "Your virtual machine is ready. It may take a few minutes before you can logon using VNC ($node:1). Below is your VM attributes." ); -# println( $callback, "$out" ); -# println( $callback, " rootpw = $rootpw" ); + # Configure Ganglia monitoring + $out = `moncfg gangliamon $node -r`; + + # Show node information, e.g. IP, hostname, and root password + $out = `lsdef $node | egrep "ip=|hostnames="`; + my $rootpw = getsysrootpw(); + println( $callback, "Your virtual machine is ready. It may take a few minutes before you can logon. Below is your VM attributes." ); + println( $callback, "$out" ); + println( $callback, " rootpw = Same as source node" ); } 1; \ No newline at end of file