Exemplo n.º 1
0
 /**
  * Save an image that is associated with a generalized virtual machine.
  *
  * @param string          $subscriptionId           Subscription Id
  * @param string          $resourceGroup            Name of Resource Group
  * @param string          $name                     Name of the Virtual Machine
  * @param array|SaveImage $requestData              Request data
  *
  * @return string Returns image uri
  */
 public function saveImage($subscriptionId, $resourceGroup, $name, $requestData)
 {
     if (!$requestData instanceof SaveImage) {
         $requestData = SaveImage::initArray($requestData);
     }
     $path = '/subscriptions/' . $subscriptionId . '/resourceGroups/' . $resourceGroup . ComputeService::ENDPOINT_MICROSOFT_COMPUTE . '/virtualMachines/' . $name . '/capture';
     $request = $this->getClient()->prepareRequest($path, 'POST', $this->getApiVersion(), $this->getServiceUrl(), [], $requestData->toArray());
     $response = $this->getClient()->call($request);
     $response = $this->getClient()->waitFinishingProcess($response, $this->getServiceUrl(), $this->getApiVersion());
     $imageUri = null;
     if (!$response->hasError()) {
         $resource = $response->getResult();
         if (!empty($resource['resources'])) {
             $vmData = VirtualMachineData::initArray(reset($resource['resources']));
             /* @var $vmData VirtualMachineData */
             if (!empty($vmData->properties->storageProfile->osDisk->image)) {
                 $imageUri = $vmData->properties->storageProfile->osDisk->image['uri'];
             }
         }
     }
     return $imageUri;
 }
Exemplo n.º 2
0
 /**
  * Sets virtual machine
  *
  * @param   array|VirtualMachineData $virtualMachine
  * @return  InterfaceProperties
  */
 public function setProperties($virtualMachine = null)
 {
     if (!$virtualMachine instanceof VirtualMachineData) {
         $virtualMachine = VirtualMachineData::initArray($virtualMachine);
     }
     return $this->__call(__FUNCTION__, [$virtualMachine]);
 }