Saturday, July 12, 2025
Social icon element need JNews Essential plugin to be activated.
No Result
View All Result
Crypto now 24
  • HOME
  • BITCOIN
  • CRYPTO UPDATES
    • GENERAL
    • ALTCOINS
    • ETHEREUM
    • CRYPTO EXCHANGES
    • CRYPTO MINING
  • BLOCKCHAIN
  • NFT
  • DEFI
  • METAVERSE
  • WEB3
  • REGULATIONS
  • SCAMS
  • ANALYSIS
  • VIDEOS
MARKETCAP
  • HOME
  • BITCOIN
  • CRYPTO UPDATES
    • GENERAL
    • ALTCOINS
    • ETHEREUM
    • CRYPTO EXCHANGES
    • CRYPTO MINING
  • BLOCKCHAIN
  • NFT
  • DEFI
  • METAVERSE
  • WEB3
  • REGULATIONS
  • SCAMS
  • ANALYSIS
  • VIDEOS
No Result
View All Result
Crypto now 24
No Result
View All Result

Using the metadata service to identify disks in your VSI with IBM Cloud VPC

June 12, 2023
in Blockchain
Reading Time: 4 mins read
A A
0

[ad_1]

A typical use case within the cloud is attaching/eradicating volumes dynamically. Figuring out the connected disk machine within the working system of the VSI will not be at all times apparent.




In IBM Cloud Digital Server for VPC, the disk that’s connected to the VSI is recognized by the quantity attachment identifier. Each quantity has a UUID, however the attachment between the quantity and the VSI additionally has a UUID. The UUID of that quantity attachment is what can be utilized to establish the backing disk within the VSI.




UI-based instance




Itemizing the quantity attachment identifiers is easy with the ibmcloud CLI:


Drews-MBP ~ % ibmcloud is in-vols 0727_fa4230b2-e167-4a09-8d7c-2822bdb016bf
Itemizing quantity attachments of occasion 0727_fa4230b2-e167-4a09-8d7c-2822bdb016bf underneath account Drew Thorstensen’s Account as consumer thorst@us.ibm.com…
ID Identify Quantity Standing Kind Gadget Auto delete
0727-7db66159-5910-4ddc-a5b4-51f9333a9c3a secrecy-robust-anyone-agile test-metadata-volume connected information 0727-7db66159-5910-4ddc-a5b4-51f9333a9c3a-4xjjc false
0727-4b98cbf2-4e57-4b3b-9bd2-83f2439da3bc breath-manger-bird-axiom test-metadata-boot-1649335137000 connected boot 0727-4b98cbf2-4e57-4b3b-9bd2-83f2439da3bc-5jx6t true





This reveals two volumes connected to the VSI: the boot after which a knowledge quantity. If we log in to the VSI, we will see the quantity disks:





[root@test-metadata ~]# ls -la /dev/disk/by-id
complete 0
drwxr-xr-x. 2 root root 200 Apr 7 12:58 .
drwxr-xr-x. 7 root root 140 Apr 7 12:51 ..
lrwxrwxrwx. 1 root root 9 Apr 7 12:52 virtio-0727-4b98cbf2-4e57-4 -> ../../vda
lrwxrwxrwx. 1 root root 10 Apr 7 12:52 virtio-0727-4b98cbf2-4e57-4-part1 -> ../../vda1
lrwxrwxrwx. 1 root root 10 Apr 7 12:52 virtio-0727-4b98cbf2-4e57-4-part2 -> ../../vda2
lrwxrwxrwx. 1 root root 10 Apr 7 12:52 virtio-0727-4b98cbf2-4e57-4-part3 -> ../../vda3
lrwxrwxrwx. 1 root root 9 Apr 7 12:58 virtio-0727-7db66159-5910-4 -> ../../vdd
lrwxrwxrwx. 1 root root 10 Apr 7 12:58 virtio-0727-7db66159-5910-4-part1 -> ../../vdd1
lrwxrwxrwx. 1 root root 9 Apr 7 12:52 virtio-cloud-init- -> ../../vdc
lrwxrwxrwx. 1 root root 9 Apr 7 12:52 virtio-cloud-init-0727_fa42 -> ../../vdb


If we need to discover the information quantity named test-metadata-volume, we see that it’s the vdd disk. The primary 20 characters of the quantity attachment identifier are used for the disk id. The symbolic hyperlink reveals us the title of the disk that it maps to, as effectively.




Simplifying with the metadata service




Most customers are in search of a faster option to establish the disk title, and these customers will even possible be beginning with the quantity somewhat than the quantity attachment. Luckily, that is simple to do.




Just lately, IBM Cloud VPC launched the metadata service. This functionality permits the tip consumer to question information about itself and get identification tokens and extra from the VSI. One of many use circumstances it will probably assist with helps simplify getting the disk title based mostly off a quantity title.




The steps to search out the disk title inside a VSI from a given quantity are as follows:






Deploy the VSI with metadata turned on



Get an occasion identification token



Question the metadata service to record the quantity attachments



Discover the quantity attachment that has the quantity specified



Search for the disk title based mostly off the quantity attachment



Connected to this put up is a script that can be utilized to retrieve the disk title for a given quantity UUID (not the attachment UUID). The next is the pattern output:





[root@test-metadata ~]# python3 scripts/find_disk.py -v 0727-7db66159-5910-4ddc-a5b4-51f9333a9c3a-4xjjc
vdd


On this case, the disk is known as vdd throughout the VSI for quantity 0727-7db66159-5910-4ddc-a5b4-51f9333a9c3a-4xjjc.




Code




The next code might be embedded into your occasion or consumer information to assist shortly establish disk names throughout the VSI given the quantity UUID.  Be sure you keep in mind that the metadata service should be operating for this to work correctly:





# ======================================================================
# Copyright 2022 IBM Corp.
#
# Licensed underneath the Apache License, Model 2.0 (the “License”);
# you could not use this file besides in compliance with the License.
# You might receive a duplicate of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Until required by relevant regulation or agreed to in writing, software program
# distributed underneath the License is distributed on an “AS IS” BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, both categorical or implied.
# See the License for the particular language governing permissions and
# limitations underneath the License.
# ======================================================================

import argparse
import json
import os
import requests
import sys

def init_argparse():
parser = argparse.ArgumentParser(
description=(“Finds an area disk by UUID”)
)
parser.add_argument(“-v”, “–volume-uuid”, required=True,
assist=(“The quantity UUID.”))

return parser.parse_args()

def get_token():
outcome = requests.put(“http://169.254.169.254/instance_identity/v1/token?model=2021-10-12”,
headers={‘Metadata-Taste’: ‘ibm’})
return json.hundreds(outcome.textual content)[‘access_token’]

def get_volume_attachments(access_token):
outcome = requests.get(“http://169.254.169.254/metadata/v1/occasion/volume_attachments?model=2021-10-12″,
headers={‘Authorization’: f”Bearer {access_token}”})
return json.hundreds(outcome.textual content)[‘volume_attachments’]

def get_disk_device(attachment_uuid):
expected_path = f’/dev/disk/by-id/virtio-{attachment_uuid[:20]}’
full_path = os.path.realpath(expected_path)
return full_path.break up(‘/’)[-1]

def major():
args = init_argparse()
access_token = get_token()
volume_attachments = get_volume_attachments(access_token)
for volume_attachment in volume_attachments:
if volume_attachment[‘device’][‘id’] == args.volume_uuid:
print(get_disk_device(volume_attachment[‘id’]))
sys.exit(0)
else:
print(f”Unable to search out disk by quantity {args.volume_uuid}”)
sys.exit(1)

if __name__ == ‘__main__’:
major()


Conclusion




The metadata service is a strong service that makes it simple for a given occasion to assemble details about itself. While not having to name out to any API, customers can detect the disk title from throughout the VSI for a given quantity UUID. These scripts might be prolonged to assist extra use circumstances, together with trying up the volumes and community interfaces.




To be taught extra about IBM Cloud VPC, please go to our web site. You may also get USD 1,000 in credit to make use of towards any of your new VPC sources – together with all compute, community and storage parts.





Apply the VPC1000 code

STSM – IBM Cloud VPC Gen 2

[ad_2]

Source link

Tags: ClouddisksIBMidentifymetadataServiceVPCVSI
Previous Post

BitGo’s Lawsuit Against Galaxy Digital Over $1.2B Merger Dismissed

Next Post

Tether treasury sends Binance $750M USDT in chain swap transaction

Next Post
Tether treasury sends Binance $750M USDT in chain swap transaction

Tether treasury sends Binance $750M USDT in chain swap transaction

5G network rollout using DevOps: Myth or reality?

5G network rollout using DevOps: Myth or reality?

Without these three crucial “transitions,” Ethereum “fails,” according to Vitalik Buterin

Without these three crucial “transitions,” Ethereum “fails,” according to Vitalik Buterin

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Social icon element need JNews Essential plugin to be activated.

CATEGORIES

  • Altcoin
  • Analysis
  • Bitcoin
  • Blockchain
  • Crypto Exchanges
  • Crypto Mining
  • Crypto Updates
  • DeFi
  • Ethereum
  • Metaverse
  • NFT
  • Regulations
  • Scam Alert
  • Uncategorized
  • Videos
  • Web3

SITE MAP

  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2023 Crypto Now 24.
Crypto Now 24 is not responsible for the content of external sites.

No Result
View All Result
  • HOME
  • BITCOIN
  • CRYPTO UPDATES
    • GENERAL
    • ALTCOINS
    • ETHEREUM
    • CRYPTO EXCHANGES
    • CRYPTO MINING
  • BLOCKCHAIN
  • NFT
  • DEFI
  • METAVERSE
  • WEB3
  • REGULATIONS
  • SCAMS
  • ANALYSIS
  • VIDEOS

Copyright © 2023 Crypto Now 24.
Crypto Now 24 is not responsible for the content of external sites.