-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver.py
More file actions
56 lines (42 loc) · 2.01 KB
/
Copy pathdriver.py
File metadata and controls
56 lines (42 loc) · 2.01 KB
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
from cloudshell.shell.core.resource_driver_interface import ResourceDriverInterface
from cloudshell.shell.core.driver_context import InitCommandContext, ResourceCommandContext, AutoLoadResource, \
AutoLoadAttribute, AutoLoadDetails, CancellationContext
from data_model import * # run 'shellfoundry generate' to generate data model classes
class IxialicensepoolDriver (ResourceDriverInterface):
def __init__(self):
"""
ctor must be without arguments, it is created with reflection at run time
"""
pass
def initialize(self, context):
"""
Initialize the driver session, this function is called everytime a new instance of the driver is created
This is a good place to load and cache the driver configuration, initiate sessions etc.
:param InitCommandContext context: the context the command runs on
"""
pass
def cleanup(self):
"""
Destroy the driver session, this function is called everytime a driver instance is destroyed
This is a good place to close any open sessions, finish writing to log files
"""
pass
# <editor-fold desc="Discovery">
def get_inventory(self, context):
"""
Discovers the resource structure and attributes.
:param AutoLoadCommandContext context: the context the command runs on
:return Attribute and sub-resource information for the Shell resource you can return an AutoLoadDetails object
:rtype: AutoLoadDetails
"""
resource = IxiaLicensePool.create_from_context(context)
resource.vendor = 'Ixia'
resource.model = 'Ixia License Pool'
available = int(resource.available_licenses)
for a in xrange(available):
lic = ResourcePort('License ' + str(a + 1).zfill(2))
lic.model_name = "Ixia License"
lic.application = "IxVM IxNetwork"
resource.add_sub_resource(str(a + 1), lic)
return resource.create_autoload_details()
# </editor-fold>