Exemplo n.º 1
0
class LinuxResource(object):
    def __init__(self, driver):
        self.driver = driver
        self.frameElem = frameElement(driver)
        self.resource = Resource(driver)
        self.account = Accountmgr(driver)

    u'''添加和编辑Linux资源
	   Parameters:
	      - data:excel中的一行数据
	'''

    def add_edit_linux_resource(self, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        self.resource.set_resource_name(data[3])
        #资源ip
        self.resource.set_resource_ip(data[4])
        #归属部门
        if data[5] != 'no':
            self.resource.set_depart(data[5])
        self.resource.select_all_agreement()
        #从IP
        if data[6] != 'no':
            self.resource.set_resource_fortIps(data[6])
        #系统版本
        if data[7] != 'no':
            self.resource.set_sys_version(data[7])
        #密码策略
        if data[8] != 'no':
            self.resource.select_pwd_strategy(data[8])
        #改密驱动名称
        if data[9] != 'no':
            self.resource.set_changePwd_driver(data[9])

        #管理员帐号
        if data[10] != 'no':
            self.resource.click_account_sync()
            self.resource.set_admin_account(data[10])
        #管理员口令
        if data[11] != 'no':
            self.resource.set_admin_pwd(data[11])
        #口令确认
        if data[12] != 'no':
            self.resource.set_confirm_pwd(data[12])
            self.resource.click_up_super()
            #提权账号口令
            self.resource.set_super_pwd(data[13])
            #确认口令
            self.resource.set_super_confirm_pwd(data[14])
        self.resource.resoure_save_button()

    u'''校验Linux资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''

    def check_linux_resource(self, datarow, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        self.resource.set_resource_name(data[2])
        #资源ip
        self.resource.set_resource_ip(data[3])
        #协议类型
        if data[4] != 'no':
            self.resource.select_agreement(data[4])
        #协议类型 端口
        if datarow == 7:
            self.resource.set_port(data[4], data[5])
        if datarow == 8:
            self.resource.clear_port("Ssh1")
        if datarow == 9:
            self.resource.set_port("Ssh1", data[5])
        if datarow == 12:
            self.resource.click_account_sync()
            self.resource.click_up_super()
        if datarow == 13:
            #提权账号口令
            if data[6] != 'no':
                self.resource.set_super_pwd(data[6])
            #确认口令
            if data[7] != 'no':
                self.resource.set_super_confirm_pwd(data[7])
            self.resource.set_super_prompt()
        self.resource.resoure_save_button()

    u'''添加资源账号
	   Parameters:
	      - editacttname:编辑的资源账号名称
	      - value:选择编辑方式的value值
	      - addactname:填写的资源账号名称
	      - pwd:账号口令
	      - cmfpwd:确认口令
	'''

    def add_edit_resource_account(self,
                                  editacttname='no',
                                  value='no',
                                  addactname='no',
                                  pwd='no',
                                  cmfpwd='no'):
        self.account.click_account_add_edit_button(editacttname)
        if value != 'no':
            self.account.select_edit_way(value)
        if addactname != 'no':
            self.account.set_account_name(addactname)
        if pwd != 'no':
            self.account.set_account_pwd(pwd)
        if cmfpwd != 'no':
            self.account.set_account_confirm_pwd(cmfpwd)
        self.account.set_authorize()
        self.account.click_save_account()

    u'''校验资源账号
	   Parameters:
	      - value:选择编辑方式的value值
	      - addactname:填写的资源账号名称
	      - pwd:账号口令
	      - cmfpwd:确认口令
	'''

    def check_resource_account(self,
                               value='no',
                               addactname='no',
                               pwd='no',
                               cmfpwd='no'):
        if addactname == 'no':
            self.account.clear_account_name()
        if pwd == 'no':
            self.account.clear_account_pwd()
        if cmfpwd == 'no':
            self.account.clear_account_confirm_pwd()
        if value != 'no':
            self.account.select_edit_way(value)
        if addactname != 'no':
            self.account.set_account_name(addactname)
        if pwd != 'no':
            self.account.set_account_pwd(pwd)
        if cmfpwd != 'no':
            self.account.set_account_confirm_pwd(cmfpwd)
        self.account.set_authorize()
        self.account.click_save_account()
Exemplo n.º 2
0
class NetworkResource(object):
    def __init__(self, driver):
        self.driver = driver
        self.getElem = getElement(driver)
        self.selectElem = selectElement(driver)
        self.frameElem = frameElement(driver)
        self.resource = Resource(driver)
        self.cnEn = cnEncode()

    u'''添加和编辑网络设备资源
	   Parameters:
	      - data:excel中的一行数据
	'''

    def add_edit_network_resource(self, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        if data[3] != 'no':
            self.resource.set_resource_name(data[3])
        #资源ip
        if data[5] != 'no':
            self.resource.set_resource_ip(data[5])
        #从IP
        if data[6] != 'no':
            self.resource.set_resource_fortIps(data[6])
        #归属部门
        if data[4] != 'no':
            self.resource.set_depart(data[4])

        self.resource.select_all_agreement()
        #系统版本
        if data[7] != 'no':
            self.resource.set_sys_version(data[7])
        #改密驱动名称
        if data[8] != 'no':
            self.resource.set_changePwd_driver(data[8])

        #管理员帐号
        if data[9] != 'no':
            self.resource.click_account_sync()
            self.resource.set_admin_account(data[9])
        #管理员口令
        if data[10] != 'no':
            self.resource.set_admin_pwd(data[10])
        #口令确认
        if data[11] != 'no':
            self.resource.set_confirm_pwd(data[11])
        #提权
        if data[12] != 'no':
            self.resource.click_up_super()
            #提权账号口令
            self.resource.set_super_pwd(data[12])
            #确认口令
            self.resource.set_super_confirm_pwd(data[13])
        if data[5] != 'no':
            self.resource.resoure_save_button()
        else:
            self.resource.click_save_button()

    u'''校验网络设备资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''

    def check_network_resource(self, datarow, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        self.resource.set_resource_name(data[2])
        #资源ip
        self.resource.set_resource_ip(data[3])
        #协议类型
        if data[4] != 'no':
            self.resource.select_agreement(data[4])
        #协议类型 端口
        if datarow == 7:
            self.resource.set_port(data[4], data[5])
        if datarow == 8:
            self.resource.clear_port("Ssh2")
        if datarow == 9:
            self.resource.set_port("Ssh2", data[5])
        if datarow == 12:
            self.resource.click_account_sync()
            self.resource.click_up_super()
        if datarow == 13:
            #提权账号口令
            if data[6] != 'no':
                self.resource.set_super_pwd(data[6])
            #确认口令
            if data[7] != 'no':
                self.resource.set_super_confirm_pwd(data[7])
            self.resource.set_super_prompt()
        self.resource.resoure_save_button()

    u'''选择telnet登录模式
	   Parameters:
	      - mode:value属性
	'''

    def telnet_login_type(self, mode):
        model = self.cnEn.is_float(mode)
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        selectelem = self.getElem.find_element_with_wait_EC(
            "id", "fortInputModelTelnet")
        self.selectElem.select_element_by_value(selectelem, model)

    u'''勾选匿名认证'''

    def check_anonymous(self):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        self.getElem.find_element_wait_and_click_EC("id", "anonymous_auth")
Exemplo n.º 3
0
class WindowsResource(object):
    def __init__(self, driver):
        self.driver = driver
        self.getElem = getElement(driver)
        self.selectElem = selectElement(driver)
        self.frameElem = frameElement(driver)
        self.resource = Resource(driver)
        self.cnEn = cnEncode()

    u'''添加和编辑windows资源
	   Parameters:
	      - data:excel中的一行数据
	'''

    def add_edit_windows_resource(self, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        if data[3] != 'no':
            self.resource.set_resource_name(data[3])
        #资源ip
        if data[5] != 'no':
            self.resource.set_resource_ip(data[5])
        #从IP
        if data[6] != 'no':
            self.resource.set_resource_fortIps(data[6])
        #归属部门
        if data[4] != 'no':
            self.resource.set_depart(data[4])
        #密码策略
        if data[7] != 'no':
            self.resource.select_pwd_strategy(data[7])
        #选择所要运维协议
        self.resource.select_all_agreement()
        #windows域名
        if data[8] != 'no':
            self.set_domain_name(data[8])
        #账号分类
        if data[9] != 'no':
            self.resource.click_account_sync()
            self.select_account_type(data[9])
        #归属域控主机
        if data[10] != 'no':
            self.select_attach_domian(data[10])
        #主机名称
        if data[11] != 'no':
            self.set_host_name(data[11])
        #管理员帐号
        if data[12] != 'no':
            if data[9] == 'no':
                self.resource.click_account_sync()
            self.resource.set_admin_account(data[12])
        #管理员帐号
        if data[16] != 'no':
            self.resource.click_account_sync()
            self.select_account_protocol(data[16])
            self.set_port(data[17])
            if data[16] == "Ldap":
                self.set_ldap_account(data[18])
            else:
                self.set_ssh_account(data[18])
        #管理员口令
        if data[13] != 'no':
            self.resource.set_admin_pwd(data[13])
        #口令确认
        if data[14] != 'no':
            self.resource.set_confirm_pwd(data[14])
        #BaseDN
        if data[15] != 'no':
            self.set_base_dn(data[15])
        self.resource.click_save_button()

    u'''校验windows资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''

    def check_windows_resource(self, datarow, data):
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        #资源名称
        self.resource.set_resource_name(data[2])
        #资源ip
        self.resource.set_resource_ip(data[3])
        #协议类型
        if data[4] != 'no':
            self.resource.select_agreement(data[4])
        #协议类型 端口
        if datarow == 7:
            self.resource.set_port(data[4], data[5])
        if datarow == 8:
            self.resource.clear_port("Vnc")
        if datarow == 9:
            self.resource.set_port("Vnc", data[5])
        if datarow == 12:
            self.resource.click_account_sync()
            self.select_account_type(data[6])
        if datarow == 13:
            self.select_attach_domian(data[7])
        self.resource.click_save_button()

    u'''填写windows域名
	   parameter:
	       - domainname:windows域名
	'''

    def set_domain_name(self, domainname):
        try:
            doname = self.cnEn.is_float(domainname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear('id', "fortDomainName")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "fortDomainName", doname)
        except Exception as e:
            print "domainname is error :" + str(e)

    u'''选择账号分类
	   Parameters:
	      - value:value属性
	'''

    def select_account_type(self, value):
        type = self.cnEn.is_float(value)
        self.frameElem.from_frame_to_otherFrame("mainFrame")
        selectelem = self.getElem.find_element_with_wait_EC(
            "id", "selectDisplay")
        self.selectElem.select_element_by_value(selectelem, type)

    u'''选择归属域控主机
	   parameter:
	       - text:归属域控主机的名称
	'''

    def select_attach_domian(self, text):
        try:
            domiantext = self.cnEn.is_float(text)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            selectelem = self.getElem.find_element_with_wait_EC(
                'id', "window_select_dc")
            self.selectElem.select_element_by_visible_text(
                selectelem, domiantext)
        except Exception as e:
            print "Domian select error:" + str(e)

    u'''填写主机名称
	   parameter:
	       - hostname:主机名称
	'''

    def set_host_name(self, hostname):
        try:
            host = self.cnEn.is_float(hostname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear('id', "window_host_name")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "window_host_name", host)
        except Exception as e:
            print "window_host_name is error :" + str(e)

    u'''填写Base DN
	   parameter:
	       - basedn:Base DN名称
	'''

    def set_base_dn(self, basedn):
        try:
            base = self.cnEn.is_float(basedn)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear('id', "fortBaseDn")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "fortBaseDn", base)
        except Exception as e:
            print "fortBaseDn is error :" + str(e)

    u'''填写连接端口
	   parameter:
	       - portname:连接端口名称
	'''

    def set_port(self, portname):
        try:
            port = self.cnEn.is_float(portname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear('id',
                                                     "fortConnectionPort")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "fortConnectionPort", port)
        except Exception as e:
            print "port is error :" + str(e)

    u'''填写ldap账号
	   parameter:
	       - actname:管理员账号
	'''

    def set_ldap_account(self, actname):
        try:
            act = self.cnEn.is_float(actname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear('id',
                                                     "fortAdminAccount_ldap")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "fortAdminAccount_ldap", act)
        except Exception as e:
            print "name is error :" + str(e)

    u'''填写ssh账号
	   parameter:
	       - actname:管理员账号
	'''

    def set_ssh_account(self, actname):
        try:
            act = self.cnEn.is_float(actname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_clear('id',
                                                     "fortAdminAccount_ssh")
            self.getElem.find_element_wait_and_sendkeys(
                'id', "fortAdminAccount_ssh", act)
        except Exception as e:
            print "name is error :" + str(e)

    u'''选择账号同步连接协议
	   parameter:
	       - proname:同步
	'''

    def select_account_protocol(self, proname):
        try:
            pro = self.cnEn.is_float(proname)
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            selem = self.getElem.find_element_with_wait_EC(
                'id', "fortConnectionProtocol")
            self.selectElem.select_element_by_visible_text(selem, pro)
        except Exception as e:
            print " protocol is error :" + str(e)

    u'''是否勾选获取所有账号'''

    def check_all_account(self):
        try:
            self.frameElem.from_frame_to_otherFrame("mainFrame")
            self.getElem.find_element_wait_and_click_EC(
                'id', "get_all_accounts")
        except Exception as e:
            print " Check failure :" + str(e)
Exemplo n.º 4
0
class LinuxResource(object):

	def __init__(self, driver):
		self.driver = driver
		self.frameElem = frameElement(driver)
		self.resource = Resource(driver)
		self.account = Accountmgr(driver)

	u'''添加和编辑Linux资源
	   Parameters:
	      - data:excel中的一行数据
	'''
	def add_edit_linux_resource(self, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		self.resource.set_resource_name(data[3])
		#资源ip
		self.resource.set_resource_ip(data[4])
		#归属部门
		if data[5] != 'no':
			self.resource.set_depart(data[5])
		self.resource.select_all_agreement()
		#从IP
		if data[6] != 'no':
			self.resource.set_resource_fortIps(data[6])
		#系统版本
		if data[7] != 'no':
			self.resource.set_sys_version(data[7])
		#密码策略
		if data[8] != 'no':
			self.resource.select_pwd_strategy(data[8])
		#改密驱动名称
		if data[9] != 'no':
			self.resource.set_changePwd_driver(data[9])

		#管理员帐号
		if data[10] != 'no':
			self.resource.click_account_sync()
			self.resource.set_admin_account(data[10])
		#管理员口令
		if data[11] != 'no':
			self.resource.set_admin_pwd(data[11])
		#口令确认
		if data[12] != 'no':
			self.resource.set_confirm_pwd(data[12])
			self.resource.click_up_super()
			#提权账号口令
			self.resource.set_super_pwd(data[13])
			#确认口令
			self.resource.set_super_confirm_pwd(data[14])
		self.resource.click_save_button()

	u'''校验Linux资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''
	def check_linux_resource(self, datarow, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		self.resource.set_resource_name(data[2])
		#资源ip
		self.resource.set_resource_ip(data[3])
		#协议类型
		if data[4] != 'no':
			self.resource.select_agreement(data[4])
		#协议类型 端口
		if datarow == 7:
			self.resource.set_port(data[4], data[5])
		if datarow == 8:
			self.resource.clear_port("Ssh1")
		if datarow == 9:
			self.resource.set_port("Ssh1", data[5])
		if datarow == 12:
			self.resource.click_account_sync()
			self.resource.click_up_super()
		if datarow == 13:
			#提权账号口令
			if data[6] != 'no':
				self.resource.set_super_pwd(data[6])
			#确认口令
			if data[7] != 'no':
				self.resource.set_super_confirm_pwd(data[7])
			self.resource.set_super_prompt()
		self.resource.click_save_button()

	u'''添加资源账号
	   Parameters:
	      - editacttname:编辑的资源账号名称
	      - value:选择编辑方式的value值
	      - addactname:填写的资源账号名称
	      - pwd:账号口令
	      - cmfpwd:确认口令
	'''
	def add_edit_resource_account(self, editacttname='no', value='no', addactname='no', pwd='no', cmfpwd='no'):
		self.account.click_account_add_edit_button(editacttname)
		if value != 'no':
			self.account.select_edit_way(value)
		if addactname != 'no':
			self.account.set_account_name(addactname)
		if pwd != 'no':
			self.account.set_account_pwd(pwd)
		if cmfpwd != 'no':
			self.account.set_account_confirm_pwd(cmfpwd)
		self.account.set_authorize()
		self.account.click_save_account()

	u'''校验资源账号
	   Parameters:
	      - value:选择编辑方式的value值
	      - addactname:填写的资源账号名称
	      - pwd:账号口令
	      - cmfpwd:确认口令
	'''
	def check_resource_account(self, value='no', addactname='no', pwd='no', cmfpwd='no'):
		if addactname == 'no':
			self.account.clear_account_name()
		if pwd == 'no':
			self.account.clear_account_pwd()
		if cmfpwd == 'no':
			self.account.clear_account_confirm_pwd()
		if value != 'no':
			self.account.select_edit_way(value)
		if addactname != 'no':
			self.account.set_account_name(addactname)
		if pwd != 'no':
			self.account.set_account_pwd(pwd)
		if cmfpwd != 'no':
			self.account.set_account_confirm_pwd(cmfpwd)
		self.account.set_authorize()
		self.account.click_save_account()
Exemplo n.º 5
0
class WindowsResource(object):

	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.resource = Resource(driver)
		self.cnEn = cnEncode()

	u'''添加和编辑windows资源
	   Parameters:
	      - data:excel中的一行数据
	'''
	def add_edit_windows_resource(self, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		if data[3] != 'no':
			self.resource.set_resource_name(data[3])
		#资源ip
		if data[5] != 'no':
			self.resource.set_resource_ip(data[5])
		#从IP
		if data[6] != 'no':
			self.resource.set_resource_fortIps(data[6])
		#归属部门
		if data[4] != 'no':
			self.resource.set_depart(data[4])
		#密码策略
		if data[7] != 'no':
			self.resource.select_pwd_strategy(data[7])
		#选择所要运维协议
		self.resource.select_all_agreement()
		#windows域名
		if data[8] != 'no':
			self.set_domain_name(data[8])
		#账号分类
		if data[9] != 'no':
			self.resource.click_account_sync()
			self.select_account_type(data[9])
		#归属域控主机
		if data[10] != 'no':
			self.select_attach_domian(data[10])
		#主机名称
		if data[11] != 'no':
			self.set_host_name(data[11])
		#管理员帐号
		if data[12] != 'no':
			if data[9] == 'no':
				self.resource.click_account_sync()
			self.resource.set_admin_account(data[12])
		#管理员帐号
		if data[16] != 'no':
			self.resource.click_account_sync()
			self.select_account_protocol(data[16])
			self.set_port(data[17])
			if data[16] == "Ldap":
				self.set_ldap_account(data[18])
			else:
				self.set_ssh_account(data[18])
		#管理员口令
		if data[13] != 'no':
			self.resource.set_admin_pwd(data[13])
		#口令确认
		if data[14] != 'no':
			self.resource.set_confirm_pwd(data[14])
		#BaseDN
		if data[15] != 'no':
			self.set_base_dn(data[15])
		self.resource.click_save_button()

	u'''校验windows资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''
	def check_windows_resource(self, datarow, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		self.resource.set_resource_name(data[2])
		#资源ip
		self.resource.set_resource_ip(data[3])
		#协议类型
		if data[4] != 'no':
			self.resource.select_agreement(data[4])
		#协议类型 端口
		if datarow == 7:
			self.resource.set_port(data[4], data[5])
		if datarow == 8:
			self.resource.clear_port("Vnc")
		if datarow == 9:
			self.resource.set_port("Vnc", data[5])
		if datarow == 12:
			self.resource.click_account_sync()
			self.select_account_type(data[6])
		if datarow == 13:
			self.select_attach_domian(data[7])
		self.resource.click_save_button()

	u'''填写windows域名
	   parameter:
	       - domainname:windows域名
	'''
	def set_domain_name(self, domainname):
		try:
			doname = self.cnEn.is_float(domainname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortDomainName")
			self.getElem.find_element_wait_and_sendkeys('id', "fortDomainName", doname)
		except Exception as e:
			print "domainname is error :" + str(e)

	u'''选择账号分类
	   Parameters:
	      - value:value属性
	'''
	def select_account_type(self, value):
		type = self.cnEn.is_float(value)
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		selectelem = self.getElem.find_element_with_wait_EC("id", "selectDisplay")
		self.selectElem.select_element_by_value(selectelem, type)

	u'''选择归属域控主机
	   parameter:
	       - text:归属域控主机的名称
	'''
	def select_attach_domian(self, text):
		try:
			domiantext = self.cnEn.is_float(text)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			selectelem = self.getElem.find_element_with_wait_EC('id', "window_select_dc")
			self.selectElem.select_element_by_visible_text(selectelem, domiantext)
		except Exception as e:
			print "Domian select error:" + str(e)

	u'''填写主机名称
	   parameter:
	       - hostname:主机名称
	'''
	def set_host_name(self, hostname):
		try:
			host = self.cnEn.is_float(hostname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "window_host_name")
			self.getElem.find_element_wait_and_sendkeys('id', "window_host_name", host)
		except Exception as e:
			print "window_host_name is error :" + str(e)

	u'''填写Base DN
	   parameter:
	       - basedn:Base DN名称
	'''
	def set_base_dn(self, basedn):
		try:
			base = self.cnEn.is_float(basedn)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortBaseDn")
			self.getElem.find_element_wait_and_sendkeys('id', "fortBaseDn", base)
		except Exception as e:
			print "fortBaseDn is error :" + str(e)

	u'''填写连接端口
	   parameter:
	       - portname:连接端口名称
	'''
	def set_port(self, portname):
		try:
			port = self.cnEn.is_float(portname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortConnectionPort")
			self.getElem.find_element_wait_and_sendkeys('id', "fortConnectionPort", port)
		except Exception as e:
			print "port is error :" + str(e)

	u'''填写ldap账号
	   parameter:
	       - actname:管理员账号
	'''
	def set_ldap_account(self, actname):
		try:
			act = self.cnEn.is_float(actname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortAdminAccount_ldap")
			self.getElem.find_element_wait_and_sendkeys('id', "fortAdminAccount_ldap", act)
		except Exception as e:
			print "name is error :" + str(e)

	u'''填写ssh账号
	   parameter:
	       - actname:管理员账号
	'''
	def set_ssh_account(self, actname):
		try:
			act = self.cnEn.is_float(actname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_clear('id', "fortAdminAccount_ssh")
			self.getElem.find_element_wait_and_sendkeys('id', "fortAdminAccount_ssh", act)
		except Exception as e:
			print "name is error :" + str(e)

	u'''选择账号同步连接协议
	   parameter:
	       - proname:同步
	'''
	def select_account_protocol(self, proname):
		try:
			pro = self.cnEn.is_float(proname)
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			selem = self.getElem.find_element_with_wait_EC('id', "fortConnectionProtocol")
			self.selectElem.select_element_by_visible_text(selem, pro)
		except Exception as e:
			print " protocol is error :" + str(e)

	u'''是否勾选获取所有账号'''
	def check_all_account(self):
		try:
			self.frameElem.from_frame_to_otherFrame("mainFrame")
			self.getElem.find_element_wait_and_click_EC('id', "get_all_accounts")
		except Exception as e:
			print " Check failure :" + str(e)
Exemplo n.º 6
0
class NetworkResource(object):

	def __init__(self, driver):
		self.driver = driver
		self.getElem = getElement(driver)
		self.selectElem = selectElement(driver)
		self.frameElem = frameElement(driver)
		self.resource = Resource(driver)
		self.cnEn = cnEncode()

	u'''添加和编辑网络设备资源
	   Parameters:
	      - data:excel中的一行数据
	'''
	def add_edit_network_resource(self, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		if data[3] != 'no':
			self.resource.set_resource_name(data[3])
		#资源ip
		if data[5] != 'no':
			self.resource.set_resource_ip(data[5])
		#从IP
		if data[6] != 'no':
			self.resource.set_resource_fortIps(data[6])
		#归属部门
		if data[4] != 'no':
			self.resource.set_depart(data[4])

		self.resource.select_all_agreement()
		#系统版本
		if data[7] != 'no':
			self.resource.set_sys_version(data[7])
		#改密驱动名称
		if data[8] != 'no':
			self.resource.set_changePwd_driver(data[8])

		#管理员帐号
		if data[9] != 'no':
			self.resource.click_account_sync()
			self.resource.set_admin_account(data[9])
		#管理员口令
		if data[10] != 'no':
			self.resource.set_admin_pwd(data[10])
		#口令确认
		if data[11] != 'no':
			self.resource.set_confirm_pwd(data[11])
		#提权
		if data[12] != 'no':
			self.resource.click_up_super()
			#提权账号口令
			self.resource.set_super_pwd(data[12])
			#确认口令
			self.resource.set_super_confirm_pwd(data[13])
		self.resource.click_save_button()

	u'''校验网络设备资源
	   Parameters:
	      - datarow:excel数据位于第几行
	      - data:excel中的一行数据
	'''
	def check_network_resource(self, datarow, data):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		#资源名称
		self.resource.set_resource_name(data[2])
		#资源ip
		self.resource.set_resource_ip(data[3])
		#协议类型
		if data[4] != 'no':
			self.resource.select_agreement(data[4])
		#协议类型 端口
		if datarow == 7:
			self.resource.set_port(data[4], data[5])
		if datarow == 8:
			self.resource.clear_port("Ssh2")
		if datarow == 9:
			self.resource.set_port("Ssh2", data[5])
		if datarow == 12:
			self.resource.click_account_sync()
			self.resource.click_up_super()
		if datarow == 13:
			#提权账号口令
			if data[6] != 'no':
				self.resource.set_super_pwd(data[6])
			#确认口令
			if data[7] != 'no':
				self.resource.set_super_confirm_pwd(data[7])
			self.resource.set_super_prompt()
		self.resource.click_save_button()

	u'''选择telnet登录模式
	   Parameters:
	      - mode:value属性
	'''
	def telnet_login_type(self, mode):
		model = self.cnEn.is_float(mode)
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		selectelem = self.getElem.find_element_with_wait_EC("id", "fortInputModelTelnet")
		self.selectElem.select_element_by_value(selectelem, model)

	u'''勾选匿名认证'''
	def check_anonymous(self):
		self.frameElem.from_frame_to_otherFrame("mainFrame")
		self.getElem.find_element_wait_and_click_EC("id", "anonymous_auth")