src/bosh-softlayer-cpi/softlayer/client/client.go
func (c *ClientManager) WaitInstanceUntilReady(id int, until time.Time) error {
	for {
		virtualGuest, found, err := c.GetInstance(id, "id, lastOperatingSystemReload[id,modifyDate], activeTransaction[id,transactionStatus.name], provisionDate, powerState.keyName")
		if err != nil {
			return err
		}
		if !found {
			return bosherr.WrapErrorf(err, "SoftLayer virtual guest '%d' does not exist", id)
		}

		lastReload := virtualGuest.LastOperatingSystemReload
		activeTxn := virtualGuest.ActiveTransaction
		provisionDate := virtualGuest.ProvisionDate

		// if lastReload != nil && lastReload.ModifyDate != nil {
		// 	fmt.Println("lastReload: ", (*lastReload.ModifyDate).Format(time.RFC3339))
		// }
		// if activeTxn != nil && activeTxn.TransactionStatus != nil && activeTxn.TransactionStatus.Name != nil {
		// 	fmt.Println("activeTxn: ", *activeTxn.TransactionStatus.Name)
		// }
		// if provisionDate != nil {
		// 	fmt.Println("provisionDate: ", (*provisionDate).Format(time.RFC3339))
		// }

		reloading := activeTxn != nil && lastReload != nil && *activeTxn.Id == *lastReload.Id
		if provisionDate != nil && !reloading {
			// fmt.Println("power state:", *virtualGuest.PowerState.KeyName)
			if *virtualGuest.PowerState.KeyName == "RUNNING" {
				return nil
			}
		}

		now := time.Now()
		if now.After(until) {
			return bosherr.Errorf("Power on virtual guest with id %d Time Out!", *virtualGuest.Id)
		}

		min := math.Min(float64(10.0), float64(until.Sub(now)))
		time.Sleep(time.Duration(min) * time.Second)
	}
}
func (c *ClientManager) WaitInstanceUntilReady(id int, until time.Time) error {
	for {
		virtualGuest, found, err := c.GetInstance(id, "id, lastOperatingSystemReload[id,modifyDate], activeTransaction[id,transactionStatus.name], provisionDate, powerState.keyName")
		if err != nil {
			return err
		}
		if !found {
			return bosherr.WrapErrorf(err, "SoftLayer virtual guest '%d' does not exist", id)
		}

		lastReload := virtualGuest.LastOperatingSystemReload
		activeTxn := virtualGuest.ActiveTransaction
		provisionDate := virtualGuest.ProvisionDate

		// if lastReload != nil && lastReload.ModifyDate != nil {
		// 	fmt.Println("lastReload: ", (*lastReload.ModifyDate).Format(time.RFC3339))
		// }
		// if activeTxn != nil && activeTxn.TransactionStatus != nil && activeTxn.TransactionStatus.Name != nil {
		// 	fmt.Println("activeTxn: ", *activeTxn.TransactionStatus.Name)
		// }
		// if provisionDate != nil {
		// 	fmt.Println("provisionDate: ", (*provisionDate).Format(time.RFC3339))
		// }

		reloading := activeTxn != nil && lastReload != nil && *activeTxn.Id == *lastReload.Id
		if provisionDate != nil && !reloading {
			// fmt.Println("power state:", *virtualGuest.PowerState.KeyName)
			if *virtualGuest.PowerState.KeyName == "RUNNING" {
				return nil
			}
		}

		now := time.Now()
		if now.After(until) {
			return bosherr.Errorf("Power on virtual guest with id %d Time Out!", *virtualGuest.Id)
		}

		min := math.Min(float64(10.0), float64(until.Sub(now)))
		time.Sleep(time.Duration(min) * time.Second)
	}
}
func ( c * ClientManager ) WaitInstanceUntilReady ( id int , until time . Time ) error { for { virtualGuest , found , err := c . GetInstance ( id , " " ) if err != nil { return err } if ! found { return bosherr . WrapErrorf ( err , " " , id ) } lastReload := virtualGuest . LastOperatingSystemReload activeTxn := virtualGuest . ActiveTransaction provisionDate := virtualGuest . ProvisionDate // if lastReload != nil && lastReload.ModifyDate != nil { // 	fmt.Println("lastReload: ", (*lastReload.ModifyDate).Format(time.RFC3339)) // } // if activeTxn != nil && activeTxn.TransactionStatus != nil && activeTxn.TransactionStatus.Name != nil { // 	fmt.Println("activeTxn: ", *activeTxn.TransactionStatus.Name) // } // if provisionDate != nil { // 	fmt.Println("provisionDate: ", (*provisionDate).Format(time.RFC3339)) // } reloading := activeTxn != nil && lastReload != nil && * activeTxn . Id == * lastReload . Id if provisionDate != nil && ! reloading { // fmt.Println("power state:", *virtualGuest.PowerState.KeyName) if * virtualGuest . PowerState . KeyName == " " { return nil } } now := time . Now ( ) if now . After ( until ) { return bosherr . Errorf ( " " , * virtualGuest . Id ) } min := math . Min ( float64 ( 10.0 ) , float64 ( until . Sub ( now ) ) ) time . Sleep ( time . Duration ( min ) * time . Second ) } }
// Check the virtual server instance is ready for use
Check the virtual server instance is ready for use