Scalr\Server\Import\Platforms\Ec2ServerImport::importServer PHP Méthode

importServer() protected méthode

See also: AbstractServerImport::importServer
protected importServer ( )
    protected function importServer()
    {
        $aws = $this->farmRole->getFarm()->getEnvironment()->aws($this->farmRole->cloudLocation);
        try {
            $instance = $this->instance = $aws->ec2->instance->describe($this->orphaned->cloudServerId)->get(0)->instancesSet->get(0);
            $this->server->properties[EC2_SERVER_PROPERTIES::AVAIL_ZONE] = $instance->placement->availabilityZone;
            $this->server->properties[EC2_SERVER_PROPERTIES::ARCHITECTURE] = $instance->architecture;
            $this->server->cloudLocationZone = $instance->placement->availabilityZone;
            $this->server->setOs($instance->platform ? $instance->platform : 'linux');
            $this->server->properties[EC2_SERVER_PROPERTIES::INSTANCE_ID] = $this->orphaned->cloudServerId;
            $this->server->properties[EC2_SERVER_PROPERTIES::VPC_ID] = $this->orphaned->vpcId;
            $this->server->properties[EC2_SERVER_PROPERTIES::SUBNET_ID] = $this->orphaned->subnetId;
            $this->server->properties[EC2_SERVER_PROPERTIES::REGION] = $this->server->cloudLocation;
            $this->server->properties[EC2_SERVER_PROPERTIES::AMIID] = $this->server->imageId;
            $this->server->instanceTypeName = $this->server->type;
            $p = PlatformFactory::NewPlatform(SERVER_PLATFORMS::EC2);
            $instanceTypeInfo = $p->getInstanceType($this->orphaned->instanceType, (new \Scalr_Environment())->loadById($this->server->envId), $this->server->cloudLocation);
            $this->server->properties[Entity\Server::INFO_INSTANCE_VCPUS] = isset($instanceTypeInfo['vcpus']) ? $instanceTypeInfo['vcpus'] : null;
        } catch (Exception $e) {
            throw new ServerImportException(sprintf('Scalr was unable to retrieve details for instance %s: %s', $this->orphaned->cloudServerId, $e->getMessage()), $e->getCode(), $e);
        }
    }