@@ -19,22 +19,13 @@ module.exports.dispatcher = function (args) {
1919 let shouldInstallSlm = args . includes ( "type=slm" ) ;
2020 if ( shouldInstallSlm ) {
2121 argsWithoutFilename = args . slice ( 1 , args . length ) ;
22- } else {
23- if ( args . length < 2 ) {
24- util . error ( "When installing a JPROD license licensefile or host:port is mandatory." )
25- printModuleHelp ( ) ;
26- process . exit ( 1 ) ;
27- }
28- argsWithoutFilename = args . slice ( 1 , args . length - 1 ) ;
2922 }
23+
3024 let options = util . optionsFromArgs ( argsWithoutFilename , [
3125 'licenseServer' ,
3226 'accessKey' ,
33- 'type' ,
34- 'lastName' ,
35- 'firstName' ,
36- 'email' ] ) ;
37- installLicense ( options , shouldInstallSlm ? null : args [ args . length - 1 ] ) ;
27+ 'type' ] ) ;
28+ installLicense ( options ) ;
3829 break ;
3930 }
4031 case 'uninstall' :
@@ -61,24 +52,13 @@ function printModuleHelp() {
6152 util . error ( "Usage: testengine license <command>" ) ;
6253 util . error ( "Commands: " ) ;
6354 util . error ( " info" ) ;
64- util . error ( " install type=<fixed|floating|slm> [lastName=<name>] [firstName=<firstName>] [email=<email-address>]" ) ;
65- util . error ( " [licenseServer=<slmLicenseServer] [accessKey=<slmAccessKey>] [<licensefile|host:port>]" ) ;
55+ util . error ( " install type=slm [licenseServer=<slmLicenseServer] [accessKey=<slmAccessKey>]" ) ;
6656 util . error ( " uninstall" ) ;
6757 util . error ( " help" ) ;
6858}
6959
70- function installLicense ( options , licenseOrLicenseServer ) {
60+ function installLicense ( options ) {
7161 switch ( options [ 'type' ] ) {
72- case 'floating' : {
73- let mr = / ( [ ^ : ] * ) : ( [ 0 - 9 ] + ) / g. exec ( licenseOrLicenseServer ) ;
74- if ( mr ) {
75- installFloatingLicense ( mr [ 1 ] , parseInt ( mr [ 2 ] ) ) ;
76- }
77- break ;
78- }
79- case 'fixed' :
80- installFixedLicense ( options , licenseOrLicenseServer ) ;
81- break ;
8262 case 'slm' :
8363 if ( ! options . accessKey && ! options . licenseServer ) {
8464 util . error ( "At least one of the options accessKey or licenseServer needs to be specified when installing" +
@@ -87,7 +67,7 @@ function installLicense(options, licenseOrLicenseServer) {
8767 installSlmLicense ( options )
8868 break ;
8969 default :
90- util . printErrorAndExit ( "Error: Specifying fixed, floating or slm license is mandatory" ) ;
70+ util . printErrorAndExit ( "Error: Specifying slm license is mandatory" ) ;
9171 }
9272}
9373
@@ -133,63 +113,6 @@ function uninstallLicense() {
133113 } ) ;
134114}
135115
136- function installFixedLicense ( options , licenseFile ) {
137- let endPoint = config . server + '/api/v1/license' ;
138- let activationInfo = { } ;
139- for ( let key of [ 'firstName' , 'lastName' , 'email' ] ) {
140- if ( key in options ) {
141- activationInfo [ key ] = options [ key ] ;
142- }
143- }
144- let readStream = fs . createReadStream ( licenseFile ) ;
145- readStream . on ( 'open' , function ( ) {
146- let buffer = Buffer . from ( JSON . stringify ( activationInfo ) , 'utf8' ) ;
147- request . post ( endPoint )
148- . auth ( config . username , config . password )
149- . accept ( 'application/json' )
150- . type ( 'multipart/form-data' )
151- . attach ( 'file' , licenseFile )
152- . attach ( 'activationInfo' , buffer , "data.json" )
153- . end ( ( err , result ) => {
154- if ( err === null ) {
155- util . output ( "The following license was installed:" ) ;
156- util . output ( licenseInfoToString ( result . body ) )
157- } else {
158- handleError ( err , result )
159- }
160- } ) ;
161- } ) ;
162- readStream . on ( 'error' , function ( err ) {
163- util . error ( "Error: " + err . message ) ;
164- let ext = path . extname ( licenseFile ) . toLowerCase ( ) ;
165- if ( ( ext !== '.key' ) && ( ext !== '.zip' ) ) {
166- util . error ( '"' + licenseFile + '" does not seem to be a .zip or .key file' ) ;
167- }
168- process . exit ( 1 ) ;
169- } ) ;
170-
171- }
172-
173- function installFloatingLicense ( licenseServerHost , licenseServerPort ) {
174- let endPoint = config . server + '/api/v1/license' ;
175- let payload = {
176- 'host' : licenseServerHost ,
177- 'port' : licenseServerPort
178- } ;
179- request . post ( endPoint )
180- . auth ( config . username , config . password )
181- . accept ( 'application/json' )
182- . type ( 'application/json' )
183- . send ( payload )
184- . end ( ( err , result ) => {
185- if ( err === null ) {
186- util . output ( "The following license was installed:" ) ;
187- util . output ( licenseInfoToString ( result . body ) )
188- } else {
189- handleError ( err , result ) ;
190- }
191- } ) ;
192- }
193116
194117function showLicenseInfo ( ) {
195118 let endPoint = config . server + '/api/v1/license' ;
0 commit comments