Eliminated hard requires for SOAP::Lite and JSON
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13877 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -528,12 +528,9 @@ sub isLinux | ||||
| #------------------------------------------------------------------------------- | ||||
| sub Version | ||||
| { | ||||
|  | ||||
|     #The following tag tells the build script where to append build info | ||||
|     my $version = shift; | ||||
|     $version = xCAT::Version->Version(); | ||||
|     return $version; | ||||
|  | ||||
| } | ||||
|  | ||||
| #------------------------------------------------------------------------------- | ||||
|   | ||||
| @@ -38,7 +38,7 @@ use strict; | ||||
| sub Version | ||||
| { | ||||
|  | ||||
|     #The following tag tells the build script where to append build info | ||||
|     #The following tags tells the build script where to append build info | ||||
|     my $version = shift; | ||||
|     if ($version eq 'short') | ||||
|     { | ||||
|   | ||||
| @@ -14,7 +14,7 @@ package xCAT::hpoa; | ||||
|  | ||||
| use strict; | ||||
|  | ||||
| use SOAP::Lite; | ||||
| #use SOAP::Lite;	# hpblade.pm requires SOAP::Lite before requiring hpoa.pm, so we can check for SOAP::Lite dynamically | ||||
| use vars qw(@ISA); | ||||
| @ISA = qw(SOAP::Lite); | ||||
|  | ||||
|   | ||||
| @@ -271,10 +271,9 @@ sub init_plugin | ||||
|         # $rc = &setup_NTPmn();  # setup NTP on the Management Node | ||||
|         if (xCAT::Utils->isLinux()) | ||||
|         { | ||||
|             print "\n" | ||||
|               ; # make OK prints look better.  Only need to do this for the 1st service. | ||||
|             my @tmp = xCAT::TableUtils->get_site_attribute("vsftp");    | ||||
| 		    if ($tmp[0] && ($tmp[0] !~ /0|NO|No|no|N|n/ )) {          | ||||
|                 print "\n";    # make OK prints look better.  Only need to do this for the 1st service. | ||||
|                 $rc = &setup_FTP();    # setup FTP | ||||
|             } | ||||
|             #enable the tftp-hpa for MN | ||||
|   | ||||
| @@ -30,7 +30,7 @@ use Net::SSLeay qw(die_now die_if_ssl_error); | ||||
| use Data::Dumper; | ||||
| use POSIX "WNOHANG"; | ||||
| use Getopt::Long; | ||||
| use xCAT::hpoa; | ||||
| #use xCAT::hpoa;	# require this dynamically below instead | ||||
|  | ||||
| sub handled_commands { | ||||
| 	return { | ||||
| @@ -326,6 +326,14 @@ sub preprocess_request { | ||||
| 		$request = {}; | ||||
| 		return; | ||||
| 	}    | ||||
|  | ||||
| 	# require SOAP::Lite for hpoa.pm so we can do it dynamically | ||||
| 	my $soapsupport = eval { require SOAP::Lite; }; | ||||
| 	unless ($soapsupport) { #Still no SOAP::Lite module | ||||
|       $callback->({error=>"SOAP::Lite perl module missing.  Install perl-SOAP-Lite before running HP blade commands.",errorcode=>[42]}); | ||||
|       return []; | ||||
| 	} | ||||
| 	require xCAT::hpoa; | ||||
| 		 | ||||
| 	#get the MMs for the nodes for the nodes in order to figure out which service nodes to send the requests to | ||||
| 	my $mptab = xCAT::Table->new("mp"); | ||||
| @@ -600,6 +608,15 @@ sub process_request { | ||||
| 	unless ($command) { | ||||
| 		return; #Empty request | ||||
| 	} | ||||
|  | ||||
| 	# require SOAP::Lite for hpoa.pm so we can do it dynamically | ||||
| 	my $soapsupport = eval { require SOAP::Lite; }; | ||||
| 	unless ($soapsupport) { #Still no SOAP::Lite module | ||||
|       $callback->({error=>"SOAP::Lite perl module missing.  Install perl-SOAP-Lite before running HP blade commands.",errorcode=>[42]}); | ||||
|       return []; | ||||
| 	} | ||||
| 	require xCAT::hpoa; | ||||
|  | ||||
| 	if (ref($request->{arg})) { | ||||
| 		@exargs = @{$request->{arg}}; | ||||
| 	} else { | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| #!/usr/bin/perl | ||||
| use strict; | ||||
| use CGI qw/:standard/; | ||||
| use JSON; | ||||
| #use JSON;		# require this dynamically later on so that installations that do not use xcatws.cgi do not need perl-JSON | ||||
| use Data::Dumper; | ||||
|  | ||||
| #added the line: | ||||
| @@ -103,6 +103,15 @@ if ($queryhash{'format'}) { | ||||
|         addPageContent("The format '$format' is not valid"); | ||||
|         sendResponseMsg($STATUS_BAD_REQUEST); | ||||
|     } | ||||
|  | ||||
| 	if ($format eq 'json') { | ||||
| 		# require JSON dynamically and let them know if it is not installed | ||||
| 		my $jsoninstalled = eval { require JSON; }; | ||||
| 		unless ($jsoninstalled) { | ||||
| 		   addPageContent($q->p("JSON perl module missing.  Install perl-JSON before using the xCAT REST web services API.")); | ||||
| 		   sendResponseMsg($STATUS_SERVICE_UNAVAILABLE); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| my $XCAT_PATH = '/opt/xcat/bin'; | ||||
|   | ||||
| @@ -27,6 +27,8 @@ Requires: xCAT-server xCAT-client perl-DBD-SQLite | ||||
| Requires: httpd nfs-utils nmap bind perl-XML-Parser perl(CGI) | ||||
| # On RHEL this pulls in dhcp, on SLES it pulls in dhcp-server | ||||
| Requires: /usr/sbin/dhcpd | ||||
| # On RHEL this pulls in openssh-server, on SLES it pulls in openssh | ||||
| Requires: /usr/bin/ssh | ||||
| %ifnarch s390x | ||||
| Requires: /etc/xinetd.d/tftp | ||||
| # yaboot-xcat is pulled in so any MN can manage ppc nodes | ||||
|   | ||||
		Reference in New Issue
	
	Block a user