Tuesday, October 3, 2023
DAPPS CLUB
  • Home
  • Cryptocurrency
  • Bitcoin
  • Ethereum
  • Blockchain
  • Altcoin
  • Litecoin
  • Metaverse
  • NFt
  • Regulations
No Result
View All Result
DAPPS CLUB
No Result
View All Result
Home Blockchain

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

Lincoln Cavenagh by Lincoln Cavenagh
June 13, 2023
in Blockchain
0
Using the metadata service to identify disks in your VSI with IBM Cloud VPC
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter


ttps://www.ibm.com/weblog/using-the-metadata-service-to-identify-disks-in-your-vsi-with-ibm-cloud-vpc/”http://www.w3.org/TR/REC-html40/unfastened.dtd”>

A typical use case within the cloud is attaching/eradicating volumes dynamically. Figuring out the hooked up disk machine within the working system of the VSI is just not all the time apparent.

Related posts

Operationalize automation for faster, more efficient incident resolution at a lower cost

Operationalize automation for faster, more efficient incident resolution at a lower cost

October 3, 2023
FTX Customers Remain Bullish on Crypto despite Losing Fortunes

FTX Customers Remain Bullish on Crypto despite Losing Fortunes

October 3, 2023




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




UI-based instance




Itemizing the amount 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 person thorst@us.ibm.com...
ID                                          Identify                          Quantity                             Standing     Sort   System                                            Auto delete   
0727-7db66159-5910-4ddc-a5b4-51f9333a9c3a   secrecy-robust-anyone-agile   test-metadata-volume               hooked up   knowledge   0727-7db66159-5910-4ddc-a5b4-51f9333a9c3a-4xjjc   false   
0727-4b98cbf2-4e57-4b3b-9bd2-83f2439da3bc   breath-manger-bird-axiom      test-metadata-boot-1649335137000   hooked up   boot   0727-4b98cbf2-4e57-4b3b-9bd2-83f2439da3bc-5jx6t   true   






This exhibits two volumes hooked up to the VSI: the boot after which a knowledge quantity. If we log in to the VSI, we are able to see the amount 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 wish to discover the information quantity named test-metadata-volume, we see that it’s the vdd disk. The primary 20 characters of the amount attachment identifier are used for the disk id. The symbolic hyperlink exhibits us the identify of the disk that it maps to, as nicely.




Simplifying with the metadata service




Most customers are in search of a faster option to determine the disk identify, and these customers may also probably be beginning with the amount reasonably than the amount attachment. Thankfully, that is straightforward to do.




Lately, IBM Cloud VPC launched the metadata service. This functionality permits the tip person to question knowledge about itself and get id tokens and extra from the VSI. One of many use instances it might probably assist with helps simplify getting the disk identify primarily based off a quantity identify.




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




  • Deploy the VSI with metadata turned on



  • Get an occasion id token



  • Question the metadata service to record the amount attachments



  • Discover the amount attachment that has the amount specified



  • Lookup the disk identify primarily based off the amount attachment

Hooked up to this put up is a script that can be utilized to retrieve the disk identify 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 called vdd throughout the VSI for quantity 0727-7db66159-5910-4ddc-a5b4-51f9333a9c3a-4xjjc.




Code




The next code could be embedded into your occasion or person knowledge to assist rapidly determine disk names throughout the VSI given the amount UUID.  Remember to do not forget that the metadata service have to 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 acquire a replica of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#    Except required by relevant legislation 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 specific 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 a neighborhood 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.cut 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 seek 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 straightforward for a given occasion to assemble details about itself. Without having to name out to any API, customers can detect the disk identify from throughout the VSI for a given quantity UUID. These scripts could be prolonged to help extra use instances, together with wanting up the volumes and community interfaces.




To be taught extra about IBM Cloud VPC, please visit our website. You too can get USD 1,000 in credit to make use of towards any of your new VPC assets – together with all compute, community and storage parts.





Apply the VPC1000 code

STSM – IBM Cloud VPC Gen 2



Source link

Tags: ClouddisksIBMidentifymetadataServiceVPCVSI
Previous Post

IBM Tech Now: June 12, 2023

Next Post

Gary Gensler’s War on Crypto in US Will Put Off Young Voters, Cameron Winklevoss Says

Next Post
Gary Gensler’s War on Crypto in US Will Put Off Young Voters, Cameron Winklevoss Says

Gary Gensler’s War on Crypto in US Will Put Off Young Voters, Cameron Winklevoss Says

RECOMMENDED NEWS

Prime Trust Files for Bankruptcy Protection amidst Financial Struggles

Prime Trust Files for Bankruptcy Protection amidst Financial Struggles

2 months ago
Stellar Development Foundation Invests in Franklin OnChain US Government Money Fund

Stellar Development Foundation Invests in Franklin OnChain US Government Money Fund

5 months ago
Crypto Analyst Warns Chainlink Positioning for Downside Move, Updates Outlook on Bitcoin and Dogecoin

Crypto Analyst Warns Chainlink Positioning for Downside Move, Updates Outlook on Bitcoin and Dogecoin

2 months ago
Strike Relocates Global Headquarters To El Salvador, Expands Presence To 65 Countries

Strike Relocates Global Headquarters To El Salvador, Expands Presence To 65 Countries

5 months ago

FOLLOW US

BROWSE BY CATEGORIES

  • Altcoin
  • Altcoin News
  • Altcoins
  • Artificial Intelligence
  • Bitcoin
  • Blockchain
  • Blockchain Games
  • Business
  • Crypto
  • Cryptocurrencies
  • Cryptocurrency
  • Culture
  • Defi
  • Economy
  • Education
  • Entertainment
  • Ethereum
  • Featured
  • Gambling
  • Governance
  • Health
  • Lifestyle
  • Litecoin
  • Market
  • Metaverse
  • News
  • NFt
  • Regulations
  • Uncategorized
  • Web 3.0
  • World

BROWSE BY TOPICS

Altcoin Analyst Bank Binance Bitcoin Blockchain Blog BTC Bullish Business CEO Cloud Coinbase Crypto Cryptocurrency Data Digital DOGEcoin ETF ETH Ethereum Exchange Foundation Halving Heres High IBM Investors Launch Launches Litecoin LTC Market Network NFT Price Rally regulatory REPORT Ripple SEC Solana Top Trading XRP

POPULAR NEWS

  • YOM brings Metaverse Mining to the Masses with MEXC Listing

    YOM brings Metaverse Mining to the Masses with MEXC Listing

    0 shares
    Share 0 Tweet 0
  • What is Cloud Mining and How Does it Work?

    0 shares
    Share 0 Tweet 0
  • Litecoin Price Prediction Gains Bearish Outlook After LTC Halving

    0 shares
    Share 0 Tweet 0
  • Educators Remain Metaverse Positive Despite Negative Media Spin

    0 shares
    Share 0 Tweet 0
  • New York Bans Crypto Exchange CoinEx and Seizes More than $1.7M

    0 shares
    Share 0 Tweet 0
Crypto markets by TradingView
Cryptocurrency Prices 

Recommended

  • Security AI and automation are key in protecting against costly data breaches for retailers and consumer goods businesses
  • Ethereum News: Solana Co-Founder Accuses ETH Of ‘Bourgeois Digital Tyranny’
  • Litecoin (LTC), 100 dolara ulaşabilecek mi? • Coinkolik

© 2023 Dapps Club | All Rights Reserved

No Result
View All Result
  • Home
  • Cryptocurrency
  • Bitcoin
  • Ethereum
  • Blockchain
  • Altcoin
  • Litecoin
  • Metaverse
  • NFt
  • Regulations

© 2023 Dapps Club | All Rights Reserved