Hi so the logic will be like bellow :- a)Start to read the file, b)start a line which start with "3600601" c) Iterate through the line till i see another line which starts with "3600601" d) read the last line before 3600601 e)cut all the path and create a dictionary which will have one key (LUN ID 3600601 ) and multiple values (PATH *0:0:0:129,**1:0:0:129,*0:0:2:129,1:0:2:129)
f) then look up each dictinary by Values(*0:0:0:129) * to get the required LUN ID does the logic sound right ? mpathdz (360060165656565634348a739e511) dm-134 DGC,VRAID size=200G features='0' hwhandler='1 alua' wp=rw |*-+- policy='round-robin 0' prio=130 status=active *|* |- 0:0:0:129 sddz 128:16 active ready running *|* `- 1:0:0:129 sdwd 69:656 active ready running *`-+- policy='round-robin 0' prio=10 status=enabled |- 0:0:2:129 sdnd 70:496 active ready running `- 1:0:2:129 sdafg 68:864 active ready running mpathcu (3600601323h42h2k323asdf33511) dm-103 DGC,VRAID size=200G features='0' hwhandler='1 alua' wp=rw |*-+- policy='round-robin 0' prio=130 status=active *|* |- 1:0:2:98 sdaeb 66:880 active ready running *|* `- 0:0:2:98 sdly 69:256 active ready running *`-+- policy='round-robin 0' prio=10 status=enabled |- 0:0:0:98 sdcu 70:32 active ready running `- 1:0:0:98 sduy 67:672 active ready running mpathbp (36003434343eere8b69e411) dm-36 DGC,RAID 5 size=100G features='0' hwhandler='1 alua' wp=rw |*-+- policy='round-robin 0' prio=130 status=active *|* |- 0:0:0:68 sdbq 68:64 active ready running *|* `- 1:0:0:68 sdtu 65:704 active ready running *`-+- policy='round-robin 0' prio=10 status=enabled |- 0:0:2:68 sdku 67:288 active ready running `- 1:0:2:68 sdacx 8:912 active ready running On Mon, Jan 4, 2016 at 11:54 PM, David Rock <[email protected]> wrote: > * Fosiul Alam <[email protected]> [2016-01-04 22:29]: > > Hi Expert, > > I am learning python to do some system admin code, i am still in the > > process of learning but I need a help on bellow code in urgent, i will be > > really greatfull for any help > > > > Basically i wanted like this :- > > > > grep a line which has 1:0:0:129 , and get the LUN number(i.e > > 360060165656565634348a739e511) for this path > > > > so the Dictionalry will be : > > > > dict = {'360060165656565634348a739e511': '1:0:0:129', > > '3600601323h42h2k323asdf33511': 1:0:2:98}; > > > > > > How can i do this ? > > based on your multipath output, one thing you have to take into account > is that the LUN value comes before the SCSI value. You are going to > have to walk the file and for each mpath line, create a dict, then add > your SCSI values to that entry. You will have to find a way to break > out of your logic when the next mpath is seen. > > You will also want to think about what to do with all your LUNs. You > have four per mpath, not one. Do you want to capture only one, or do > you need all of them? > > -- > David Rock > [email protected] > _______________________________________________ > Tutor maillist - [email protected] > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > -- Regards Fosiul Alam _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
