def get_os_info(cls, client_object, **kwargs): """ Returns the Kernel version, Build number, Name and Version information for given NSX edge NSXEdge>show version ... Name: NSX Edge ... Version: 7.0.0.0.0 ... Build Number: 2252106 ... Kernel: 3.2.62 """ endpoint = "show version " PARSER = "raw/showEdgeVersion" EXPECT_PROMPT = ['bytes*', 'NSXEdge>'] # Get the parsed data mapped_pydict = utilities.get_mapped_pydict_for_expect( client_object.connection, endpoint, PARSER, EXPECT_PROMPT, ' ') # Close the expect connection object client_object.connection.close() get_edge_version_schema_object = show_edge_version_schema. \ ShowEdgeVersionSchema(mapped_pydict) pylogger.info("show version command output : %s" % get_edge_version_schema_object.__dict__) return get_edge_version_schema_object
def verify_application_processes(cls, client_obj, application_name, **kwargs): client_obj.connection.login_to_st_en_terminal(expect=['#']) app_dict = {"appmgmt": "ps -eo user,cmd | " "grep appmgmt-tcserver | wc -l", "locator": "ps -eo user,cmd | grep ulocator |" " grep clustering-utils | wc -l", "ntp": "ps -eo user,cmd | grep /usr/sbin/ntpd | wc -l", "proton": "ps -eo user,cmd | grep uproton | " "grep proton-tcserver | wc -l", "proxy": "ps -eo user,cmd | grep urproxy | " "grep proxy-tcserver| wc -l", "rabbitmq": "ps -U urabbit | wc -l", "snmp": "ps -eo user,cmd | grep /usr/local/sbin/snmpd |" " wc -l", "sshd": "ps -eo user,cmd | grep /usr/sbin/sshd | wc -l", "syslog": "ps -eo user,cmd | " "grep /usr/local/sbin/rsyslogd | wc -l"} endpoint = app_dict[application_name] parser = "raw/applicationProcess" expect_prompt = [']', '#'] mapped_pydict = utilities.get_mapped_pydict_for_expect( client_obj.connection, endpoint, parser, expect_prompt, application_name) client_obj.connection.close() return mapped_pydict
def verify_application_processes(cls, client_obj, application_name, **kwargs): client_obj.connection.login_to_st_en_terminal(expect=['#']) app_dict = { "appmgmt": "ps -eo user,cmd | " "grep appmgmt-tcserver | wc -l", "locator": "ps -eo user,cmd | grep ulocator |" " grep clustering-utils | wc -l", "ntp": "ps -eo user,cmd | grep /usr/sbin/ntpd | wc -l", "proton": "ps -eo user,cmd | grep uproton | " "grep proton-tcserver | wc -l", "proxy": "ps -eo user,cmd | grep urproxy | " "grep proxy-tcserver| wc -l", "rabbitmq": "ps -U urabbit | wc -l", "snmp": "ps -eo user,cmd | grep /usr/local/sbin/snmpd |" " wc -l", "sshd": "ps -eo user,cmd | grep /usr/sbin/sshd | wc -l", "syslog": "ps -eo user,cmd | " "grep /usr/local/sbin/rsyslogd | wc -l" } endpoint = app_dict[application_name] parser = "raw/applicationProcess" expect_prompt = [']', '#'] mapped_pydict = utilities.get_mapped_pydict_for_expect( client_obj.connection, endpoint, parser, expect_prompt, application_name) client_obj.connection.close() return mapped_pydict
def read(cls, client_object, **kwargs): endpoint = "show services" parser = "raw/listServices" expect_prompt = ['bytes*', '>'] mapped_pydict = utilities.get_mapped_pydict_for_expect( client_object.connection, endpoint, parser, expect_prompt, ':') if 'failure' in mapped_pydict: raise Exception(mapped_pydict['failure']) schema_object = list_services_schema.ListServicesSchema(mapped_pydict) return schema_object
def get_vhosts_list(cls, client_object, **kwargs): client_object.connection.login_to_st_en_terminal(expect=['#']) endpoint = "rabbitmqctl list_vhosts" parser = "raw/listHosts" expect_prompt = ['bytes*', '#'] mapped_pydict = utilities.get_mapped_pydict_for_expect( client_object.connection, endpoint, parser, expect_prompt, ' ') schema_object = list_vhosts_schema.ListvHostsSchema(mapped_pydict) return schema_object
def get_queues_list(cls, client_object, **kwargs): vhostpath = kwargs['get_queues_list']['vhostpath'] client_object.connection.login_to_st_en_terminal(expect=['#']) endpoint = "rabbitmqctl list_queues -p %s" % vhostpath parser = "raw/listQueues" expect_prompt = ['bytes*', '#'] mapped_pydict = utilities.get_mapped_pydict_for_expect( client_object.connection, endpoint, parser, expect_prompt, ' ') schema_object = list_queues_schema.ListQueuesSchema(mapped_pydict) return schema_object
def _parse_get_interface(cls, client_object, adapter_name): if adapter_name is None: raise ValueError("vNic name must be a valid value. " "Provided: %r" % adapter_name) endpoint = "get interface " + adapter_name PARSER = "raw/showinterface" EXPECT_PROMPT = ['bytes*', 'NSXEdge>'] mapped_pydict = utilities.get_mapped_pydict_for_expect( client_object.connection, endpoint, PARSER, EXPECT_PROMPT, ' ') client_object.connection.close() return mapped_pydict
def _parse_get_interface(cls, client_object, adapter_name): if adapter_name is None: raise ValueError("vNic name must be a valid value. " "Provided: %r" % adapter_name) endpoint = "get interface " + adapter_name PARSER = "raw/showinterface" EXPECT_PROMPT = ['bytes*', 'NSXEdge>'] mapped_pydict = utilities.get_mapped_pydict_for_expect( client_object.connection, endpoint, PARSER, EXPECT_PROMPT, ' ') client_object.connection.close() return mapped_pydict
def get_user_permissions_list(cls, client_object, **kwargs): username = kwargs['get_user_permissions_list']['username'] client_object.connection.login_to_st_en_terminal(expect=['#']) endpoint = "rabbitmqctl list_user_permissions %s" % username parser = "raw/listUserPermissions" expect_prompt = ['bytes*', '#'] mapped_pydict = utilities.get_mapped_pydict_for_expect( client_object.connection, endpoint, parser, expect_prompt, ' ') schema_object = list_user_permissions_schema.\ ListUserPermissionsSchema(mapped_pydict) return schema_object
def get_cluster_status(cls, client_object, **kwargs): ''' NSXEdge>show edge-cluster status Highavailability Status: Standby Highavailability State since: 2014-10-22 17:45:43.559 Highavailability Unit Id: 0 Highavailability Unit State: Down Highavailability Admin State: Up Highavailability Running Resources: None Highavailability Active Nodes: None Unit Poll Policy: Frequency: 1 seconds Deadtime: 6 seconds Highavailability Services Status: Routing Status Channel: Up Routing Status: Down Healthcheck Config Channel: Up Healthcheck Status Channel: Up Highavailability Healthcheck Status: This unit [0]: Down Peer unit [1]: Down Session via vNic_0: 10.110.63.98:10.110.63.47 Down Session via vNic_2: 169.255.255.241:169.255.255.242 Down Peer unit [2]: Down Session via vNic_0: 10.110.63.98:10.110.63.240 Down Session via vNic_2: 169.255.255.241:169.255.255.243 Down ''' cli_command = "show edge-cluster status" PARSER = "raw/showedgeclusterstatus" EXPECT_PROMPT = ['bytes*', 'NSXEdge>'] mapped_pydict = utilities.get_mapped_pydict_for_expect( client_object.connection, cli_command, PARSER, EXPECT_PROMPT, ' ') client_object.connection.close() show_edge_cluster_status_schema_object = show_edge_cluster_status_schema.\ ShowEdgeClusterStatusSchema(mapped_pydict) pylogger.info("show edge-cluster status command output : %s" % show_edge_cluster_status_schema_object.__dict__) return show_edge_cluster_status_schema_object
def get_cluster_status(cls, client_object, **kwargs): ''' NSXEdge>show edge-cluster status Highavailability Status: Standby Highavailability State since: 2014-10-22 17:45:43.559 Highavailability Unit Id: 0 Highavailability Unit State: Down Highavailability Admin State: Up Highavailability Running Resources: None Highavailability Active Nodes: None Unit Poll Policy: Frequency: 1 seconds Deadtime: 6 seconds Highavailability Services Status: Routing Status Channel: Up Routing Status: Down Healthcheck Config Channel: Up Healthcheck Status Channel: Up Highavailability Healthcheck Status: This unit [0]: Down Peer unit [1]: Down Session via vNic_0: 10.110.63.98:10.110.63.47 Down Session via vNic_2: 169.255.255.241:169.255.255.242 Down Peer unit [2]: Down Session via vNic_0: 10.110.63.98:10.110.63.240 Down Session via vNic_2: 169.255.255.241:169.255.255.243 Down ''' cli_command = "show edge-cluster status" PARSER = "raw/showedgeclusterstatus" EXPECT_PROMPT = ['bytes*', 'NSXEdge>'] mapped_pydict = utilities.get_mapped_pydict_for_expect( client_object.connection, cli_command, PARSER, EXPECT_PROMPT, ' ') client_object.connection.close() show_edge_cluster_status_schema_object = show_edge_cluster_status_schema.\ ShowEdgeClusterStatusSchema(mapped_pydict) pylogger.info("show edge-cluster status command output : %s" % show_edge_cluster_status_schema_object.__dict__) return show_edge_cluster_status_schema_object
def get_configuration_bgp(cls, client_object, get_configuration_bgp=None): """ Sample Output of command: NSXEdge> show configuration bgp ----------------------------------------------------------------------- vShield Edge BGP Routing Protocol Config: { "bgp" : { "gracefulRestart" : false, "localAS" : 200, "neighbors" : [ { "keepAliveTimer" : 60, "ipAddress" : "192.168.50.50", "name" : "Neighbour 1", "description" : "Neighbour 1", "remoteAS" : 200, "password" : "****", "srcIpAddress" : "192.168.50.1", "holdDownTimer" : 180, "weight" : 60 } ], "enabled" : true } } """ endpoint = "show configuration bgp" PARSER = "raw/jsonCli" EXPECT_PROMPT = ['bytes*', 'NSXEdge>'] mapped_pydict = utilities.get_mapped_pydict_for_expect( client_object.connection, endpoint, PARSER, EXPECT_PROMPT, 'bgp') get_configuration_bgp_schema_object = get_configuration_bgp_schema. \ GetConfigurationBGPSchema(mapped_pydict) return get_configuration_bgp_schema_object
def get_configuration_bgp(cls, client_object, get_configuration_bgp=None): """ Sample Output of command: NSXEdge> show configuration bgp ----------------------------------------------------------------------- vShield Edge BGP Routing Protocol Config: { "bgp" : { "gracefulRestart" : false, "localAS" : 200, "neighbors" : [ { "keepAliveTimer" : 60, "ipAddress" : "192.168.50.50", "name" : "Neighbour 1", "description" : "Neighbour 1", "remoteAS" : 200, "password" : "****", "srcIpAddress" : "192.168.50.1", "holdDownTimer" : 180, "weight" : 60 } ], "enabled" : true } } """ endpoint = "show configuration bgp" PARSER = "raw/jsonCli" EXPECT_PROMPT = ['bytes*', 'NSXEdge>'] mapped_pydict = utilities.get_mapped_pydict_for_expect( client_object.connection, endpoint, PARSER, EXPECT_PROMPT, 'bgp') get_configuration_bgp_schema_object = get_configuration_bgp_schema. \ GetConfigurationBGPSchema(mapped_pydict) return get_configuration_bgp_schema_object