Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

#! /usr/bin/env python 

# Copyright (c) 2008 Citrix Systems, Inc. All use and distribution of this 

# copyrighted material is governed by and subject to terms and conditions 

# as licensed by Citrix Systems, Inc. All other rights reserved. 

# Xen, XenSource and XenEnterprise are either registered trademarks or 

# trademarks of Citrix Systems, Inc. in the United States and/or other  

# countries. 

 

import sshutil 

import getpass 

import sys, os 

import re 

import time 

 

start_time = time.time() 

#IP address of the EqualLogic Storage group 

host=sys.argv[1] 

#Username of the group admin user of the EqualLogic Storage group 

user = sys.argv[2] 

#EqualLogic Storage group CLI command to be executed: Example: "vol show" 

#to be specified as a string in quotes. 

command = sys.argv[3] 

password = getpass.getpass() 

conn_cred = [host, user, password] 

 

conn = sshutil.SSHSession(conn_cred) 

conn.connect() 

(rc, fw_supported, errlog, errmsg) = sshutil.check_version(conn) 

if (rc): 

        print errmsg 

        for id in range(len(errlog)): 

                print errlog[id] 

else: 

        if not fw_supported : 

                print "FW version not supported" 

                sys.exit() 

 

(rc, output, errlog, errmsg) = conn.command(command) 

if (rc): 

        print errmsg 

        for id in range(len(errlog)): 

                print errlog[id] 

else: 

        for line in output: print line 

 

#Comment the next line to run the series of example test cases below. 

sys.exit() 

 

print "\nListing SR volumes" 

(rc, vol_list, errlog, errmsg) = sshutil.list_SR_vols(conn, "XenStorage") 

if (rc): 

        print errmsg 

        for id in range(len(errlog)): 

               print errlog[id] 

else: 

        print vol_list 

        for id1 in range(len(vol_list)): 

                print "\nListing snapshots for volume:%s"% vol_list[id1] 

                (rc, snap_list, errlog, errmsg) = sshutil.list_VDI_snaps(conn, vol_list[id1]) 

                if (rc): 

                        print errmsg 

                        for id2 in range(len(errlog)): 

                                print errlog[id2] 

                else: 

                        print snap_list 

                        for id3 in range(len(snap_list)): 

                            print "\nListing snapshot connection details for %s"% snap_list[id3] 

                            (rc, output, errlog, errmsg) = sshutil.snap_conn_detail(conn, vol_list[id1], snap_list[id3]) 

                            if (rc): 

                                print errmsg 

                                for id4 in range(len(errlog)): 

                                    print errlog[id4] 

                            else: 

                                print output 

#sys.exit() 

 

#set the loop count below to run the tests repeatedly to create stress 

loop_count = 1 

while True: 

    if (loop_count == 0): 

            break 

    print "\nListing all pools in the group" 

    (rc, output, errlog, errmsg) = sshutil.all_StoragePools(conn) 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

    #sys.exit() 

 

    print "\nListing pool details for default pool" 

    (rc, output, errlog, errmsg) = sshutil.pool_detail(conn, "default") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

    #sys.exit() 

 

    print "\nCreating accessvol in the SR" 

    (rc, output, iSCSIname, errlog, errmsg) = sshutil.vol_create(conn, "accessvol", "10GB", "thin", "cece3456-bad2-4fc2-9142-990d3d920fb7", "offline", 100, "volume-offline", "default") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

            print "iSCSI name: %s"% iSCSIname 

 

    initiator_name = "iqn.2006-04.com.example:4567acdb" 

    print "\nCreating access control record for accessvol with initiator %s"% initiator_name 

    (rc, output, errlog, errmsg) = sshutil.vol_create_access_rec_by_initiator(conn, "accessvol", initiator_name) 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    initiator_name = "iqn.2006-04.com.example:4567acdb" 

    print "\nDeleting access information for initiator %s from accessvol"% initiator_name 

    (rc, output, errlog, errmsg) = sshutil.vol_delete_access_rec_by_initiator(conn, "accessvol", initiator_name) 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            for id in range(len(output)): 

                    print output[id] 

    #sys.exit() 

 

    print "\nDeleting accessvol from SR" 

    (rc, output, errlog, errmsg) = sshutil.vol_delete(conn, "accessvol") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    vdi_name = "XenStorage0ff867ef31210e7c5497f5c34916727d22267eb723c04479a063" 

    print "\nCreating VDI:%s in the SR" % vdi_name 

    (rc, output, iSCSIname, errlog, errmsg) = sshutil.vol_create(conn, vdi_name, "10GB", "thin", "22267eb7-23c0-4479-a063-f5c34916727d", "offline", 100, "volume-offline", "default") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

            print "iSCSI name: %s"% iSCSIname 

 

    print "\nCreating snapshot of VDI:%s in the SR" % vdi_name 

    (rc, errlog, errmsg) = sshutil.vol_create_snapshot(conn, vdi_name, "bebe1234-bad2-4fc2-9142-990d3d920fb7", "eeff5678-bad2-4fc2-9142-990d3d92aaaa", "SNAPSHOT") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

    print "\nListing snapshots of VDI: %s"% vdi_name 

    (rc, snap_list, errlog, errmsg) = sshutil.list_VDI_snaps(conn, vdi_name) 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print snap_list 

            for id in range(len(snap_list)): 

                print "\nListing snapshot details for %s"% snap_list[id] 

                (rc, output, errlog, errmsg) = sshutil.snap_detail(conn, vdi_name, snap_list[id]) 

                if (rc): 

                    print errmsg 

                    for id in range(len(errlog)): 

                        print errlog[id] 

                else: 

                    print output 

    #sys.exit() 

 

    snapname= "XenStorage" + "bebe1234-bad2-4fc2-9142-990d3d920fb7".replace("-", "") + "eeff5678-bad2-4fc2-9142-990d3d92aaaa".replace("-", "")[:20] 

 

    print "\nDeleting snapshot of VDI:%s from SR" % vdi_name 

    (rc, output, errlog, errmsg) = sshutil.snap_delete(conn, vdi_name, snapname) 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    print "\nDeleting VDI:%s from SR" % vdi_name 

    (rc, output, errlog, errmsg) = sshutil.vol_delete(conn, vdi_name) 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    print "\nCreating bigvol in the SR" 

    (rc, output, iSCSIname, errlog, errmsg) = sshutil.vol_create(conn, "bigvol", "10GB", "thin", "bebe1234-bad2-4fc2-9142-990d3d920fb7", "offline", 100, "volume-offline", "default") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

            print "iSCSI name: %s"% iSCSIname 

 

    print "\nListing volume details for bigvol" 

    (rc, output, errlog, errmsg) = sshutil.vol_detail(conn, "bigvol") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    print "\nBringing bigvol online" 

    (rc, errlog, errmsg) = sshutil.vol_online(conn, "bigvol") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

    print "\nShrinking bigvol to 8GB" 

    (rc, errlog, errmsg) = sshutil.vol_shrink(conn, "bigvol", "8GB") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

    print "\nBringing bigvol offline" 

    (rc, errlog, errmsg) = sshutil.vol_offline(conn, "bigvol") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

    print "\nShrinking bigvol to 8GB" 

    (rc, errlog, errmsg) = sshutil.vol_shrink(conn, "bigvol", "8GB") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

 

    print "\nListing volume details for bigvol" 

    (rc, output, errlog, errmsg) = sshutil.vol_detail(conn, "bigvol") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    print "\nBringing bigvol online" 

    (rc, errlog, errmsg) = sshutil.vol_online(conn, "bigvol") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

    print "\nGrowing bigvol to 12GB" 

    (rc, errlog, errmsg) = sshutil.vol_grow(conn, "bigvol", "12GB") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

    print "\nListing volume details for bigvol" 

    (rc, output, errlog, errmsg) = sshutil.vol_detail(conn, "bigvol") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

    #sys.exit() 

 

    print "\nDeleting bigvol from SR" 

    (rc, output, errlog, errmsg) = sshutil.vol_delete(conn, "bigvol") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    print "\nBringing bigvol offline" 

    (rc, errlog, errmsg) = sshutil.vol_offline(conn, "bigvol") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

    print "\nDeleting bigvol from SR" 

    (rc, output, errlog, errmsg) = sshutil.vol_delete(conn, "bigvol") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    print "\nListing SR volumes- Checking if myvol6 exists" 

    (rc, vol_list, errlog, errmsg) = sshutil.list_SR_vols(conn, "myvol") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print vol_list 

 

    print "\nCreating myvol6 in the SR" 

    (rc, output, iSCSIname, errlog, errmsg) = sshutil.vol_create(conn, "myvol6", "5GB", "none", "bebe1234-bad2-4fc2-9142-990d3d920fb7", "offline", 100, "volume-offline", "default") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

            print "iSCSI name: %s"% iSCSIname 

 

    print "\nCreating clone of myvol6 in the SR" 

    (rc, output, iscsiname, errlog, errmsg) = sshutil.vol_create_clone(conn, "myvol6", "bebe1234-bad2-4fc2-9142-990d3d920fb7", "ddbb7698-bad2-4fc2-9142-990d3d920fb7", "UUID-ddbb7698-bad2-4fc2-9142-990d3d920fb7:DELETED-False") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

            print "iSCSI name: %s"% iSCSIname 

 

    clone_name= "XenStorage" + "bebe1234-bad2-4fc2-9142-990d3d920fb7".replace("-", "") + "ddbb7698-bad2-4fc2-9142-990d3d920fb7".replace("-", "")[:20] 

    print "\nBringing clone %s online"% clone_name 

    (rc, errlog, errmsg) = sshutil.vol_online(conn, clone_name) 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

    print "\nListing volume details for myvol6" 

    (rc, output, errlog, errmsg) = sshutil.vol_detail(conn, "myvol6") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    print "\nListing SR volumes" 

    (rc, vol_list, errlog, errmsg) = sshutil.list_SR_vols(conn, "myvol") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print vol_list 

 

    print "\nBringing myvol6 online" 

    (rc, errlog, errmsg) = sshutil.vol_online(conn, "myvol6") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

    print "\nBringing myvol6 offline" 

    (rc, errlog, errmsg) = sshutil.vol_offline(conn, "myvol6") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

    print "\nCreating access control record for myvol6" 

    (rc, output, errlog, errmsg) = sshutil.vol_create_access_rec_by_initiator(conn, "myvol6", "iqn.2008-04.com.example:12345a") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    print "\nBringing myvol6 online" 

    (rc, errlog, errmsg) = sshutil.vol_online(conn, "myvol6") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

    print "\nCreating a snapshot of myvol6" 

    snapname= "XenStorage" + "bebe1234-bad2-4fc2-9142-990d3d920fb7".replace("-", "") + "ddbb5678-bad2-4fc2-9142-990d3d92aaaa".replace("-", "")[:20] 

    (rc, errlog, errmsg) = sshutil.vol_create_snapshot(conn, "myvol6", "bebe1234-bad2-4fc2-9142-990d3d920fb7", "ddbb5678-bad2-4fc2-9142-990d3d92aaaa", "SNAPSHOT") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print "\nCreating a clone form snapshot %s of vol myvol6"% snapname 

            (rc, output, iscsiname, errlog, errmsg) = sshutil.vol_create_clone_from_snapshot(conn, "myvol6", snapname, "bebe1234-bad2-4fc2-9142-990d3d920fb7", "eeff9012-bad2-4fc2-9142-990d3d92cccc", "UUID-eeff9012-bad2-4fc2-9142-990d3d92cccc:DELETED-False") 

            if (rc): 

                    print errmsg 

                    for id in range(len(errlog)): 

                            print errlog[id] 

            else: 

                    print output 

                    print "iSCSI name of the clone is: %s"% iscsiname 

 

    print "\nListing snapshot details for %s"% snapname 

    (rc, output, errlog, errmsg) = sshutil.snap_detail(conn, "myvol6", snapname) 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    clone_name= "XenStorage" + "bebe1234-bad2-4fc2-9142-990d3d920fb7".replace("-", "") + "ddbb7698-bad2-4fc2-9142-990d3d920fb7".replace("-", "")[:20] 

 

    print "\nBringing clone of myvol6 offline" 

    (rc, errlog, errmsg) = sshutil.vol_offline(conn, clone_name) 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

    print "\nDeleting clone of myvol6: %s from SR"% clone_name 

    (rc, output, errlog, errmsg) = sshutil.vol_delete(conn, clone_name) 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    snap_clone= "XenStorage" + "bebe1234-bad2-4fc2-9142-990d3d920fb7".replace("-", "") + "eeff9012-bad2-4fc2-9142-990d3d92cccc".replace("-", "")[:20] 

    print "\nDeleting snap-clone of myvol6: %s from SR"% snap_clone 

    (rc, output, errlog, errmsg) = sshutil.vol_delete(conn, snap_clone) 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    print "\nDeleting snapshot of myvol6 from SR" 

    (rc, output, errlog, errmsg) = sshutil.snap_delete(conn, "myvol6", snapname) 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    print "\nBringing myvol6 offline" 

    (rc, errlog, errmsg) = sshutil.vol_offline(conn, "myvol6") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

 

    print "\nDeleting myvol6 from SR" 

    (rc, output, errlog, errmsg) = sshutil.vol_delete(conn, "myvol6") 

    if (rc): 

            print errmsg 

            for id in range(len(errlog)): 

                    print errlog[id] 

    else: 

            print output 

 

    print "Total time elapsed: %is"% (time.time() - start_time) 

 

    loop_count = loop_count - 1 

 

conn.close()