lib/ohai/mixin/azure_metadata.rb in ohai-15.0.35 vs lib/ohai/mixin/azure_metadata.rb in ohai-15.1.3
- old
+ new
@@ -13,17 +13,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 AzureMetadata
- AZURE_METADATA_ADDR = "169.254.169.254".freeze unless defined?(AZURE_METADATA_ADDR)
- AZURE_METADATA_URL = "/metadata/instance?api-version=2017-08-01".freeze unless defined?(AZURE_METADATA_URL)
+ AZURE_METADATA_ADDR ||= "169.254.169.254".freeze
+ AZURE_METADATA_URL ||= "/metadata/instance?api-version=2017-08-01".freeze
# fetch the meta content with a timeout and the required header
def http_get(uri)
conn = Net::HTTP.start(AZURE_METADATA_ADDR)
conn.read_timeout = 6