lib/ohai/mixin/scaleway_metadata.rb in ohai-15.0.35 vs lib/ohai/mixin/scaleway_metadata.rb in ohai-15.1.3
- old
+ new
@@ -12,17 +12,17 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-require "net/http"
+require "net/http" unless defined?(Net::HTTP)
module Ohai
module Mixin
module ScalewayMetadata
- SCALEWAY_METADATA_ADDR = "169.254.42.42".freeze unless defined?(SCALEWAY_METADATA_ADDR)
- SCALEWAY_METADATA_URL = "/conf?format=json".freeze unless defined?(SCALEWAY_METADATA_URL)
+ SCALEWAY_METADATA_ADDR ||= "169.254.42.42".freeze
+ SCALEWAY_METADATA_URL ||= "/conf?format=json".freeze
# @return [Net::HTTP] net/http object without timeout set to 6
def http_client
Net::HTTP.start(SCALEWAY_METADATA_ADDR).tap { |h| h.read_timeout = 6 }
end