replacing contents based on output
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"
|