Article 54SFD replacing contents based on output

replacing contents based on output

by
gurukr040
from LinuxQuestions.org on (#54SFD)
Hello.
I execute 'k get bd' and get below output.Also another file in my repo 'file.yaml' which has entries like below.
Need to read the output of 2nd column and replace entries in the file.yaml at "testing.in/hostname" and 1st column with "blockDeviceName".
The required file that should be after modification is "file2.yaml".
Any suggestions or help.It should read each value from the command output and edit the same in file.yaml.

NAME NODE
blockdevice-0c008888888888888433c50 drac-1
blockdevice-999999fc000c90d8ae958b4 drac-2
blockdevice-e2979399960ad81255413cc drac-3
blockdevice-78787878787878f6a4842cc drac-4

file.yaml:

- nodeSelector:
testing.in/hostname: "machine1"
RaidMember:
- blockDevice:
- blockDeviceName: "blockdevice-0fggh44445555556"
matrixConfig:
dataRaidGroupType: "raid"
- nodeSelector:
testing.in/hostname: "machine2"
RaidMember:
- blockDevice:
- blockDeviceName: "blockdevice-9090908124667899"
matrixConfig:
dataRaidGroupType: "raid"

file2.yaml

- nodeSelector:
testing.in/hostname: "drac-1"
RaidMember:
- blockDevices:
- blockDeviceName: "blockdevice-0c008888888888888433c50"
matrixConfig:
dataRaidGroupType: "raid"
- nodeSelector:
testing.in/hostname: "drac-2"
RaidMember:
- blockDevices:
- blockDeviceName: "blockdevice-999999fc000c90d8ae958b4"
matrixConfig:
dataRaidGroupType: "raid"latest?d=yIl2AUoC8zA latest?i=CP4Q_HvnIOY:Jcl8gJiN1BQ:F7zBnMy latest?i=CP4Q_HvnIOY:Jcl8gJiN1BQ:V_sGLiP latest?d=qj6IDK7rITs latest?i=CP4Q_HvnIOY:Jcl8gJiN1BQ:gIN9vFwCP4Q_HvnIOY
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments