@@ -82,11 +82,11 @@ func handleGetState(ctx context.Context, odcClient *RpcClient, envId string) (st
8282 "odcMsg" : rep .Reply .Msg ,
8383 "odcStatus" : rep .Reply .Status .String (),
8484 "odcExectime" : rep .Reply .Exectime ,
85- "odcRunid " : rep .Reply .Partitionid ,
85+ "partition " : rep .Reply .Partitionid ,
8686 "odcSessionid" : rep .Reply .Sessionid ,
8787 "odcState" : rep .Reply .State ,
8888 }).
89- Debug ("call to ODC complete" )
89+ Debug ("call to ODC complete: odc.GetState " )
9090 return odcutils .StateForOdcState (newState ), err
9191}
9292
@@ -150,10 +150,10 @@ func handleStart(ctx context.Context, odcClient *RpcClient, arguments map[string
150150 "odcMsg" : setPropertiesResponse .Msg ,
151151 "odcStatus" : setPropertiesResponse .Status .String (),
152152 "odcExectime" : setPropertiesResponse .Exectime ,
153- "odcRunid " : setPropertiesResponse .Partitionid ,
153+ "partition " : setPropertiesResponse .Partitionid ,
154154 "odcSessionid" : setPropertiesResponse .Sessionid ,
155155 }).
156- Debug ("call to ODC complete" )
156+ Debug ("call to ODC complete: odc.SetProperties " )
157157
158158 // The actual START operation starts here
159159 rep , err = odcClient .Start (ctx , req , grpc.EmptyCallOption {})
@@ -177,10 +177,10 @@ func handleStart(ctx context.Context, odcClient *RpcClient, arguments map[string
177177 "odcMsg" : rep .Reply .Msg ,
178178 "odcStatus" : rep .Reply .Status .String (),
179179 "odcExectime" : rep .Reply .Exectime ,
180- "odcRunid " : rep .Reply .Partitionid ,
180+ "partition " : rep .Reply .Partitionid ,
181181 "odcSessionid" : rep .Reply .Sessionid ,
182182 }).
183- Debug ("call to ODC complete" )
183+ Debug ("call to ODC complete: odc.Start " )
184184 return err
185185}
186186
@@ -223,13 +223,33 @@ func handleStop(ctx context.Context, odcClient *RpcClient, arguments map[string]
223223 "odcMsg" : rep .Reply .Msg ,
224224 "odcStatus" : rep .Reply .Status .String (),
225225 "odcExectime" : rep .Reply .Exectime ,
226- "odcRunid " : rep .Reply .Partitionid ,
226+ "partition " : rep .Reply .Partitionid ,
227227 "odcSessionid" : rep .Reply .Sessionid ,
228228 }).
229- Debug ("call to ODC complete" )
229+ Debug ("call to ODC complete: odc.Stop " )
230230 return err
231231}
232232
233+
234+ func handlePartitionTerminate (ctx context.Context , odcClient * RpcClient , arguments map [string ]string , envId string ) error {
235+ defer utils .TimeTrackFunction (time .Now (), log .WithPrefix ("odcclient" ).WithField ("partition" , envId ))
236+ if envId == "" {
237+ return errors .New ("cannot proceed with empty environment id" )
238+ }
239+
240+ err := doTerminate (ctx , odcClient , arguments , envId )
241+ if err != nil {
242+ return printGrpcError (err )
243+ }
244+
245+ err = doShutdown (ctx , odcClient , arguments , envId )
246+ if err != nil {
247+ return printGrpcError (err )
248+ }
249+ return nil
250+ }
251+
252+
233253func handleReset (ctx context.Context , odcClient * RpcClient , arguments map [string ]string , envId string ) error {
234254 defer utils .TimeTrackFunction (time .Now (), log .WithPrefix ("odcclient" ).WithField ("partition" , envId ))
235255 if envId == "" {
@@ -241,6 +261,21 @@ func handleReset(ctx context.Context, odcClient *RpcClient, arguments map[string
241261 return printGrpcError (err )
242262 }
243263
264+ return nil
265+ }
266+
267+
268+ func handleResetLegacy (ctx context.Context , odcClient * RpcClient , arguments map [string ]string , envId string ) error {
269+ defer utils .TimeTrackFunction (time .Now (), log .WithPrefix ("odcclient" ).WithField ("partition" , envId ))
270+ if envId == "" {
271+ return errors .New ("cannot proceed with empty environment id" )
272+ }
273+
274+ err := doReset (ctx , odcClient , arguments , envId )
275+ if err != nil {
276+ return printGrpcError (err )
277+ }
278+
244279 err = doTerminate (ctx , odcClient , arguments , envId )
245280 if err != nil {
246281 return printGrpcError (err )
@@ -321,7 +356,7 @@ func handleCleanup(ctx context.Context, odcClient *RpcClient, arguments map[stri
321356 "odcStatus" : rep .GetStatus ().String (),
322357 "odcExectime" : rep .GetExectime (),
323358 }).
324- Debug ("call to ODC complete" )
359+ Debug ("call to ODC complete: odc.GetStatus " )
325360
326361 partitionIdsKnownToOdc := make ([]string , len (rep .GetPartitions ()))
327362 for i , v := range rep .GetPartitions () {
@@ -416,10 +451,10 @@ func doReset(ctx context.Context, odcClient *RpcClient, arguments map[string]str
416451 "odcMsg" : rep .Reply .Msg ,
417452 "odcStatus" : rep .Reply .Status .String (),
418453 "odcExectime" : rep .Reply .Exectime ,
419- "odcRunid " : rep .Reply .Partitionid ,
454+ "partition " : rep .Reply .Partitionid ,
420455 "odcSessionid" : rep .Reply .Sessionid ,
421456 }).
422- Debug ("call to ODC complete" )
457+ Debug ("call to ODC complete: odc.Reset " )
423458 return err
424459}
425460
@@ -456,10 +491,10 @@ func doTerminate(ctx context.Context, odcClient *RpcClient, arguments map[string
456491 "odcMsg" : rep .Reply .Msg ,
457492 "odcStatus" : rep .Reply .Status .String (),
458493 "odcExectime" : rep .Reply .Exectime ,
459- "odcRunid " : rep .Reply .Partitionid ,
494+ "partition " : rep .Reply .Partitionid ,
460495 "odcSessionid" : rep .Reply .Sessionid ,
461496 }).
462- Debug ("call to ODC complete" )
497+ Debug ("call to ODC complete: odc.Terminate " )
463498 return err
464499}
465500
@@ -491,10 +526,10 @@ func doShutdown(ctx context.Context, odcClient *RpcClient, arguments map[string]
491526 "odcMsg" : shutdownResponse .Msg ,
492527 "odcStatus" : shutdownResponse .Status .String (),
493528 "odcExectime" : shutdownResponse .Exectime ,
494- "odcRunid " : shutdownResponse .Partitionid ,
529+ "partition " : shutdownResponse .Partitionid ,
495530 "odcSessionid" : shutdownResponse .Sessionid ,
496531 }).
497- Debug ("call to ODC complete" )
532+ Debug ("call to ODC complete: odc.Shutdown " )
498533 return err
499534}
500535
@@ -563,15 +598,15 @@ func handleRun(ctx context.Context, odcClient *RpcClient, isManualXml bool, argu
563598 "odcMsg" : runResponse .Msg ,
564599 "odcStatus" : runResponse .Status .String (),
565600 "odcExectime" : runResponse .Exectime ,
566- "odcRunid " : runResponse .Partitionid ,
601+ "partition " : runResponse .Partitionid ,
567602 "odcSessionid" : runResponse .Sessionid ,
568603 }).
569- Debug ("call to ODC complete" )
604+ Debug ("call to ODC complete: odc.Run " )
570605 return err
571606}
572607
573608
574- func handleConfigure (ctx context.Context , odcClient * RpcClient , arguments map [string ]string , isManualXml bool , topology string , script string , plugin string , resources string , envId string ) error {
609+ func handleConfigure (ctx context.Context , odcClient * RpcClient , arguments map [string ]string , envId string ) error {
575610 defer utils .TimeTrackFunction (time .Now (), log .WithPrefix ("odcclient" ))
576611 if envId == "" {
577612 return errors .New ("cannot proceed with empty environment id" )
@@ -597,6 +632,112 @@ func handleConfigure(ctx context.Context, odcClient *RpcClient, arguments map[st
597632 i ++
598633 }
599634
635+ log .WithField ("partition" , envId ).Debugf ("preparing call odc.SetProperties" )
636+
637+ var setPropertiesResponse * odcpb.GeneralReply
638+ setPropertiesResponse , err = odcClient .SetProperties (ctx , setPropertiesRequest , grpc.EmptyCallOption {})
639+ if err != nil {
640+ log .WithField ("partition" , envId ).WithError (err ).Debugf ("finished call odc.SetProperties with ERROR" )
641+ return printGrpcError (err )
642+ }
643+
644+
645+ if setPropertiesResponse == nil {
646+ log .WithField ("partition" , envId ).WithError (err ).Debugf ("finished call odc.SetProperties, ERROR nil response" )
647+
648+ // We got a nil response with nil error, this should never happen
649+ return errors .New ("nil response error" )
650+ }
651+
652+ if odcErr := setPropertiesResponse .GetError (); odcErr != nil {
653+ log .WithField ("partition" , envId ).WithError (err ).Debugf ("finished call odc.SetProperties, ERROR in response payload" )
654+
655+ return fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
656+ }
657+ if replyStatus := setPropertiesResponse .Status ; replyStatus != odcpb .ReplyStatus_SUCCESS {
658+ log .WithField ("partition" , envId ).WithError (err ).Debugf ("finished call odc.SetProperties, bad status in response payload" )
659+
660+ return fmt .Errorf ("status %s from ODC" , replyStatus .String ())
661+ }
662+
663+ log .WithField ("partition" , envId ).Debugf ("finished call odc.SetProperties with SUCCESS" )
664+
665+ log .WithFields (logrus.Fields {
666+ "odcMsg" : setPropertiesResponse .Msg ,
667+ "odcStatus" : setPropertiesResponse .Status .String (),
668+ "odcExectime" : setPropertiesResponse .Exectime ,
669+ "partition" : setPropertiesResponse .Partitionid ,
670+ "odcSessionid" : setPropertiesResponse .Sessionid ,
671+ }).
672+ Debug ("call to ODC complete: odc.SetProperties" )
673+
674+
675+ // CONFIGURE
676+ configureRequest := & odcpb.ConfigureRequest {
677+ Request : & odcpb.StateRequest {
678+ Partitionid : envId ,
679+ Path : "" ,
680+ Detailed : false ,
681+ },
682+ }
683+
684+ var configureResponse * odcpb.StateReply
685+ configureResponse , err = odcClient .Configure (ctx , configureRequest , grpc.EmptyCallOption {})
686+ if err != nil {
687+ return printGrpcError (err )
688+ }
689+
690+ if configureResponse == nil || configureResponse .Reply == nil {
691+ // We got a nil response with nil error, this should never happen
692+ return errors .New ("nil response error" )
693+ }
694+
695+ if odcErr := configureResponse .Reply .GetError (); odcErr != nil {
696+ return fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
697+ }
698+ if replyStatus := configureResponse .Reply .Status ; replyStatus != odcpb .ReplyStatus_SUCCESS {
699+ return fmt .Errorf ("status %s from ODC" , replyStatus .String ())
700+ }
701+ log .WithFields (logrus.Fields {
702+ "odcMsg" : configureResponse .Reply .Msg ,
703+ "odcStatus" : configureResponse .Reply .Status .String (),
704+ "odcExectime" : configureResponse .Reply .Exectime ,
705+ "partition" : configureResponse .Reply .Partitionid ,
706+ "odcSessionid" : configureResponse .Reply .Sessionid ,
707+ }).
708+ Debug ("call to ODC complete: odc.Configure" )
709+ return err
710+ }
711+
712+
713+ func handleConfigureLegacy (ctx context.Context , odcClient * RpcClient , arguments map [string ]string , isManualXml bool , topology string , script string , plugin string , resources string , envId string ) error {
714+ defer utils .TimeTrackFunction (time .Now (), log .WithPrefix ("odcclient" ))
715+ if envId == "" {
716+ return errors .New ("cannot proceed with empty environment id" )
717+ }
718+
719+ var err error = nil
720+
721+ // SetProperties before CONFIGURE
722+ setPropertiesRequest := & odcpb.SetPropertiesRequest {
723+ Partitionid : envId ,
724+ Path : "" ,
725+ Properties : make ([]* odcpb.Property , len (arguments )),
726+ }
727+
728+ // Extract relevant parameters from Arguments payload
729+ // and build payload for SetProperty+Configure
730+ i := 0
731+ for k , v := range arguments {
732+ setPropertiesRequest .Properties [i ] = & odcpb.Property {
733+ Key : k ,
734+ Value : v ,
735+ }
736+ i ++
737+ }
738+
739+ log .WithField ("partition" , envId ).Debugf ("preparing call odc.Run" )
740+
600741 err = handleRun (ctx , odcClient , isManualXml , map [string ]string {
601742 "topology" : topology ,
602743 "script" : script ,
@@ -605,35 +746,50 @@ func handleConfigure(ctx context.Context, odcClient *RpcClient, arguments map[st
605746 },
606747 envId )
607748 if err != nil {
749+ log .WithField ("partition" , envId ).WithError (err ).Debugf ("finished call odc.Run with ERROR" )
608750 return printGrpcError (err )
609751 }
752+ log .WithField ("partition" , envId ).Debugf ("finished call odc.Run with SUCCESS" )
753+
610754
755+ log .WithField ("partition" , envId ).Debugf ("preparing call odc.SetProperties" )
611756
612757 var setPropertiesResponse * odcpb.GeneralReply
613758 setPropertiesResponse , err = odcClient .SetProperties (ctx , setPropertiesRequest , grpc.EmptyCallOption {})
614759 if err != nil {
760+ log .WithField ("partition" , envId ).WithError (err ).Debugf ("finished call odc.SetProperties with ERROR" )
615761 return printGrpcError (err )
616762 }
617763
764+
618765 if setPropertiesResponse == nil {
766+ log .WithField ("partition" , envId ).WithError (err ).Debugf ("finished call odc.SetProperties, ERROR nil response" )
767+
619768 // We got a nil response with nil error, this should never happen
620769 return errors .New ("nil response error" )
621770 }
622771
623772 if odcErr := setPropertiesResponse .GetError (); odcErr != nil {
773+ log .WithField ("partition" , envId ).WithError (err ).Debugf ("finished call odc.SetProperties, ERROR in response payload" )
774+
624775 return fmt .Errorf ("code %d from ODC: %s" , odcErr .GetCode (), odcErr .GetMsg ())
625776 }
626777 if replyStatus := setPropertiesResponse .Status ; replyStatus != odcpb .ReplyStatus_SUCCESS {
778+ log .WithField ("partition" , envId ).WithError (err ).Debugf ("finished call odc.SetProperties, bad status in response payload" )
779+
627780 return fmt .Errorf ("status %s from ODC" , replyStatus .String ())
628781 }
782+
783+ log .WithField ("partition" , envId ).Debugf ("finished call odc.SetProperties with SUCCESS" )
784+
629785 log .WithFields (logrus.Fields {
630- "odcMsg" : setPropertiesResponse .Msg ,
631- "odcStatus" : setPropertiesResponse .Status .String (),
632- "odcExectime" : setPropertiesResponse .Exectime ,
633- "odcRunid " : setPropertiesResponse .Partitionid ,
634- "odcSessionid" : setPropertiesResponse .Sessionid ,
635- }).
636- Debug ("call to ODC complete" )
786+ "odcMsg" : setPropertiesResponse .Msg ,
787+ "odcStatus" : setPropertiesResponse .Status .String (),
788+ "odcExectime" : setPropertiesResponse .Exectime ,
789+ "partition " : setPropertiesResponse .Partitionid ,
790+ "odcSessionid" : setPropertiesResponse .Sessionid ,
791+ }).
792+ Debug ("call to ODC complete: odc.SetProperties " )
637793
638794
639795 // CONFIGURE
@@ -666,10 +822,10 @@ func handleConfigure(ctx context.Context, odcClient *RpcClient, arguments map[st
666822 "odcMsg" : configureResponse .Reply .Msg ,
667823 "odcStatus" : configureResponse .Reply .Status .String (),
668824 "odcExectime" : configureResponse .Reply .Exectime ,
669- "odcRunid " : configureResponse .Reply .Partitionid ,
825+ "partition " : configureResponse .Reply .Partitionid ,
670826 "odcSessionid" : configureResponse .Reply .Sessionid ,
671827 }).
672- Debug ("call to ODC complete" )
828+ Debug ("call to ODC complete: odc.Configure " )
673829 return err
674830}
675831
0 commit comments