|
1 | | -#!/usr/bin/env python2.7 |
| 1 | +#!/usr/bin/env python |
2 | 2 |
|
3 | 3 | # Copyright 2017 Amazon.com, Inc. and its affiliates. All Rights Reserved. |
4 | 4 | # |
@@ -106,26 +106,26 @@ class ebs_nvme_device: |
106 | 106 | alen = id_len, |
107 | 107 | cdw10 = 1) |
108 | 108 |
|
109 | | - with open(self.device, "rw") as nvme: |
| 109 | + with open(self.device, "r+") as nvme: |
110 | 110 | ioctl(nvme, NVME_IOCTL_ADMIN_CMD, admin_cmd) |
111 | 111 |
|
112 | 112 | def ctrl_identify(self): |
113 | 113 | self.id_ctrl = nvme_identify_controller() |
114 | 114 | self._nvme_ioctl(addressof(self.id_ctrl), sizeof(self.id_ctrl)) |
115 | 115 |
|
116 | | - if self.id_ctrl.vid != AMZN_NVME_VID or self.id_ctrl.mn.strip() != AMZN_NVME_EBS_MN: |
| 116 | + if self.id_ctrl.vid != AMZN_NVME_VID or self.id_ctrl.mn.decode().strip() != AMZN_NVME_EBS_MN: |
117 | 117 | raise TypeError("[ERROR] Not an EBS device: '{0}'".format(self.device)) |
118 | 118 |
|
119 | 119 | def get_volume_id(self): |
120 | | - vol = self.id_ctrl.sn |
| 120 | + vol = self.id_ctrl.sn.decode() |
121 | 121 |
|
122 | 122 | if vol.startswith("vol") and vol[3] != "-": |
123 | 123 | vol = "vol-" + vol[3:] |
124 | 124 |
|
125 | 125 | return vol |
126 | 126 |
|
127 | 127 | def get_block_device(self, stripped=False): |
128 | | - dev = self.id_ctrl.vs.bdev.strip() |
| 128 | + dev = self.id_ctrl.vs.bdev.decode().strip() |
129 | 129 |
|
130 | 130 | if stripped and dev.startswith("/dev/"): |
131 | 131 | dev = dev[5:] |
@@ -155,10 +155,10 @@ if __name__ == "__main__": |
155 | 155 | try: |
156 | 156 | dev = ebs_nvme_device(args.device[0]) |
157 | 157 | except (IOError, TypeError) as err: |
158 | | - print >> sys.stderr, err |
| 158 | + print(err, file=sys.stderr) |
159 | 159 | sys.exit(1) |
160 | 160 |
|
161 | 161 | if get_all or args.volume: |
162 | | - print "Volume ID: {0}".format(dev.get_volume_id()) |
| 162 | + print("Volume ID: {0}".format(dev.get_volume_id())) |
163 | 163 | if get_all or args.block_dev or args.udev: |
164 | | - print dev.get_block_device(args.udev) |
| 164 | + print(dev.get_block_device(args.udev)) |
0 commit comments