コード例 #1
0
 /**
  * Helper function to resolve reference to another machine.
  *
  * @param $reference_name    Name of the reference in AbstractMachine::references.
  * @param $properties_cache  Properties of referencing machine.
  * @return Reference to referred machine.
  */
 protected function resolveMachineReference($reference_name, $properties_cache)
 {
     if (!isset($this->references[$reference_name])) {
         throw new \InvalidArgumentException('Unknown reference: ' . $reference_name);
     }
     // Get reference configuration
     $r = $this->references[$reference_name];
     // Get referenced machine id
     $ref_machine_id = array();
     foreach ($r['machine_id'] as $mid_prop) {
         $ref_machine_id[] = $properties_cache[$mid_prop];
     }
     // Get referenced machine type
     $ref_machine_type = $r['machine_type'];
     return new Reference($this->backend->getMachine($ref_machine_type), $ref_machine_id);
 }