or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

connection-management.mddevice-support.mdindex.mdnetconf-operations.mdtransport-layer.mdxml-utilities.md

device-support.mddocs/

0

# Device Support

1

2

Device-specific handlers providing optimizations and vendor-specific functionality for major network equipment manufacturers. Handlers customize NETCONF behavior, add vendor extensions, and optimize operations for specific device capabilities.

3

4

## Capabilities

5

6

### Device Handler Creation

7

8

Factory function for creating appropriate device handlers based on device parameters.

9

10

```python { .api }

11

def make_device_handler(device_params, ignore_errors=None):

12

"""

13

Create device handler for vendor-specific functionality.

14

15

Parameters:

16

- device_params: dict, device configuration with 'name' key

17

or custom 'handler' class

18

- ignore_errors: list, error patterns to ignore

19

20

Returns:

21

DeviceHandler: Device-specific handler instance

22

"""

23

```

24

25

### Base Device Handler

26

27

Default handler providing standard NETCONF behavior without vendor-specific customizations.

28

29

```python { .api }

30

class DefaultDeviceHandler:

31

"""Default device handler for standard NETCONF devices."""

32

33

def __init__(self, device_params, ignore_errors=None):

34

"""

35

Initialize default device handler.

36

37

Parameters:

38

- device_params: dict, device parameters

39

- ignore_errors: list, error patterns to ignore

40

"""

41

42

def add_additional_ssh_connect_params(self, params):

43

"""Add device-specific SSH connection parameters."""

44

45

def add_additional_netconf_params(self, params):

46

"""Add device-specific NETCONF parameters."""

47

48

def add_additional_operations(self):

49

"""

50

Add vendor-specific operations.

51

52

Returns:

53

dict: Mapping of operation names to operation classes

54

"""

55

56

def perform_qualify_check(self):

57

"""Perform device qualification checks."""

58

59

def handle_connection_exceptions(self, sshsession):

60

"""Handle device-specific connection exceptions."""

61

```

62

63

### Cisco Device Handlers

64

65

Device handlers for Cisco network equipment with platform-specific optimizations.

66

67

```python { .api }

68

class NexusDeviceHandler(DefaultDeviceHandler):

69

"""Cisco Nexus device handler with NXOS optimizations."""

70

71

def __init__(self, device_params, ignore_errors=None):

72

"""Initialize Nexus device handler."""

73

74

class IosxrDeviceHandler(DefaultDeviceHandler):

75

"""Cisco IOS XR device handler."""

76

77

def __init__(self, device_params, ignore_errors=None):

78

"""Initialize IOS XR device handler."""

79

80

class IosxeDeviceHandler(DefaultDeviceHandler):

81

"""Cisco IOS XE device handler."""

82

83

def __init__(self, device_params, ignore_errors=None):

84

"""Initialize IOS XE device handler."""

85

86

class CsrDeviceHandler(DefaultDeviceHandler):

87

"""Cisco Cloud Services Router device handler."""

88

89

def __init__(self, device_params, ignore_errors=None):

90

"""Initialize CSR device handler."""

91

```

92

93

### Juniper Device Handler

94

95

Device handler for Juniper Networks equipment with Junos-specific functionality.

96

97

```python { .api }

98

class JunosDeviceHandler(DefaultDeviceHandler):

99

"""Juniper Junos device handler with platform optimizations."""

100

101

def __init__(self, device_params, ignore_errors=None):

102

"""

103

Initialize Junos device handler.

104

105

Parameters:

106

- device_params: dict, may include 'local' key for local connections

107

- ignore_errors: list, error patterns to ignore

108

"""

109

110

def add_additional_operations(self):

111

"""

112

Add Junos-specific operations.

113

114

Returns:

115

dict: Junos vendor operations

116

"""

117

```

118

119

### Huawei Device Handlers

120

121

Device handlers for Huawei network equipment supporting multiple data models.

122

123

```python { .api }

124

class HuaweiDeviceHandler(DefaultDeviceHandler):

125

"""Huawei device handler for traditional data models."""

126

127

def __init__(self, device_params, ignore_errors=None):

128

"""Initialize Huawei device handler."""

129

130

class HuaweiyangDeviceHandler(DefaultDeviceHandler):

131

"""Huawei device handler for YANG-based data models."""

132

133

def __init__(self, device_params, ignore_errors=None):

134

"""Initialize Huawei YANG device handler."""

135

```

136

137

### Other Vendor Handlers

138

139

Device handlers for additional network equipment vendors.

140

141

```python { .api }

142

class H3cDeviceHandler(DefaultDeviceHandler):

143

"""H3C (Hewlett Packard Enterprise) device handler."""

144

145

def __init__(self, device_params, ignore_errors=None):

146

"""Initialize H3C device handler."""

147

148

class HpcomwareDeviceHandler(DefaultDeviceHandler):

149

"""HP Comware device handler."""

150

151

def __init__(self, device_params, ignore_errors=None):

152

"""Initialize HP Comware device handler."""

153

154

class AluDeviceHandler(DefaultDeviceHandler):

155

"""Nokia/Alcatel-Lucent device handler."""

156

157

def __init__(self, device_params, ignore_errors=None):

158

"""Initialize ALU device handler."""

159

160

class SrosDeviceHandler(DefaultDeviceHandler):

161

"""Nokia Service Router Operating System device handler."""

162

163

def __init__(self, device_params, ignore_errors=None):

164

"""Initialize SR OS device handler."""

165

166

class EricssonDeviceHandler(DefaultDeviceHandler):

167

"""Ericsson device handler."""

168

169

def __init__(self, device_params, ignore_errors=None):

170

"""Initialize Ericsson device handler."""

171

172

class CienaDeviceHandler(DefaultDeviceHandler):

173

"""Ciena device handler."""

174

175

def __init__(self, device_params, ignore_errors=None):

176

"""Initialize Ciena device handler."""

177

```

178

179

## Vendor-Specific Operations

180

181

Extended RPC operations provided by device handlers for vendor-specific functionality.

182

183

### Juniper Operations

184

185

```python { .api }

186

# Available through JunosDeviceHandler

187

def compare_configuration(**kwargs):

188

"""Compare configuration versions (Junos)."""

189

190

def load_configuration(config, **kwargs):

191

"""Load configuration with Junos-specific options."""

192

193

def commit_configuration(**kwargs):

194

"""Commit with Junos-specific parameters."""

195

```

196

197

### Cisco Operations

198

199

```python { .api }

200

# Available through Nexus/IOS handlers

201

def save_config(**kwargs):

202

"""Save running configuration (Cisco)."""

203

204

def action(action_xml):

205

"""Execute Cisco-specific action RPC."""

206

```

207

208

### Nokia/ALU Operations

209

210

```python { .api }

211

# Available through ALU/SROS handlers

212

def md_cli_raw_command(command):

213

"""Execute raw MD-CLI command (Nokia)."""

214

215

def classic_cli_raw_command(command):

216

"""Execute raw classic CLI command (Nokia)."""

217

```

218

219

## Device Parameter Configuration

220

221

Device-specific parameters for customizing handler behavior and connection settings.

222

223

```python { .api }

224

# Device parameter examples

225

device_params = {

226

'name': 'junos', # Device type identifier

227

'local': True, # Local connection (Junos)

228

'handler': CustomHandler, # Custom handler class

229

'timeout': 60, # Device-specific timeout

230

'port': 22, # SSH port override

231

'hostkey_verify': False, # SSH host key verification

232

}

233

```

234

235

## Usage Examples

236

237

### Basic Device Handler Usage

238

239

```python

240

from ncclient import manager

241

242

# Automatic device detection

243

device_params = {'name': 'junos'}

244

245

with manager.connect_ssh(

246

host='juniper-mx.example.com',

247

username='netconf-user',

248

password='netconf-pass',

249

device_params=device_params

250

) as m:

251

# Junos-specific operations available

252

config = m.get_config(source='running')

253

254

# Access vendor operations if available

255

if hasattr(m, 'compare_configuration'):

256

result = m.compare_configuration()

257

```

258

259

### Cisco Nexus Device

260

261

```python

262

from ncclient import manager

263

264

device_params = {'name': 'nexus'}

265

266

with manager.connect_ssh(

267

host='nexus-switch.example.com',

268

username='admin',

269

password='admin',

270

device_params=device_params

271

) as m:

272

# Nexus-specific behavior and operations

273

result = m.get_config(source='running')

274

275

# Save configuration if supported

276

if hasattr(m, 'save_config'):

277

m.save_config()

278

```

279

280

### Custom Device Handler

281

282

```python

283

from ncclient import manager

284

from ncclient.devices.default import DefaultDeviceHandler

285

286

class MyCustomHandler(DefaultDeviceHandler):

287

def add_additional_operations(self):

288

# Add custom operations

289

return {

290

'custom_op': MyCustomOperation

291

}

292

293

def add_additional_ssh_connect_params(self, params):

294

# Customize SSH parameters

295

params['banner_timeout'] = 60

296

params['auth_timeout'] = 30

297

298

# Use custom handler

299

device_params = {'handler': MyCustomHandler}

300

301

with manager.connect_ssh(

302

host='custom-device.example.com',

303

username='admin',

304

password='admin',

305

device_params=device_params

306

) as m:

307

# Custom operations available

308

if hasattr(m, 'custom_op'):

309

result = m.custom_op()

310

```

311

312

### Multiple Device Types

313

314

```python

315

from ncclient import manager

316

317

devices = [

318

{'host': 'juniper.example.com', 'device_params': {'name': 'junos'}},

319

{'host': 'cisco.example.com', 'device_params': {'name': 'nexus'}},

320

{'host': 'huawei.example.com', 'device_params': {'name': 'huawei'}},

321

]

322

323

for device_config in devices:

324

try:

325

with manager.connect_ssh(

326

host=device_config['host'],

327

username='admin',

328

password='admin',

329

device_params=device_config['device_params']

330

) as m:

331

print(f"Connected to {device_config['host']}")

332

333

# Universal operations work on all devices

334

config = m.get_config(source='running')

335

print(f"Config length: {len(config.data_xml)}")

336

337

except Exception as e:

338

print(f"Failed to connect to {device_config['host']}: {e}")

339

```

340

341

### Error Handling with Device Specifics

342

343

```python

344

from ncclient import manager

345

346

# Device-specific error handling

347

ignore_errors = [

348

'warning',

349

'minor-error'

350

]

351

352

device_params = {

353

'name': 'iosxr',

354

}

355

356

errors_params = {

357

'ignore_errors': ignore_errors

358

}

359

360

with manager.connect_ssh(

361

host='iosxr-router.example.com',

362

username='cisco',

363

password='cisco',

364

device_params=device_params,

365

errors_params=errors_params

366

) as m:

367

# IOS XR specific operations with error handling

368

try:

369

result = m.edit_config(target='candidate', config=config_xml)

370

m.commit()

371

except Exception as e:

372

print(f"Operation failed: {e}")

373

```