diff --git a/modules/servers/solusvmpro/lang/english.php b/modules/servers/solusvmpro/lang/english.php index 8aa58a9..971b48e 100644 --- a/modules/servers/solusvmpro/lang/english.php +++ b/modules/servers/solusvmpro/lang/english.php @@ -24,6 +24,8 @@ $_LANG['solusvmpro_used'] = 'Used'; $_LANG['solusvmpro_free'] = 'Free'; $_LANG['solusvmpro_status'] = 'Status'; +$_LANG['solusvmpro_rebuild'] = 'Rebuild Os'; +$_LANG['solusvmpro_submit_rebuild'] = 'Submit Rebuild Os'; $_LANG['solusvmpro_ipAddress'] = 'IP Address'; $_LANG['solusvmpro_unavailable'] = 'Unavailable'; $_LANG['solusvmpro_VSC'] = 'Virtual Server Control'; diff --git a/modules/servers/solusvmpro/solusvmpro.php b/modules/servers/solusvmpro/solusvmpro.php index 5967f7f..2da0aab 100644 --- a/modules/servers/solusvmpro/solusvmpro.php +++ b/modules/servers/solusvmpro/solusvmpro.php @@ -1073,6 +1073,43 @@ function solusvmpro_Custom_ChangeVNCPassword( $params = '' ) { } +function mf_solusvmpro_RebuildVirtualServer( $params, $os ) { + global $_LANG; + + try { + $solusvm = new SolusVM( $params ); + $customField = $solusvm->getParam( "customfields" ); + + ## The call string for the connection fuction + $callArray = array( + "vserverid" => $customField["vserverid"], + "template" => $os, + ); + + $solusvm->apiCall( 'vserver-rebuild', $callArray ); + + if ( $solusvm->isSuccessResponse($solusvm->result) ) { + $result = "success"; + } else { + $result = (string) $solusvm->result["statusmsg"]; + } + + return $result; + } catch ( Exception $e ) { + // Record the error in WHMCS's module log. + logModuleCall( + 'rebuild', + __FUNCTION__, + $params, + $e->getMessage(), + $e->getTraceAsString() + ); + + return $e->getMessage(); + } + +} + function solusvmpro_ClientArea( $params ) { $notCustomFuntions = [ 'reboot', 'shutdown', 'boot' ]; if ( isset( $_GET['modop'] ) && ( $_GET['modop'] == 'custom' ) ) { @@ -1116,10 +1153,46 @@ function solusvmpro_ClientArea( $params ) { } } } else { + + $rebuild = false; + if (isset($_POST['change_os']) && isset($_POST['vserver_templates'])){ + $os = $_POST['vserver_templates']; + $rebuild = mf_solusvmpro_RebuildVirtualServer($params, $os); + } + + #--------------- get templates + $packageconfigoption = initConfigOption(); + $vt = ''; + if ( $packageconfigoption[5] == "OpenVZ" ) { + $vt = "openvz"; + } elseif ( $packageconfigoption[5] == "Xen-PV" ) { + $vt = "xen"; + } elseif ( $packageconfigoption[5] == "Xen-HVM" ) { + $vt = "xen hvm"; + } elseif ( $packageconfigoption[5] == "KVM" ) { + $vt = "kvm"; + } + $callArray = array( "type" => $vt ); + ## List templates + $solusvm->apiCall( 'listtemplates', $callArray ); + + if ( $solusvm->isSuccessResponse($solusvm->result) ) { + $default_template = $solusvm->result["templates"]; + } else { + $default_template = $solusvm->rawResult; + } + $default_template = explode(',', $default_template); + #--------------- get templates + $data = array( 'vserverid' => $customField["vserverid"], + 'templates' => $default_template, ); + if($rebuild !== false){ + $data['rebuild_os'] = $rebuild; + } + return array( 'templatefile' => 'templates/clientareaBootstrap.tpl', 'vars' => array( diff --git a/modules/servers/solusvmpro/templates/clientareaBootstrap.tpl b/modules/servers/solusvmpro/templates/clientareaBootstrap.tpl index b3f1c42..e980861 100644 --- a/modules/servers/solusvmpro/templates/clientareaBootstrap.tpl +++ b/modules/servers/solusvmpro/templates/clientareaBootstrap.tpl @@ -94,6 +94,19 @@