virtual machine - PHP: Error in creating Server Instance in Google Cloud Compute -


while using google cloud compute's api in php, able start, stop, delete instances create , delete disks.

however, when trying create instance, keep getting error

invalid value field 'resource.disks'

php fatal error:  uncaught exception 'google_service_exception' message 'error calling post https://www.googleapis.com/compute/v1/projects/project/zones/zone/instances: (400) invalid value field 'resource.disks': ''.  boot disk must specified.' in /var/www/html/google/google-api-php-client/src/google/http/rest 

here request making

self::connectclient();  $computeservice = new google_service_compute($this->client);  if ($this->client->getaccesstoken())  {     $googlenetworkinterfaceobj = new google_service_compute_networkinterface();     $network = self::default_network;     $googlenetworkinterfaceobj->setnetwork($network);      $diskobj = self::getdisk($instance_name);      $new_instance = new google_service_compute_instance();     $new_instance->setname($instance_name);     $new_instance->setmachinetype(self::default_machine_type);     $new_instance->setnetworkinterfaces(array($googlenetworkinterfaceobj));     $new_instance->setdisks(array(                     "source"=>$diskobj->selflink,                     "boot"=>true,                     "type"=>"persistent",                     "devicename"=>$diskobj->name,                    ));     $insertinstance = $computeservice->instances->insert(self::default_project,self::default_zone_name, $new_instance); 

any highly appreciated, thank you.

ok solution simple (and silly)

instead of

$new_instance->setdisks(array(                     "source"=>$diskobj->selflink,                     "boot"=>true,                     "type"=>"persistent",                     "devicename"=>$diskobj->name,                    )); 

it's supposed

$new_instance->setdisks(array(          array(             'source'=>self::getdisk($instance_name)->selflink,             'boot'=>true,             'type' => "persistent",             'devicename'=>self::getdisk($instance_name)->name,             )           )); 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -