def __init__( self, fqdn, username, password, version): """ Arguments: fqdn: same as for Endpoint username: same as for Endpoint password: same as for Endpoint version: same as for Endpoint """ self.log = TastLogger(self.__class__.__name__) self.log.debug('LocalEndpointBase: Creating new %s instance...' % ( self.__class__.__name__)) super(LocalEndpointBase, self).__init__( fqdn, username, password, version) self.connection_interface = None self.local_endpoint = None self.log.debug('LocalEndpointBase: New %s instance created!' % ( self.__class__.__name__))
def __init__(self, fqdn, username, password, type, version, os_info, vm_name, connection_server): """ Arguments: fqdn: same as for Endpoint username: same as for Endpoint password: same as for Endpoint type: same as for Endpoint version: same as for Endpoint os_info: {'os_name', 'os_version', 'os_theme', 'system_type'} vm_name: connection_server: """ self.log = TastLogger(self.__class__.__name__) self.log.debug('RemoteEndpoint: Creating new %s instance...' % (self.__class__.__name__)) super(RemoteEndpoint, self).__init__(fqdn, username, password, type, version) self.os_info = os_info self.vm_name = vm_name self.connection_server = connection_server self.build = None self.log.debug('RemoteEndpoint: New %s instance created!' % (self.__class__.__name__))
def __init__( self, fqdn, username, password, type, version): """ Arguments: fqdn: same as for Endpoint username: same as for Endpoint password: same as for Endpoint type: one of LocalEndpointType values version: same as for Endpoint """ self.log = TastLogger(self.__class__.__name__) self.log.debug('LocalEndpoint: Creating new %s instance...' % self.__class__.__name__) if (type == LocalEndpointType.VMW_VIEW_CLIENT): self.local_endpoint = VmwViewClient(fqdn, username, password, version) elif (type == LocalEndpointType.TERA1_CLIENT): self.local_endpoint = Tera1Client(fqdn, username, password, version) else: self.log.error( 'Unknown PCoIP client (%s)' % type) self.local_endpoint = None self.log.debug('LocalEndpoint: New %s instance created!' % self.__class__.__name__)
class Endpoint(RemoteMachine): """ Endpoint base class. Provides common endpoint functionality """ def __init__(self, fqdn, username, password, type, version): """ Arguments: fqdn: same as for RemoteMachine username: same as for RemoteMachine password: same as for RemoteMachine type: one of LocalEndpointType or RemoteEndpointType values version: type specific, could include build information, we can use also values 'latest_dev', 'latest_released', etc. """ self.log = TastLogger(self.__class__.__name__) self.log.debug('Endpoint: Creating new %s instance...' % (self.__class__.__name__)) super(Endpoint, self).__init__(fqdn, username, password) self.type = type self.version = version self.log.debug('Endpoint: New %s instance created!' % (self.__class__.__name__))
def __init__(self, fqdn, username, password, type, version, viewer_type, viewer_id): """ Arguments: fqdn: same as for Endpoint username: same as for Endpoint password: same as for Endpoint type: one of LocalEndpointType values version: same as for Endpoint viewer_type: 'kvmoip' or 'dp-dvi' viewer_id: type specific, for 'kvmoip' switch it is fqdn or ipaddr of the kvmoip device """ self.log = TastLogger(self.__class__.__name__) self.log.debug('LocalEndpoint: Creating new %s instance...' % (self.__class__.__name__)) super(LocalEndpoint, self).__init__(fqdn, username, password, type, version) self.viewer_type = viewer_type self.viewer_id = viewer_id self.connection_interface = None self._local_endpoint_obj = None self.log.debug('LocalEndpoint: New %s instance created!' % (self.__class__.__name__))
def __init__(self): """ """ self.log = TastLogger(self.__class__.__name__) self.log.debug('ZeroClient: New %s instance created!' % (self.__class__.__name__))
def __init__(self, fqdn='', username='******', password='******', *args, **kwargs): """ Arguments: fqdn: machine fqdn username: user of the machine, can be in the format 'domain\username' password: user's password """ self.log = TastLogger(self.__class__.__name__) self.log.debug('RemoteMachine: Creating new %s instance...' % (self.__class__.__name__)) rm = None if WmiRemoteMachine: try: rm = WmiRemoteMachine(fqdn, username, password) except Exception, e: self.log.debug('Unable to access machine %s using wmi. %s' % (fqdn, str(e))) rm = None
def __init__(self, fqdn='', username='', password='', **kwargs): self.log = TastLogger(self.__class__.__name__) self.log.debug('RemoteMachineWmi: Creating new %s instance...' % (self.__class__.__name__)) super(RemoteMachine, self).__init__(fqdn, username, password) self.log.debug('RemoteMachineWmi: New %s instance created!' % (self.__class__.__name__))
def __init__(self, fqdn='', username='', password='', **kwargs): self.log = TastLogger(self.__class__.__name__) self.log.debug('RemoteMachineBase: Creating new %s instance...' % (self.__class__.__name__)) self.fqdn = fqdn self.username = username self.password = password self.log.debug('RemoteMachineBase: New %s instance created!' % (self.__class__.__name__))
class RemoteEndpointBase(EndpointBase): """ RemoteEndpoint class provides remote endpoint specific functionality """ def __init__(self, fqdn, username, password, version, os_info, vm_name, connection_server): """ Arguments: fqdn: same as for Endpoint username: same as for Endpoint password: same as for Endpoint version: same as for Endpoint os_info: {'os_name', 'os_version', 'os_theme', 'system_type'} vm_name: connection_server: """ self.log = TastLogger(self.__class__.__name__) self.log.debug('RemoteEndpointBase: Creating new %s instance...' % (self.__class__.__name__)) super(RemoteEndpointBase, self).__init__(fqdn, username, password, version) self.os_info = os_info self.vm_name = vm_name self.connection_server = connection_server self.build = None self.log.debug('RemoteEndpointBase: New %s instance created!' % (self.__class__.__name__)) def update_pcoip_software(self, build): """ Update the remote endpoint's PCoIP software (agent/firmware) to the specified build Arguments: build - pcoip build to be installed on the endpoint Exceptions: UpdateError(description) """ raise Exception( 'update_pcoip_software must be implemented in the concrete class!') def get_pcoip_version(self): """ Returns PCoIP software/firmware version for the endpoint Similar functions: swift SwiftServer.get_pcoip_version() """ raise Exception( 'get_pcoip_version must be implemented in the concrete class!')
def __init__(self, fqdn, username, password, version): """ """ self.log = TastLogger(self.__class__.__name__) self.log.debug('VmwViewClient: Creating new %s instance...' % (self.__class__.__name__)) super(VmwViewClient, self).__init__(fqdn, username, password, version) self.connection_interface = None self.rep = None self.log.debug('VmwViewClient: New %s instance created!' % (self.__class__.__name__))
def __init__(self, fqdn, username, password, version): """ Arguments: fqdn: same as for RemoteMachine username: same as for RemoteMachine password: same as for RemoteMachine version: type specific, could include build information, we can use also values 'latest_dev', 'latest_released', etc. """ self.log = TastLogger(self.__class__.__name__) self.log.debug('EndpointBase: Creating new %s instance...' % (self.__class__.__name__)) super(EndpointBase, self).__init__(fqdn, username, password) self.version = version self.log.debug('EndpointBase: New %s instance created!' % (self.__class__.__name__))
class WmiRemoteMachine(RemoteMachineBase): ''' Class that wraps all the above Remote* classes. Use this class if you want all of the above functionality ''' def __init__( self, fqdn='', username='', password='', **kwargs): self.log = TastLogger(self.__class__.__name__) self.log.debug('WmiRemoteMachine: Creating new %s instance...' % ( self.__class__.__name__)) super(WmiRemoteMachine, self).__init__( fqdn, username, password) self.log.debug('WmiRemoteMachine: New %s instance created!' % ( self.__class__.__name__)) def start_process(self, process_name): ''' ''' self.log.info('process %s started!' % process_name)
class ViewClient(object): ''' ViewClient ''' def __init__(self): """ """ self.log = TastLogger(self.__class__.__name__) self.log.debug('ViewClient: New %s instance created!' % ( self.__class__.__name__)) def start_view_client( self, remote_endpoint, configuration): ''' ''' self.log.info( 'view_client connected to %s with configurartion %s' % ( str(remote_endpoint), str(configuration))) def close_view_client(): self.log.info('view client closed!')
def __init__(self, fqdn, username, password, version, os_info, vm_name, connection_server): """ Arguments: fqdn: same as for Endpoint username: same as for Endpoint password: same as for Endpoint version: same as for Endpoint os_info: {'os_name', 'os_version', 'os_theme', 'system_type'} vm_name: connection_server: """ self.log = TastLogger(self.__class__.__name__) self.log.debug('VmwWin7ViewHost: Creating new %s instance...' % (self.__class__.__name__)) super(VmwWin7ViewHost, self).__init__(fqdn, username, password, version, os_info, vm_name, connection_server) self.log.debug('VmwWin7ViewHost: New %s instance created!' % (self.__class__.__name__))
class VmwViewClient(LocalEndpointBase): ''' ''' def __init__(self, fqdn, username, password, version): """ """ self.log = TastLogger(self.__class__.__name__) self.log.debug('VmwViewClient: Creating new %s instance...' % (self.__class__.__name__)) super(VmwViewClient, self).__init__(fqdn, username, password, version) self.connection_interface = None self.rep = None self.log.debug('VmwViewClient: New %s instance created!' % (self.__class__.__name__)) def connect_to_remote_endpoint(self, remote_endpoint, connection_interface, configuration): """ Arguments: RemoteEndpoint remote_endpoint: endpoint to connect to string connection_interface: 'ui' (sikuli) or 'api' (cmicl) dict configuration: parameters that depend on the client, server and connection interface types. For example, when using VMware View Client one parameter could be desktop layout (fullscreen or window with sepcific size); e.g. dictionary {'desktop_layout': 'fullscreen'} Exceptions: ConnectionError(description) """ self.log.info( 'vmw view client %s connected to %s via %s with configurartion %s' % (self.fqdn, str(remote_endpoint.vm_name), str(connection_interface), str(configuration))) self.rep = remote_endpoint def disconnect_from_remote_endpoint(self, method=DisconnectionMethod.DISCONNECT): """ Arguments: method - e.g. disconnect, disconnect&logoff, tsdiscon, ctrl+alt+F12, etc Returns: none Exceptions: DisconnectionError(description) """ self.log.info('vmw view client %s disconnected from %s!' % (self.fqdn, self.rep.fqdn))
class RemoteMachine(object): """ Provides functions for doing various operations on a remote machine (e.g. file and directory operations, creating and managing processes, working with registry etc.) This is factory class which creates and returns object of one of concrete classes (see list of concrete classes in the import section). For the list and documentation of the avaialable remote operations refer to the _RemoteMachineBase class. """ def __init__(self, fqdn='', username='******', password='******', *args, **kwargs): """ Arguments: fqdn: machine fqdn username: user of the machine, can be in the format 'domain\username' password: user's password """ self.log = TastLogger(self.__class__.__name__) self.log.debug('RemoteMachine: Creating new %s instance...' % (self.__class__.__name__)) rm = None if WmiRemoteMachine: try: rm = WmiRemoteMachine(fqdn, username, password) except Exception, e: self.log.debug('Unable to access machine %s using wmi. %s' % (fqdn, str(e))) rm = None else:
class VmwWin7ViewHost(RemoteEndpointBase): ''' ''' def __init__(self, fqdn, username, password, version, os_info, vm_name, connection_server): """ Arguments: fqdn: same as for Endpoint username: same as for Endpoint password: same as for Endpoint version: same as for Endpoint os_info: {'os_name', 'os_version', 'os_theme', 'system_type'} vm_name: connection_server: """ self.log = TastLogger(self.__class__.__name__) self.log.debug('VmwWin7ViewHost: Creating new %s instance...' % (self.__class__.__name__)) super(VmwWin7ViewHost, self).__init__(fqdn, username, password, version, os_info, vm_name, connection_server) self.log.debug('VmwWin7ViewHost: New %s instance created!' % (self.__class__.__name__)) def update_pcoip_software(self, build): """ Update the remote endpoint's PCoIP software (agent/firmware) to the specified build Arguments: build - pcoip build to be installed on the endpoint Exceptions: UpdateError(description) """ self.build = build self.log.info( 'VmwWin7ViewHost %s:%s:%s updated to %s!' % (self.fqdn, self.connection_server, self.vm_name, str(build))) def get_pcoip_version(self): """ Returns PCoIP software/firmware version for the endpoint Similar functions: swift SwiftServer.get_pcoip_version() """ return self.build
class LocalEndpoint(object): """ LocalEndpoint class provides functions for managing local PCoIP endpoint. """ def __init__( self, fqdn, username, password, type, version): """ Arguments: fqdn: same as for Endpoint username: same as for Endpoint password: same as for Endpoint type: one of LocalEndpointType values version: same as for Endpoint """ self.log = TastLogger(self.__class__.__name__) self.log.debug('LocalEndpoint: Creating new %s instance...' % self.__class__.__name__) if (type == LocalEndpointType.VMW_VIEW_CLIENT): self.local_endpoint = VmwViewClient(fqdn, username, password, version) elif (type == LocalEndpointType.TERA1_CLIENT): self.local_endpoint = Tera1Client(fqdn, username, password, version) else: self.log.error( 'Unknown PCoIP client (%s)' % type) self.local_endpoint = None self.log.debug('LocalEndpoint: New %s instance created!' % self.__class__.__name__) def __getattr__(self, attr): """ Invokes specified attribute implentation of the concrete class. """ return getattr(self.local_endpoint, attr)
class ZeroClient(object): ''' ZeroClient ''' def __init__(self): """ """ self.log = TastLogger(self.__class__.__name__) self.log.debug('ZeroClient: New %s instance created!' % (self.__class__.__name__)) def create_pcoip_session(self, remote_endpoint, configuration): ''' ''' self.log.info('zero_client connected to %s with configurartion %s' % (str(remote_endpoint), str(configuration))) def close_pcoip_session(): self.log.info('pcoip session closed!')
class LocalEndpointBase(EndpointBase): """ LocalEndpoint class provides functions for managing local PCoIP endpoint. """ def __init__( self, fqdn, username, password, version): """ Arguments: fqdn: same as for Endpoint username: same as for Endpoint password: same as for Endpoint version: same as for Endpoint """ self.log = TastLogger(self.__class__.__name__) self.log.debug('LocalEndpointBase: Creating new %s instance...' % ( self.__class__.__name__)) super(LocalEndpointBase, self).__init__( fqdn, username, password, version) self.connection_interface = None self.local_endpoint = None self.log.debug('LocalEndpointBase: New %s instance created!' % ( self.__class__.__name__)) # ===== session related functions ===== def connect_to_remote_endpoint( self, remote_endpoint, connection_interface, configuration): """ Arguments: RemoteEndpoint remote_endpoint: endpoint to connect to string connection_interface: 'ui' (sikuli) or 'api' (cmicl) dict configuration: parameters that depend on the client, server and connection interface types. For example, when using VMware View Client one parameter could be desktop layout (fullscreen or window with sepcific size); e.g. dictionary {'desktop_layout': 'fullscreen'} Exceptions: ConnectionError(description) """ raise Exception('connect_to_remote_endpoint must be implemented in the concrete class!') def disconnect_from_remote_endpoint(self, method): """ Arguments: method - e.g. disconnect, disconnect&logoff, tsdiscon, ctrl+alt+F12, etc Returns: none Exceptions: DisconnectionError(description) """ raise Exception('disconnect_from_remote_endpoint must be implemented in the concrete class!')
class LocalEndpoint(endpoint.Endpoint): """ LocalEndpoint class provides functions for managing local PCoIP endpoint. """ def __init__(self, fqdn, username, password, type, version, viewer_type, viewer_id): """ Arguments: fqdn: same as for Endpoint username: same as for Endpoint password: same as for Endpoint type: one of LocalEndpointType values version: same as for Endpoint viewer_type: 'kvmoip' or 'dp-dvi' viewer_id: type specific, for 'kvmoip' switch it is fqdn or ipaddr of the kvmoip device """ self.log = TastLogger(self.__class__.__name__) self.log.debug('LocalEndpoint: Creating new %s instance...' % (self.__class__.__name__)) super(LocalEndpoint, self).__init__(fqdn, username, password, type, version) self.viewer_type = viewer_type self.viewer_id = viewer_id self.connection_interface = None self._local_endpoint_obj = None self.log.debug('LocalEndpoint: New %s instance created!' % (self.__class__.__name__)) # ===== session related functions ===== def connect_to_remote_endpoint(self, remote_endpoint, connection_interface, configuration): """ Arguments: RemoteEndpoint remote_endpoint: endpoint to connect to string connection_interface: 'ui' (sikuli) or 'api' (cmicl) dict configuration: parameters that depend on the client, server and connection interface types. For example, when using VMware View Client one parameter could be desktop layout (fullscreen or window with sepcific size); e.g. dictionary {'desktop_layout': 'fullscreen'} Exceptions: ConnectionError(description) Similar functions: softi PcoipClient.create_pcoip_session(pcoip_client, pcoip_server, *args) swift SwiftClient*.start_pcoip_session(desktop)+verify_session_start() swift SwiftSession.initialize()+create_pcoip_session() firmware SessionCtrl.start_session_direct() Questions: - How do we connect through security gateway? Is that defined by connection server? """ self._connection_interface = connection_interface if ((self.type == LocalEndpointType.VMW_VIEW_CLIENT) and (self._connection_interface == ConnectionInterface.GUI)): self._local_endpoint_obj = ViewClient() self._local_endpoint_obj.start_view_client(remote_endpoint, configuration) elif ((self.type == LocalEndpointType.TERA1_CLIENT) and (self._connection_interface == ConnectionInterface.GUI)): self._local_endpoint_obj = ZeroClient() self._local_endpoint_obj.create_pcoip_session( remote_endpoint, configuration) else: self.log.error( 'Unknown PCoIP client (%s) or connection interface (%s)' % (self.type, self._connection_interface)) def disconnect_from_remote_endpoint(self, method): """ Arguments: method - e.g. disconnect, disconnect&logoff, tsdiscon, ctrl+alt+F12, etc Returns: none Exceptions: DisconnectionError(description) Simialar functions: softi PcoipClient.close_pcoip_session() swift SwiftClient*.terminate_pcoip_session() swift SwiftSession.close_pcoip_session() firmware SessionCtrl.stop_session() """ if ((self.type == LocalEndpointType.VMW_VIEW_CLIENT) and (self._connection_interface == ConnectionInterface.GUI)): self._local_endpoint_obj.close_view_client() elif ((self.type == LocalEndpointType.TERA1_CLIENT) and (self._connection_interface == ConnectionInterface.GUI)): self._local_endpoint_obj.close_pcoip_session() else: self.log.error( 'disconnect_from_remote_endpoint is not implemented for %s client and %s interface!' % (self.type, self._connection_interface))