protected function run1($stage)
{
$platform = SERVER_PLATFORMS::EC2;
$platformModule = PlatformFactory::NewPlatform($platform);
/* @var $platformModule Ec2PlatformModule*/
$instanceTypes = $platformModule->getInstanceTypes(null, null, true);
$result = $this->db->Execute("\n SELECT s.server_id, s.`type`, sp.`value` AS vcpus\n FROM servers AS s\n LEFT JOIN server_properties sp ON sp.`server_id`= s.`server_id` AND sp.`name` = ?\n WHERE s.`status` NOT IN (?, ?)\n AND s.`type` IS NOT NULL\n AND s.`platform` = ?\n ", [Server::INFO_INSTANCE_VCPUS, Server::STATUS_PENDING_TERMINATE, Server::STATUS_TERMINATED, $platform]);
while ($row = $result->FetchRow()) {
if (!empty($row["type"]) && empty($row['vcpus'])) {
if (isset($instanceTypes[$row['type']]['vcpus']) && $instanceTypes[$row['type']]['vcpus'] > 0) {
$this->db->Execute("\n INSERT INTO server_properties (`server_id`, `name`, `value`) VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE `value` = ?\n ", [$row["server_id"], Server::INFO_INSTANCE_VCPUS, $instanceTypes[$row['type']]['vcpus'], $instanceTypes[$row['type']]['vcpus']]);
}
}
}
}