-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
491 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from pkgutil import extend_path | ||
__path__ = extend_path(__path__, __name__) |
274 changes: 274 additions & 0 deletions
274
cloudshell/devices/standards/traffic/chassis/autoload_structure.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,274 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
from cloudshell.devices.standards.base import AbstractResource | ||
from cloudshell.devices.standards.validators import attr_length_validator | ||
|
||
AVAILABLE_SHELL_TYPES = ['CS_TrafficGeneratorChassis'] | ||
|
||
__all__ = ["TrafficGeneratorChassis", "GenericTrafficGeneratorModule", | ||
"GenericTrafficGeneratorPort", "GenericPowerPort"] | ||
|
||
|
||
class TrafficGeneratorChassis(AbstractResource): | ||
RESOURCE_MODEL = "Traffic Generator Chassis" | ||
RELATIVE_PATH_TEMPLATE = "CH" | ||
|
||
# NAME_TEMPLATE = 'Chassis {}' | ||
|
||
def __init__(self, shell_name, name, unique_id, shell_type="CS_TrafficGeneratorChassis"): | ||
super(TrafficGeneratorChassis, self).__init__(shell_name, name, unique_id) | ||
|
||
if shell_name: | ||
self.shell_name = "{}.".format(shell_name) | ||
if shell_type in AVAILABLE_SHELL_TYPES: | ||
self.shell_type = "{}.".format(shell_type) | ||
else: | ||
raise Exception(self.__class__.__name__, "Unavailable shell type {shell_type}." | ||
"Shell type should be one of: {avail}" | ||
.format(shell_type=shell_type, avail=", ".join(AVAILABLE_SHELL_TYPES))) | ||
else: | ||
self.shell_name = "" | ||
self.shell_type = "" | ||
|
||
@property | ||
def model_name(self): | ||
""" Return the catalog name of the device model. | ||
This attribute will be displayed in CloudShell instead of the CloudShell model. """ | ||
|
||
return self.attributes.get("{}Model Name".format(self.shell_type), None) | ||
|
||
@model_name.setter | ||
@attr_length_validator | ||
def model_name(self, value=""): | ||
""" Set the catalog name of the device model. | ||
This attribute will be displayed in CloudShell instead of the CloudShell model. """ | ||
|
||
self.attributes["{}Model Name".format(self.shell_type)] = value | ||
|
||
@property | ||
def serial_number(self): | ||
""" Return the device serial number.""" | ||
|
||
return self.attributes.get("{}Serial Number".format(self.shell_type), None) | ||
|
||
@serial_number.setter | ||
@attr_length_validator | ||
def serial_number(self, value=""): | ||
""" Set the device serial number. """ | ||
|
||
self.attributes["{}Serial Number".format(self.shell_type)] = value | ||
|
||
@property | ||
def server_description(self): | ||
""" Return the full description of the server. | ||
Usually includes the OS, exact firmware version and additional characteritics of the device. """ | ||
|
||
return self.attributes.get("{}Server Description".format(self.shell_type), None) | ||
|
||
@server_description.setter | ||
@attr_length_validator | ||
def server_description(self, value=""): | ||
""" Set the full description of the server. | ||
Usually includes the OS, exact firmware version and additional characteritics of the device. """ | ||
|
||
self.attributes["{}Server Description".format(self.shell_type)] = value | ||
|
||
@property | ||
def vendor(self): | ||
""" Return the name of the device manufacture. """ | ||
|
||
return self.attributes.get("{}Vendor".format(self.shell_type), None) | ||
|
||
@vendor.setter | ||
@attr_length_validator | ||
def vendor(self, value): | ||
""" Set the name of the device manufacture. """ | ||
|
||
self.attributes["{}Vendor".format(self.shell_type)] = value | ||
|
||
@property | ||
def version(self): | ||
""" Return the firmware version of the resource. """ | ||
|
||
return self.attributes.get("{}Version".format(self.shell_type), None) | ||
|
||
@version.setter | ||
@attr_length_validator | ||
def version(self, value): | ||
""" Set the firmware version of the resource. """ | ||
|
||
self.attributes["{}Version".format(self.shell_type)] = value | ||
|
||
|
||
class GenericTrafficGeneratorModule(AbstractResource): | ||
RESOURCE_MODEL = "Generic Traffic Generator Module" | ||
RELATIVE_PATH_TEMPLATE = "M" | ||
|
||
@property | ||
def model_name(self): | ||
""" Return the catalog name of the device model. | ||
This attribute will be displayed in CloudShell instead of the CloudShell model. """ | ||
|
||
return self.attributes.get("{}Model Name".format(self.namespace), None) | ||
|
||
@model_name.setter | ||
@attr_length_validator | ||
def model_name(self, value=""): | ||
""" Set the catalog name of the device model. | ||
This attribute will be displayed in CloudShell instead of the CloudShell model. """ | ||
|
||
self.attributes["{}Model Name".format(self.namespace)] = value | ||
|
||
@property | ||
def version(self): | ||
""" Return the firmware version of the resource. """ | ||
|
||
return self.attributes.get("{}Version".format(self.namespace), None) | ||
|
||
@version.setter | ||
@attr_length_validator | ||
def version(self, value): | ||
""" Set the firmware version of the resource. """ | ||
|
||
self.attributes["{}Version".format(self.namespace)] = value | ||
|
||
@property | ||
def serial_number(self): | ||
""" Return the serial number of the resource. """ | ||
|
||
return self.attributes.get("{}Serial Number".format(self.namespace), None) | ||
|
||
@serial_number.setter | ||
@attr_length_validator | ||
def serial_number(self, value=""): | ||
""" Set the serial number of the resource. """ | ||
|
||
self.attributes["{}Serial Number".format(self.namespace)] = value | ||
|
||
|
||
class GenericTrafficGeneratorPort(AbstractResource): | ||
RESOURCE_MODEL = "Generic Traffic Generator Port" | ||
RELATIVE_PATH_TEMPLATE = "P" | ||
|
||
@property | ||
def media_type(self): | ||
""" | ||
Return interface media type. Possible values are Fiber and/or Copper (comma-separated). | ||
:rtype: str | ||
""" | ||
return self.attributes.get("{}Media Type".format(self.namespace), False) | ||
|
||
@media_type.setter | ||
@attr_length_validator | ||
def media_type(self, value): | ||
""" | ||
Set interface media type. Possible values are Fiber and/or Copper (comma-separated). | ||
:type value: str | ||
""" | ||
self.attributes["{}Media Type".format(self.namespace)] = value | ||
|
||
@property | ||
def configured_controllers(self): | ||
""" | ||
Return the value which specifies what controller can be used with the ports (IxLoad controller, BP controller etc...) | ||
:rtype: float | ||
""" | ||
return self.attributes.get("{}Configured Controllers".format(self.namespace), False) | ||
|
||
@configured_controllers.setter | ||
@attr_length_validator | ||
def configured_controllers(self, value): | ||
""" | ||
Set the value which specifies what controller can be used with the ports (IxLoad controller, BP controller etc...) | ||
:type value: float | ||
""" | ||
self.attributes["{}Configured Controllers".format(self.namespace)] = value | ||
|
||
|
||
class GenericPowerPort(AbstractResource): | ||
RESOURCE_MODEL = "Generic Power Port" | ||
RELATIVE_PATH_TEMPLATE = "PP" | ||
|
||
@property | ||
def model(self): | ||
""" | ||
Return the device model. This information is typically used for abstract resource filtering. | ||
:rtype: str | ||
""" | ||
return self.attributes.get("{}Model".format(self.namespace), False) | ||
|
||
@model.setter | ||
@attr_length_validator | ||
def model(self, value): | ||
""" | ||
Set the device model. This information is typically used for abstract resource filtering. | ||
:type value: str | ||
""" | ||
self.attributes["{}Model".format(self.namespace)] = value | ||
|
||
@property | ||
def model_name(self): | ||
""" Return the catalog name of the device model. | ||
This attribute will be displayed in CloudShell instead of the CloudShell model. | ||
:rtype: str""" | ||
|
||
return self.attributes.get("{}Model Name".format(self.namespace), None) | ||
|
||
@model_name.setter | ||
@attr_length_validator | ||
def model_name(self, value=""): | ||
""" Set the catalog name of the device model. | ||
This attribute will be displayed in CloudShell instead of the CloudShell model. """ | ||
|
||
self.attributes["{}Model Name".format(self.namespace)] = value | ||
|
||
@property | ||
def serial_number(self): | ||
""" | ||
Return the serial number of the resource. | ||
:rtype: str | ||
""" | ||
return self.attributes.get("{}Serial Number".format(self.namespace), False) | ||
|
||
@serial_number.setter | ||
@attr_length_validator | ||
def serial_number(self, value): | ||
""" | ||
Set the serial number of the resource. | ||
:type value: str | ||
""" | ||
self.attributes["{}Serial Number".format(self.namespace)] = value | ||
|
||
@property | ||
def version(self): | ||
""" | ||
Return the firmware version of the resource. | ||
:rtype: str | ||
""" | ||
return self.attributes.get("{}Version".format(self.namespace), False) | ||
|
||
@version.setter | ||
@attr_length_validator | ||
def version(self, value): | ||
""" | ||
Set the firmware version of the resource. | ||
:type value: str | ||
""" | ||
self.attributes["{}Version".format(self.namespace)] = value | ||
|
||
@property | ||
def port_description(self): | ||
""" | ||
Return the description of the port as configured in the device. | ||
:rtype: str | ||
""" | ||
return self.attributes.get("{}Port Description".format(self.namespace), False) | ||
|
||
@port_description.setter | ||
@attr_length_validator | ||
def port_description(self, value): | ||
""" | ||
Set the description of the port as configured in the device. | ||
:type value: str | ||
""" | ||
self.attributes["{}Port Description".format(self.namespace)] = value |
102 changes: 102 additions & 0 deletions
102
cloudshell/devices/standards/traffic/chassis/configuration_attributes_structure.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
class GenericTrafficChassisResource(object): | ||
def __init__(self, shell_name=None, name=None, supported_os=None): | ||
""" Init method | ||
:param shell_name: Shell Name | ||
:type shell_name: str | ||
:param name: Resource Name | ||
:type name: str | ||
:param supported_os: list of supported OS | ||
:type supported_os: list | ||
""" | ||
|
||
self.attributes = {} | ||
self.shell_name = shell_name | ||
self.name = name | ||
self.supported_os = supported_os | ||
self.fullname = None | ||
self.address = None # The IP address of the resource | ||
self.family = None # The resource family | ||
|
||
if shell_name: | ||
self.namespace_prefix = "{}.".format(self.shell_name) | ||
else: | ||
self.namespace_prefix = "" | ||
|
||
@property | ||
def user(self): | ||
""" | ||
User to connect to the chassis (optional) | ||
:rtype: str | ||
""" | ||
return self.attributes.get("{}User".format(self.namespace_prefix), None) | ||
|
||
@property | ||
def password(self): | ||
""" | ||
Password to connect to the chassis (optional) | ||
:rtype: string | ||
""" | ||
return self.attributes.get("{}Password".format(self.namespace_prefix), None) | ||
|
||
@property | ||
def controller_tcp_port(self): | ||
""" | ||
The TCP port of the traffic controller. Relevant only in case an external controller is configured. | ||
Default TCP port should be used if kept empty. | ||
:rtype: int | ||
""" | ||
return self.attributes.get("{}Controller TCP Port".format(self.namespace_prefix), None) | ||
|
||
@property | ||
def controller_address(self): | ||
""" | ||
The IP address of the traffic server. Relevant only in case an external server is configured. | ||
:rtype: int | ||
""" | ||
return self.attributes.get("{}Controller Address".format(self.namespace_prefix), None) | ||
|
||
@property | ||
def client_install_path(self): | ||
""" | ||
The path in which the traffic client is installed on the Execution Server. | ||
For example C:/Program Files (x86)/Ixia/IxLoad/5.10-GA | ||
:rtype: str | ||
""" | ||
return self.attributes.get("{}Client Install Path".format(self.namespace_prefix), None) | ||
|
||
@property | ||
def power_management(self): | ||
""" | ||
Used by the power management orchestration, if enabled, to determine whether to automatically manage the device | ||
power status. Enabled by default. | ||
:rtype: bool | ||
""" | ||
return self.attributes.get("{}Power Management".format(self.namespace_prefix), None) | ||
|
||
@staticmethod | ||
def from_context(shell_name, supported_os, context): | ||
""" | ||
Creates an instance of Networking Resource by given context | ||
:param shell_name: Shell Name | ||
:type shell_name: str | ||
:param supported_os: list of supported OS | ||
:type supported_os: list | ||
:param context: cloudshell.shell.core.driver_context.AutoLoadCommandContext | ||
:type context: cloudshell.shell.core.driver_context.AutoLoadCommandContext | ||
:return: | ||
:rtype GenericNetworkingResource | ||
""" | ||
|
||
result = GenericTrafficChassisResource(shell_name=shell_name, name=context.resource.name, supported_os=supported_os) | ||
result.address = context.resource.address | ||
result.family = context.resource.family | ||
result.fullname = context.resource.fullname | ||
|
||
result.attributes = dict(context.resource.attributes) | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from pkgutil import extend_path | ||
__path__ = extend_path(__path__, __name__) |
Oops, something went wrong.