@@ -10,6 +10,7 @@ import (
1010 "github.com/redhat-developer/mapt/pkg/provider/aws"
1111 "github.com/redhat-developer/mapt/pkg/provider/aws/modules/iam"
1212 "github.com/redhat-developer/mapt/pkg/provider/aws/modules/mac"
13+ macConstants "github.com/redhat-developer/mapt/pkg/provider/aws/modules/mac/constants"
1314 macHost "github.com/redhat-developer/mapt/pkg/provider/aws/modules/mac/host"
1415 macMachine "github.com/redhat-developer/mapt/pkg/provider/aws/modules/mac/machine"
1516 macUtil "github.com/redhat-developer/mapt/pkg/provider/aws/modules/mac/util"
@@ -35,6 +36,9 @@ func Create(ctx *maptContext.ContextArgs, r *MacPoolRequestArgs) error {
3536 if err := r .scheduleHouseKeeper (); err != nil {
3637 return err
3738 }
39+ if err := r .createRequestTaskSpec (); err != nil {
40+ return err
41+ }
3842 return r .requestReleaserAccount ()
3943}
4044
@@ -91,6 +95,10 @@ func HouseKeeper(ctx *maptContext.ContextArgs, r *MacPoolRequestArgs) error {
9195}
9296
9397func Request (ctx * maptContext.ContextArgs , r * RequestMachineArgs ) error {
98+ // If remote run through serverless
99+ if r .Remote {
100+ return requestRemote (ctx , r )
101+ }
94102 // First get full info on the pool and the next machine for request
95103 p , err := getPool (r .PoolName , r .Architecture , r .OSVersion )
96104 if err != nil {
@@ -129,6 +137,11 @@ func Request(ctx *maptContext.ContextArgs, r *RequestMachineArgs) error {
129137 * hi .Host .HostId )
130138}
131139
140+ func requestRemote (ctx * maptContext.ContextArgs , r * RequestMachineArgs ) error {
141+
142+ return fmt .Errorf ("not implemented yet" )
143+ }
144+
132145func Release (ctx * maptContext.ContextArgs , hostID string ) error {
133146 return macUtil .Release (ctx , hostID )
134147}
@@ -155,7 +168,7 @@ func (r *MacPoolRequestArgs) addMachinesToPool(n int) error {
155168func (r * MacPoolRequestArgs ) scheduleHouseKeeper () error {
156169 return serverless .Create (
157170 & serverless.ServerlessArgs {
158- Command : getHouseKeepingCommand (
171+ Command : houseKeepingCommand (
159172 r .PoolName ,
160173 r .Architecture ,
161174 r .OSVersion ,
@@ -170,28 +183,31 @@ func (r *MacPoolRequestArgs) scheduleHouseKeeper() error {
170183 r .OSVersion )})
171184}
172185
173- // // Run serverless operation request
174- // func (r *MacPoolRequestArgs) requester() error {
175- // return serverless.Create(
176- // getHouseKeepingCommand(
177- // r.PoolName,
178- // r.Architecture,
179- // r.OSVersion,
180- // r.OfferedCapacity,
181- // r.MaxSize,
182- // r.FixedLocation),
183- // serverless.Repeat,
184- // houseKeepingInterval,
185- // fmt.Sprintf("%s-%s-%s",
186- // r.PoolName,
187- // r.Architecture,
188- // r.OSVersion))
189- // }
186+ // Run serverless operation request
187+ // check how we will call it from the request?
188+ // may add tags and find or add arn to stack?
189+ func (r * MacPoolRequestArgs ) createRequestTaskSpec () error {
190+ return serverless .Create (
191+ & serverless.ServerlessArgs {
192+ Command : requestCommand (
193+ r .PoolName ,
194+ r .Architecture ,
195+ r .OSVersion ),
196+ LogGroupName : fmt .Sprintf ("%s-%s-%s-request" ,
197+ r .PoolName ,
198+ r .Architecture ,
199+ r .OSVersion ),
200+ Tags : map [string ]string {
201+ macConstants .TagKeyArch : r .Architecture ,
202+ macConstants .TagKeyOSVersion : r .OSVersion ,
203+ macConstants .TagKeyPoolName : r .PoolName ,
204+ }})
205+ }
190206
191- func getHouseKeepingCommand (poolName , arch , osVersion string ,
207+ func houseKeepingCommand (poolName , arch , osVersion string ,
192208 offeredCapacity , maxSize int ,
193209 fixedLocation bool ) string {
194- cmd := fmt .Sprintf (houseKeepingCommand ,
210+ cmd := fmt .Sprintf (houseKeepingCommandRegex ,
195211 poolName , arch , osVersion ,
196212 offeredCapacity , maxSize )
197213 if fixedLocation {
@@ -200,6 +216,12 @@ func getHouseKeepingCommand(poolName, arch, osVersion string,
200216 return cmd
201217}
202218
219+ func requestCommand (poolName , arch , osVersion string ) string {
220+ cmd := fmt .Sprintf (requestCommandRegex ,
221+ poolName , arch , osVersion )
222+ return cmd
223+ }
224+
203225// If we need less or equal than the max allowed on the pool we create all of them
204226// if need are more than allowed we can create just the allowed
205227func (r * MacPoolRequestArgs ) addCapacity (p * pool ) error {
0 commit comments