Copy-paste from https://github.com/Mirantis/fuelweb/pull/1494/files#L0R87. Use DRY principle.