0
votes

We have received a notification about planned migration to new hypervisors mentioning we can do such migration in SL Portal or via API.

Q: how to migrate servers by API call:

  • REST

  • slcli call-api method

Notification we received:

IBM Bluemix is extending "hot patching" capabilities for VSIs (Virtual Server Instances) in all locations. Hot patching allows the IBM Bluemix Virtual Server team to apply many software and security patches to virtual machine hosts without disrupting client workloads with a host reboot.

To provide flexibility, clients will be able to self migrate prior to the migration window either through the API or UI as noted below:

To self migrate your virtual server, go to the "Device List", which can be found under "Devices" across the top of Control Portal, and select "Actions". A "Migrate Host" should be selectable (capacity dependent).

2

2 Answers

1
votes

Using rest you can use this request:

https://$USERNAME:[email protected]/rest/v3/SoftLayer_Virtual_Guest/$VSIID/migrate

Note: replace $USERNAM , $APIKEY and $VSIID

Regards

1
votes

This is the script what we are using to migrate the VMs one by one.

You can list the migrateable VMs using this command slcli virtual list --columns id,hostname,pendingMigrationFlag | grep True and the actual migration can be done with this slcli call-api Virtual_Guest migrate "--id=$VSID"

#!/bin/bash

TYPE=${1:-server}

while :; do
  VSID=`slcli virtual list --columns id,hostname,pendingMigrationFlag | grep "$TYPE" | grep True | head -1 | cut -d ' ' -f1`;
  if [[ -n "$VSID" ]]; then
    echo "Next item to migrate: $VSID"
    slcli vs detail "$VSID"
    slcli call-api Virtual_Guest migrate "--id=$VSID"
    if [[ "$?" -eq "0" ]]; then
      echo "Waiting for the migration to complete..."
      while :; do
        sleep 5
        STATE=`slcli vs detail "$VSID" | grep active_transaction | awk '{print $2}'`
        if [ "$STATE" = "NULL" ]; then
          echo "Migration finished"
          break
        else
          echo "Current state: $STATE"
        fi
      done
    fi
  else
    echo "No vs found to migrate"
    break
  fi
done