public function createImageEntity()
{
$snapshot = $this->getSnapshotDetails();
$image = new Image();
$image->id = $this->snapshotId;
$image->accountId = $this->clientId;
$image->envId = $this->envId;
$image->bundleTaskId = $this->id;
$image->platform = $this->platform;
$image->cloudLocation = $this->cloudLocation;
$image->createdById = $this->createdById;
$image->createdByEmail = $this->createdByEmail;
$image->architecture = is_null($snapshot['os']->arch) ? 'x86_64' : $snapshot['os']->arch;
$image->source = Image::SOURCE_BUNDLE_TASK;
$image->status = Image::STATUS_ACTIVE;
$image->agentVersion = $snapshot['szr_version'];
$image->isScalarized = 1;
$image->hasCloudInit = 0;
$image->checkImage();
if (!$image->name) {
$image->name = $this->roleName . '-' . date('YmdHi');
}
// before checkImage we should set current envId, so that request to cloud could fill required fields, after that set correct envId
if ($this->objectScope == ScopeInterface::SCOPE_ACCOUNT) {
$image->envId = null;
}
$image->osId = $this->osId;
$image->save();
if ($snapshot['software']) {
$software = [];
foreach ((array) $snapshot['software'] as $soft) {
$software[$soft->name] = $soft->version;
}
$image->setSoftware($software);
}
return $image;
}