@@ -140,6 +140,10 @@ func (m *MachinePoolScope) SetReady() {
140140 m .OCIMachinePool .Status .Ready = true
141141}
142142
143+ func (m * MachinePoolScope ) SetReplicaCount (count int32 ) {
144+ m .OCIMachinePool .Status .Replicas = count
145+ }
146+
143147// GetWorkerMachineSubnet returns the WorkerRole core.Subnet id for the cluster
144148func (m * MachinePoolScope ) GetWorkerMachineSubnet () * string {
145149 for _ , subnet := range m .OCICluster .Spec .NetworkSpec .Vcn .Subnets {
@@ -150,6 +154,42 @@ func (m *MachinePoolScope) GetWorkerMachineSubnet() *string {
150154 return nil
151155}
152156
157+ // ListMachinePoolInstances returns the WorkerRole core.Subnet id for the cluster
158+ func (m * MachinePoolScope ) ListMachinePoolInstances (ctx context.Context ) ([]core.InstanceSummary , error ) {
159+ poolOid := m .OCIMachinePool .Spec .OCID
160+ if len (poolOid ) <= 0 {
161+ return nil , errors .New ("OCIMachinePool OCID can't be empty" )
162+ }
163+
164+ req := core.ListInstancePoolInstancesRequest {
165+ CompartmentId : common .String (m .OCICluster .Spec .CompartmentId ),
166+ InstancePoolId : common .String (poolOid ),
167+ }
168+ resp , err := m .ComputeManagementClient .ListInstancePoolInstances (ctx , req )
169+ if err != nil {
170+ return nil , err
171+ }
172+
173+ return resp .Items , nil
174+ }
175+
176+ // SetListandSetMachinePoolInstances retrieves a machine pools instances and sets them in the ProviderIDList
177+ func (m * MachinePoolScope ) SetListandSetMachinePoolInstances (ctx context.Context ) (int32 , error ) {
178+ poolInstanceSummaries , err := m .ListMachinePoolInstances (ctx )
179+ if err != nil {
180+ return 0 , errors .New ("Unable to list machine pool's instances" )
181+ }
182+ providerIDList := make ([]string , len (poolInstanceSummaries ))
183+
184+ for i , instance := range poolInstanceSummaries {
185+ providerIDList [i ] = fmt .Sprintf ("oci://%s" , * instance .Id )
186+ }
187+
188+ m .OCIMachinePool .Spec .ProviderIDList = providerIDList
189+
190+ return int32 (len (providerIDList )), nil
191+ }
192+
153193// GetBootstrapData returns the bootstrap data from the secret in the Machine's bootstrap.dataSecretName.
154194func (m * MachinePoolScope ) GetBootstrapData () (string , error ) {
155195 if m .MachinePool .Spec .Template .Spec .Bootstrap .DataSecretName == nil {
@@ -330,9 +370,8 @@ func (m *MachinePoolScope) ReconcileInstanceConfiguration(ctx context.Context) e
330370 },
331371 Metadata : metadata ,
332372 CreateVnicDetails : & core.InstanceConfigurationCreateVnicDetails {
333- SubnetId : subnetId ,
334- // TODO variablize AssignPublicIp in the future
335- AssignPublicIp : common .Bool (false ),
373+ SubnetId : subnetId ,
374+ AssignPublicIp : common .Bool (m .OCIMachinePool .Spec .VNICAssignPublicIp ),
336375 NsgIds : []string {* nsgId },
337376 },
338377 },
@@ -472,7 +511,9 @@ func (m *MachinePoolScope) UpdatePool(ctx context.Context, instancePool *core.In
472511 }
473512
474513 req := core.UpdateInstancePoolRequest {InstancePoolId : instancePool .Id ,
475- UpdateInstancePoolDetails : core.UpdateInstancePoolDetails {Size : common .Int (replicas )}}
514+ UpdateInstancePoolDetails : core.UpdateInstancePoolDetails {
515+ Size : common .Int (replicas ),
516+ }}
476517
477518 if _ , err := m .ComputeManagementClient .UpdateInstancePool (ctx , req ); err != nil {
478519 return errors .Wrap (err , "unable to update instance pool" )
@@ -492,7 +533,7 @@ func (m *MachinePoolScope) TerminateInstancePool(ctx context.Context, instancePo
492533 return nil
493534}
494535
495- // instancePoolNeedsUpdates compares incoming OCIMachinePool and compares against existing ASG .
536+ // instancePoolNeedsUpdates compares incoming OCIMachinePool and compares against existing instance pool .
496537func instancePoolNeedsUpdates (machinePoolScope * MachinePoolScope , instancePool * core.InstancePool ) bool {
497538
498539 // Allow pool resize
0 commit comments