Exemple #1
0
    def Delete(self):
        """ Deletes the instance and its subclients """
        log = loghelper.getLog()
        try:
            log.info("Deleting the instance")
            if self.Check_If_Entity_Exists("link","Delete"):
                self.driver.find_element_by_link_text("Delete").click()
                self.Wait_for_Completion()
                #self.driver.find_element_by_xpath("//input[@id='confirm']/following-sibling::label").click()
                #self.driver.find_element_by_xpath("//button[@class = 'btn btn-primary'").click()
                self.driver.find_element_by_xpath("//body/div[1]/div/div/div[2]/div[3]/input[@type = 'text']").send_keys('DELETE')

                #self.driver.find_element_by_xpath("/html/body/div[1]/div/div/div[2]/div[2]/label[@for ='confirm']").click()
                self.driver.find_element_by_xpath("//div[1]/div/div/div[3]/button[2]").click()
                self.Wait_for_Completion()
                return True,1
            else:
                e = "There is no option to delete the instance"
                log.error(e)
                fn = sys._getframe().f_code.co_name
                return False,fn,e
        except Exception as e:
            log.exception(str(e))
            fn = sys._getframe().f_code.co_name
            return False,fn,str(e)
Exemple #2
0
 def DeleteSub(self, subclient):
     """ Deletes the Subclient from instance properties."""
     log = loghelper.getLog()
     try:
         log.info("Deleting the subclient")
         #self.driver.find_element_by_xpath("//a[text()='" +subclient).click()
         self.driver.find_element_by_link_text(subclient).click()
         self.Wait_for_Completion()
         if self.Check_If_Entity_Exists("link","Delete"):
             self.driver.find_element_by_link_text("Delete").click()
             self.Wait_for_Completion()
             self.driver.find_element_by_xpath("//div[1]/div/div/div[2]/div[3]/input[@type = 'text']").clear()
             self.driver.find_element_by_xpath("//div[1]/div/div/div[2]/div[3]/input[@type = 'text']").send_keys('DELETE')
             self.driver.find_element_by_xpath("//div[1]/div/div/div[3]/button[2][contains(text(), 'Save')]").click()
             self.Wait_for_Completion()
             return True,1
         else:
             e = "Could not delete this subclient"
             log.error(e)
             fn = sys._getframe().f_code.co_name
             return False,fn,e
     except Exception as e:
         log.exception(str(e))
         fn = sys._getframe().f_code.co_name
         return False,fn,str(e)
Exemple #3
0
 def SubmitOracleBackup(self,bkpType, cumulative = False):
     """Submits a backup job """
     log = loghelper.getLog()
     try:
         log.info("Submitting Oracle backup")
         bkpType = bkpType.lower()
         if bkpType == "full":
             bkpType = "FULL"
         #elif bkpType == "incr":
         elif bkpType == "incremental":
             bkpType = "INCREMENTAL"
         else:
             e = "Please type the correct backup option"
             log.error(e)
             fn = sys._getframe().f_code.co_name
             return False, fn, e
         self.driver.find_element_by_xpath(
             "//input[@type='radio' and @value='" + bkpType + "']").click()
         if bkpType == "INCREMENTAL":
             if cumulative:
                 #if not self.driver.find_element_by_xpath("//input[@id='cumulative']").is_selected():
                 self.driver.find_element_by_xpath("//input[@id='cumulative']").click()
         self.driver.find_element_by_xpath("/html/body/div[1]/div/div/div[2]/div/button[3]").click()
         self.Wait_for_Completion()
         return True,1
     except Exception as e:
         log.exception(str(e))
         fn = sys._getframe().f_code.co_name
         return False,fn,str(e)
def JobManipulation(data, retcode, CommServerName):
    log = loghelper.getLog()
    jobId = cmdhelper.getJobId(data)
    (returnCode,
     returnString) = cmdhelper.waitForJobToComplete(jobId, CommServerName)
    if returnString != True:
        log.error("There is issue with the job creation & run")
        return -1
    else:
        return jobId
Exemple #5
0
 def ActionOracleBackupHistory(self, subclient):
     """Opens the backup history of the subclient in an oracle instance
         subclient   : a string, the name of the subclient whose backup history is to be opened
         Returns (True,1), if successful
                 (False, func_name, error_msg), otherwise
     """
     log = loghelper.getLog()
     try:
         log.info(
             "Opening the backup history of the subclient " +
             subclient)
         if self.Check_If_Entity_Exists("link", subclient):
             self.driver.find_element_by_xpath(
                 "//a[contains(text(),'" +
                 subclient +
                 "')]/../../div[3]/div/a/span[@class='grid-action-icon']").click()
             self.Wait_for_Completion()
             self.driver.find_element_by_link_text('Backup history').click()
             self.Wait_for_Completion()
             self.driver.find_element_by_xpath("//span[@class = 'dropdownArrow right']").click()
             self.driver.find_element_by_link_text('All Jobs').click()
             self.Wait_for_Completion()
             jids= self.driver.find_elements_by_class_name("ui-grid-render-container")
             JobID = []
             for i in jids:
                 m = re.findall("\d+",i.text.encode('utf-8'))
                 for j in m:
                     if int(j)>100:
                         JobID.append(j)
                         log.info(str(j))
             if JobID == []:
                 return False
             else:
                 return True
         else:
             e = "There is no option to view the backup history of the subclient from the action menu"
             log.error(e)
             fn = sys._getframe().f_code.co_name
             return False, fn, e
     except Exception as e:
         log.exception(str(e))
         fn = sys._getframe().f_code.co_name
         return False, fn, str(e)
Exemple #6
0
 def AddSubclient(
         self,
         subclientName,
         storagePolicy,
         dataStreams,
         dataBackup,
         dataBackupType,
         ArchiveLog,
         DeleteArchiveLog):
     """Creates a Oracle subclient
         subClient       : a string, name of the subclient we want to associate the backupset to
         storagePolicy   : a string, storage policy we want to associate to with this subclient
         streams         : a string,   the number of streams to be allocated
         dataBackup      : a boolean, True if the data needs to be backedup
         datatype        : a string, type of data to be backed up
         ArchiveLog      : a boolean, True if archive logs needs to be backedup
         DeleteArchiveLog: a boolean, True if archive logs needs to be deleted
         Return (True, 1) on successfull completion
                 (False, func_name, error_msg) otherwise
     """
     log = loghelper.getLog()
     try:
         log.info("Adding a new oracle subclient")
         if self.Check_If_Entity_Exists("link", "Add subclient"):
             self.driver.find_element_by_link_text("Add subclient").click()
             self.Wait_for_Completion()
             ret = self.SubClientForm(subclientName,storagePolicy,dataStreams,dataBackup,dataBackupType,ArchiveLog,DeleteArchiveLog)
             if ret[0]:
                 return True, 1
             else:
                 e = "the subclient creation failed"
                 log.error(e)
                 fn = sys._getframe().f_code.co_name
                 return False, fn, e
         else:
             e = "there is no option to create subclient"
             log.error(e)
             fn = sys._getframe().f_code.co_name
             return False, fn, e
     except Exception as e:
         log.exception(str(e))
         fn = sys._getframe().f_code.co_name
         return False, fn, str(e)
Exemple #7
0
    def GetSubclientDetails(self,sbclnt):#remove entityName and remove if
        log = loghelper.getLog()
        try:
            if sbclnt is not None:
                log.info("Fetching the details of the subclient- %s" %sbclnt)
                '''ret,InstanceDetails=self.GetValuesForEntity()#rename
                if not ret:
                    log.error("Could not get details of the instance")
                    raise Exception(InstanceDetails)'''
                SubclientDetails = {}
                displayedTitle=self.driver.find_element_by_xpath("//h1[@class='float-left ng-binding']")
                SubclientDetails.update({"SubclientName":(displayedTitle.text.encode('utf-8'))})
                #Plan = self.driver.find_element_by_xpath("/div/div[3]/div/div[2]/span/p[@class='info-place-holder']/span/a[@class='ng-binding']")
                #SubclientDetails.update({"Plan": (Plan.text.encode('utf-8'))})
                log.info("Checking content for subclient.")
                self.driver.find_element_by_xpath("//div/div/div/span/cv-subclient-content/div/a[contains(text(),'Edit')]").click()
                if self.driver.find_element_by_id('dataBackup').is_selected():
                    SubclientDetails.update({"dataBackup": 'True'})
                    if self.driver.find_element_by_id('onlineData').is_selected():
                        SubclientDetails.update({"dataBackuptype": 'onlineData'})
                    elif self.driver.find_element_by_id('onlineSubset').is_selected():
                        SubclientDetails.update({"dataBackuptype": 'onlineSubset'})
                    elif self.driver.find_element_by_id('offlineData').is_selected():
                        SubclientDetails.update({"dataBackuptype": 'offlineData'})
                else:
                    SubclientDetails.update({"dataBackup": 'False'})

                if self.driver.find_element_by_id('logBackup').is_selected():
                    SubclientDetails.update({"ArchlogBackup": 'True'})
                    if self.driver.find_element_by_id('deleteArchiveLogs').is_selected():
                        SubclientDetails.update({"deleteArchiveLogs": 'True'})
                    else:
                        SubclientDetails.update({"deleteArchiveLogs": 'False'})
                else:
                    SubclientDetails.update({"ArchlogBackup": 'False'})
                    SubclientDetails.update({"deleteArchiveLogs": 'False'})

                log.info("Subclient details fetched: %s" %SubclientDetails)
                return SubclientDetails
        except Exception as e:
            fn = sys._getframe().f_code.co_name
            log.exception(str(e))
            return False, fn, str(e)
Exemple #8
0
 def ActionOracleRestoreHistory(self, subclient):
     """Opens the restore history of the subclient in an oracle instance
         subclient   : a string, the name of the subclient whose restore history is to be opened
         Returns (True,1), if successful
                 (False, func_name, error_msg), otherwise
     """
     log = loghelper.getLog()
     try:
         log.info(
             "Opening the restore history of the subclient " +
             subclient)
         if self.Check_If_Entity_Exists("link", subclient):
             self.driver.find_element_by_xpath(
                 "//a[contains(text(),'" +
                 subclient +
                 "')]/../../dvi[3]/div/a/span[@class='grid-action-icon']").click()
             self.Wait_for_Completion
             if self.Check_If_Entity_Exists(
                     "xpath",
                     "//a[contains(text(),'" +
                     subclient +
                     "']/../../div[3]/div/ul/li[3]/a[contains(text(),'Backup History')]"):
                 self.driver.find_element_by_xpath(
                     "//a[contains(text(),'" +
                     subclient +
                     "']/../../div[3]/div/ul/li[3]/a[contains(text(),'Backup History')]").click()
                 self.Wait_for_Completion()
             else:
                 e = "There is no option to view the restore history of the subclient from the action menu"
                 log.error(e)
                 fn = sys._getframe().f_code.co_name
                 return False, fn, e
         else:
             e = "There is no subclient with the given name"
             log.error(e)
             fn = sys._getframe().f_code.co_name
             return False, fn, e
         return True, 1
     except Exception as e:
         log.exception(str(e))
         fn = sys._getframe().f_code.co_name
         return False, fn, str(e)
Exemple #9
0
 def Refresh(self):
     """Refreshes the status of the instance
         Returns (True,status), if the refresh was successful
                 (False, fnc_name, error_msg), otherwise """
     log = loghelper.getLog()
     try:
         log.info("Refreshing the status")
         if self.Check_If_Entity_Exists("link", "Refresh"):
             self.driver.find_element_by_link_text("Refresh").click()
             self.Wait_for_Completion()
         else:
             e = "There is no option to refresh the instance."
             log.error(e)
             fn = sys._getframe().f_code.co_name
             return False, fn, e
         return True, 0
     except Exception as e:
         log.exception(str(e))
         fn = sys._getframe().f_code.co_name
         return False, fn, str(e)
Exemple #10
0
 def ManagingClones(self):
     """ Manages Clones."""
     log = loghelper.getLog()
     try:
         if self.Check_If_Entity_Exists("link","Manage clones"):
             self.driver.find_element_by_link_text("Manage clones").click()
             self.Wait_for_Completion()
             log.info("Go for Refresh")
             ret = self.Refresh()
             if ret:
                 log.info("Checking the list of Clones for an instance")
                 jids= self.driver.find_elements_by_class_name("ui-grid-canvas")
                 JobID = []
                 for i in jids:
                     t = i.find_element_by_xpath("./div/div/div/a").text
                     JobID.append(t)
                 if JobID == []:
                     return False
                 else:
                     for i in JobID:
                         log.info(str(i))
                     log.info("printed all the job Ids")
                     return True
                 log.info("Create clone if needed.....")
                 return True,1
             else:
                 return False
         else:
             e = "Could not find the option Manage clones"
             log.error(e)
             fn = sys._getframe().f_code.co_name
             return False,fn,e
     except Exception as e:
         log.exception(str(e))
         fn = sys._getframe().f_code.co_name
         return False,fn,str(e)
Exemple #11
0
 def OpenSubclient(self, sbclnt):
     """ Opens the subclient with the given name.
         sbclnt   : a string, name of the subclient we want to open
         Return (True, 1) on successfull completion
                 (False, func_name, error_msg) otherwise """
     log = loghelper.getLog()
     try:
         log.info("opening SubClient " + sbclnt)
         #self.SearchFor(instance)
         if self.Check_If_Entity_Exists("link", sbclnt):
             self.driver.find_element_by_link_text(sbclnt).click()
             self.Wait_for_Completion()
             return True, 1
         else:
             self.ErroroutScreenShot()
             e = "There is no subclient with the name " + sbclnt
             log.error(e)
             fn = sys._getframe().f_code.co_name
             return False, fn, e
     except Exception as e:
         self.ErroroutScreenShot()
         fn = sys._getframe().f_code.co_name
         log.exception(str(e))
         return False, fn, str(e)
def tearDown(CurrentRun):
    "Tear Down function"
    log = loghelper.getLog()
    log.info("This is teardown function of %s Testcase" %
             CurrentRun.getTestCaseName())
def run(CurrentRun):
    "Run function"
    setup(CurrentRun)
    log = loghelper.getLog()
    try:
        answers = CurrentRun.getAnswers()
        DataAgentType = str(answers['DataAgentType'])
        CommServerName = str(answers['CommServerName'])
        Usr = AutomationConstants.CV_AUTOMATION_USR
        Pwd = AutomationConstants.CV_AUTOMATION_PWD
        DefaultStoragePolicy = str(answers['DefaultStoragePolicy'])
        SnapCopyName = "SNAP_COPY"
        ClientName = str(answers['ClientName'])
        ClientHostName = str(answers['ClientHostName'])
        ConnectUser = str(answers['ConnectUser'])
        ConnectPassword = str(answers['ConnectPassword'])
        ConnectString = str(answers['ConnectString'])
        Instance = str(answers['InstanceName'])
        RemoteMachineUserName = str(answers['RemoteMachineUserName'])
        RemoteMachinePassword = str(answers['RemoteMachinePassword'])
        OSType = str(answers['OSType'])
        LocalDBTNSNamesPath = str(answers['LocalDBTNSNamesPath'])
        LogStoragePolicy = str(answers['LogStoragePolicy'])
        CmdStoragePolicy = str(answers['CmdStoragePolicy'])
        CatalogConnectEnable = str(answers['CatalogConnectEnable'])
        CatalogUser = str(answers['CatalogUser'])
        CatalogPassword = str(answers['CatalogPassword'])
        CatalogConnectString = str(answers['CatalogConnectString'])
        OracleUser = str(answers['OracleUser'])
        OracleUserPassword = str(answers['OracleUserPassword'])
        MAName = str(answers['MAName'])
        LibraryName = str(answers['LibraryName'])
        SimpanaInstanceName = str(answers['SimpanaInstance'])
        ResultFlag = False

        SnapVendorName = str(answers['SnapVendor'])
        #SMArrayId =  str(answers['ArrayID'])
        #ControlHost = str(answers['ControlHost'])
        #SMHostUserName = str(answers['ArrayUserName'])
        #SMHostPassword = str(answers['ArrayPassword'])
        #DeviceGroup = str(answers['DeviceGroup'])
        tblCountG = 0

        ##testCaseID = CurrentRun.getTestCaseName()
        cmdhelper.cvLogout(CommServerName)
        csn, b, c, d = CommServerName.split(".")
        log.info("CSN Name:" + str(csn))
        (_retcode, _retval) = cmdhelper.cvLogin(CommServerName, Usr, Pwd,
                                                str(csn))
        if _retcode != 0:
            log.error("Login Failed")
            return 1
        else:
            ResultFlag = True
            log.info("Done - Login to CommServe")

        log.info("SNAP BACKUP - Creating Storagepolicy if it doesnot exist.")
        retcode = storagepolicyhelper.spExists(CommServerName,
                                               DefaultStoragePolicy)
        if retcode == False:
            retcode = storagepolicyhelper.createStoragePolicy(
                CommServerName, DefaultStoragePolicy, MAName, LibraryName, 5)
            if retcode != True:
                ResultFlag = False
                log.exception("Error creating " + DefaultStoragePolicy +
                              " Storage Policy.")
                raise
            else:
                ResultFlag = True
                log.info("Success - Creating " + DefaultStoragePolicy +
                         " StoragePolicy.")
        else:
            ResultFlag = True
            log.info(" StoragePolicy " + DefaultStoragePolicy +
                     " exists. Skipping...")

        log.info("SNAP BACKUP - Creating SNAP COPY if it does not exist.")
        retcode = storagepolicyhelper.SPCopyExists(CommServerName,
                                                   DefaultStoragePolicy,
                                                   SnapCopyName)
        if retcode == False:
            log.info("Creating secondary copy ")
            result = storagepolicyhelper.createSnapCopy(
                CommServerName, DefaultStoragePolicy, SnapCopyName, MAName,
                LibraryName)
            if result != True:
                ResultFlag = False
                log.error("Creating Snap copy failed")
                loghelper.setResultString("Creating Snap copy failed")
                return 4
            else:
                ResultFlag = True
                log.info("Success - Creating " + SnapCopyName +
                         " StoragePolicy.")
        else:
            ResultFlag = True
            log.info(" StoragePolicy " + SnapCopyName + " exists. Skipping...")

        log.info("Make oracle instance entry in tnsnamesora file")
        (retCode, retString) = oraclehelper.UpdateTNSNamesOraFile(
            LocalDBTNSNamesPath, ClientHostName, ConnectString)
        if retCode == -1:
            raise
        ##connect to DB and create a table
        (retCode, retString, conn,
         curs) = oraclehelper.connectOracle(ConnectUser, ConnectPassword,
                                            ConnectString)
        if retCode == -1:
            log.error("OperationalError: ORA-01034: ORACLE not available")
            raise

        (_retCode,
         state) = oraclehelper.GetDatabaseState(ConnectUser, ConnectPassword,
                                                ConnectString)
        if _retCode != 0 or state != "OPEN":
            log.error(" Database is not in open state.")
            try:
                curs.execute('alter database open')
            except:
                raise

        if OSType.lower() != "windows":
            sshConn = remoteconnection.Connection(
                ClientHostName,
                OS="unix",
                username=RemoteMachineUserName,
                password=RemoteMachinePassword)
            #SimpanaInstanceName=UnixHelper.getInstanceName(ClientHostName, CommServerName,RemoteMachineUserName, RemoteMachinePassword)
            SimpanaLogDirectory = UnixHelper.getLogDirectoryPath(
                ClientHostName, SimpanaInstanceName, RemoteMachineUserName,
                RemoteMachinePassword)
            SimpanaLogDirectory = SimpanaLogDirectory + "/"

        else:
            sshConn = remoteconnection.Connection(
                ClientHostName,
                OS="windows",
                username=RemoteMachineUserName,
                password=RemoteMachinePassword)
            (retCode, SimpanaLogDirectory) = clienthelper.getSimpanaLogDir(
                CommServerName, ClientName, "CC")
            SimpanaLogDirectory = SimpanaLogDirectory + "\\"

        (retCode, LocalPath) = oraclehelper.getCommonDirPath()
        retCode = oraclehelper.hasInstance(CommServerName, ClientName,
                                           DataAgentType, Instance)
        if retCode == False:
            log.info("Instance doesnot exist. so we need to create ")
            OracleHome = oraclehelper.getOracleHomePath(
                Instance, ClientHostName, RemoteMachineUserName,
                RemoteMachinePassword, OSType)
            if OracleHome == 'None':
                raise
            (_retstring, _retval) = oraclehelper.createOracleInstance(CommServerName, ClientName, Instance, DataAgentType, \
                                                                      OracleHome, ConnectUser, ConnectPassword, ConnectString, DefaultStoragePolicy, \
                                                                      LogStoragePolicy, CmdStoragePolicy, CatalogConnectEnable, CatalogUser, CatalogPassword, \
                                                                      CatalogConnectString, OracleUser, OracleUserPassword)

            if (_retstring == None or _retstring == False):
                log.error("Instance creation is failed")
                raise

        log.info("######## SNAP SHOT BACKUP ONLY ########")

        log.info(
            "#### CASE 1: Run SNAP and then run offline backup copy #####")

        log.info("### Enable SNAP Protect at Client Level ###")
        log.info("Client Name:" + ClientName)
        retcode = clienthelper.EnableSnapProtectOnClient(
            CommServerName, ClientName)
        if retcode != True:
            log.error("Failed to enable Snap Protect on %s" % (ClientName))
            loghelper.setResultString("Failed to enable snapprotect on client")
            return 5

        ###STEP2:CREATE A SUBCLIENT AND FROM THE CONTENT TAB SELECT ONLINE DATABASE,BACKUP ARCHIVE LOG OPTION###
        log.info(
            "###CREATE OF SUBCLIENT WITH PROPERTIES SELECT ONLINE DATABASE AND BACKUP ARCHIVE LOG STARTS HERE###"
        )

        SubClientName = "SNAP_OFFLINE_BACKUP_COPY"

        retCode = subclienthelper.hasSubclient(CommServerName, ClientName,
                                               DataAgentType, None,
                                               SubClientName, Instance)
        if retCode == False:
            "SNAP BACKUP: Selective Online Full- Subclient doesnot exist so we need to create New Subclient"
            retCode = oraclehelper.CreateOracleSubclient(
                CommServerName, ClientName, Instance, SubClientName,
                DefaultStoragePolicy)
            if retCode != True:
                log.error("error while creating Subclient")
                raise

        "SNAP BACKUP: Enable Selective Online Full-"
        (retCode,
         retString) = oraclehelper.setSubclientPropSelectiveOnlineFullON(
             CommServerName, ClientName, Instance, SubClientName)
        if (retCode == None or retCode == False):
            log.error(
                "Failed to Enable Selective Online Full property for subclient"
            )
            raise

        tblSpaceG = "TS_SNAP"
        tblNameG = "TBL_SNAP"
        tblCountG += 1

        ###Creating a tablespace and tables##
        log.info("SNAP - Creating some test data##")
        (retCode, retString,
         firstrow) = oraclehelper.getDatafile(curs, tblSpaceG, OSType)
        log.info("firstrow we got is " + firstrow)
        if retCode == -1:
            log.error("Database is not in mounted state")
            raise

        (_retCode,
         _retString) = oraclehelper.createTable(curs, firstrow, tblSpaceG,
                                                tblNameG + str(tblCountG),
                                                True)
        if _retCode != 0:
            log.error("Failed to create table in tablespace")
            raise

        log.info("Enable Snap Protect Details on subclient")

        (retCode, retString) = oraclehelper.EnableSubclientSnapProtectDetails(
            CommServerName, ClientName, Instance, SubClientName,
            SnapVendorName)
        # (_retCode,_data)=cmdhelper.executeCommand(r"qoperation execute -af update_subclient_template.xml -appName Oracle -clientName " + ClientName +
        #            " -cs " + CommServerName + " -instanceName " + Instance + " -subclientName " + SubClientName +
        #    " -isRMANEnableForTapeMovement true " + " -isSnapBackupEnabled true " +
        #       " -snapShotEngineName " + SnapVendorName + " -StoragePolicyName " + DefaultStoragePolicy )

        SPCopyID = storagepolicyhelper.getCopyIDBySPandCopyName(
            DefaultStoragePolicy, SnapCopyName, CommServerName)
        log.info("Secondary copy copy id:%s" % (SPCopyID))

        result = storagepolicyhelper.updateSPCopyRetention(
            SPCopyID, 1, 0, CommServerName)
        log.info("Changed the Retention on Snap Copy to 0 days 1 cycle")

        log.info("Start Backup and wait for the job to complete ")
        #log.info(" [%s] Backup Start for TC - [%s]" %(backupType, testCaseID))
        retCode, data = cmdhelper.executeCommand(
            "qoperation execute -af SNAP_BACKUP.xml" + " -cs " +
            CommServerName + " -clientName " + ClientName + " -instanceName " +
            Instance + " -subclientName " + SubClientName +
            " -backupLevel FULL")
        if retCode != 0:
            log.error("Failed to start backup")
            cmdhelper.cvLogout(CommServerName)
            return 1

        #wait for the job to complete
        log.info("Waiting for Backup job to complete")
        if cmdhelper.waitForJobToComplete(cmdhelper.getJobId(data),
                                          CommServerName) != (0, True):
            log.info("Backup Job failed to complete. Script exiting")
            cmdhelper.cvLogout(CommServerName)
            return 1

        #log.info("[%s] Backup Job completed successfully" %backupType)
        log.info("SNAP BACKUP COPY - Running offline SNAP Backup copy.")
        #log.info(" [%s] Backup Start for TC - [%s]" %(backupType, testCaseID))
        (_retCode, _data) = cmdhelper.executeCommand(
            "qoperation execute -af BACKUP_COPY.xml" + " -cs " +
            CommServerName + " -storagePolicyName " + DefaultStoragePolicy)

        #wait for the job to complete
        log.info("Waiting for Backup job to complete")
        if _retCode == -1:
            log.error("Failed to start qoperation backup operation")
            raise
        jobId = JobManipulation(_data, _retCode, CommServerName)
        if jobId == -1:
            raise

        CommServerTimeZone = oraclehelper.getCommServerTimeZone(CommServerName)
        ####Submitting restore job from SNAP backup###
        log.info("SNAP - Submitting restore job from SNAP BACKUP ###")
        (_retCode,_data)=cmdhelper.executeCommand(r"qoperation execute -af RESTORE_FROM_SNAP.xml -clientName " + \
                                                  ClientName + " -cs " + CommServerName + " -instanceName " + Instance + " -oracleOpt/catalogConnect1 " + CatalogUser + " -oracleOpt/catalogConnect2/password " + \
       CatalogPassword+ " -oracleOpt/catalogConnect3 " + CatalogConnectString + " -TimeZoneName " + "\"" + CommServerTimeZone + "\"")

        #wait for the job to complete
        log.info("Waiting for Backup job to complete")
        if _retCode == -1:
            log.error("Failed to start qoperation backup operation")
            raise
        jobId = JobManipulation(_data, _retCode, CommServerName)
        if jobId == -1:
            raise
        else:
            ResultFlag = True
        log.info(
            "SNAP BACKUP - Submitting another SNAP backup to REVERT from this SNAP BACKUP ###"
        )
        retCode, data = cmdhelper.executeCommand(
            "qoperation execute -af SNAP_BACKUP.xml" + " -cs " +
            CommServerName + " -clientName " + ClientName + " -instanceName " +
            Instance + " -subclientName " + SubClientName +
            " -backupLevel FULL")
        if retCode != 0:
            log.error("Failed to start backup")
            cmdhelper.cvLogout(CommServerName)
            return 1

        #wait for the job to complete
        log.info("Waiting for Backup job to complete")
        if cmdhelper.waitForJobToComplete(cmdhelper.getJobId(data),
                                          CommServerName) != (0, True):
            log.info("Backup Job failed to complete. Script exiting")
            cmdhelper.cvLogout(CommServerName)
            return 1

        ####Submitting restore job from SNAP backup###
        log.info("SNAP - Submitting REVERT restore job from SNAP BACKUP ###")

        (_retCode,_data)=cmdhelper.executeCommand(r"qoperation execute -af RESTORE_FROM_SNAP.xml -revert true -useRmanRestore true -clientName " + \
             ClientName + " -cs " + CommServerName + " -instanceName " + Instance + " -oracleOpt/catalogConnect1 " + CatalogUser + " -oracleOpt/catalogConnect2/password " + \
              CatalogPassword+ " -oracleOpt/catalogConnect3 " + CatalogConnectString + " -TimeZoneName " + "\"" + CommServerTimeZone + "\"")
        '''(_retCode,_data)=cmdhelper.executeCommand(r"qoperation execute -af RESTORE_FROM_SNAP.xml -revert true -clientName " + \
                                                  ClientName + " -cs " + CommServerName + " -instanceName " + Instance + " -TimeZoneName " + "\"" + CommServerTimeZone + "\"")'''

        #wait for the job to complete
        log.info("Waiting for Backup job to complete")
        if _retCode == -1:
            log.error("Failed to start qoperation backup operation")
            raise
        jobId = JobManipulation(_data, _retCode, CommServerName)
        if jobId == -1:
            raise
        else:
            ResultFlag = True

        #Compare data from restore
        log.info("Data Comparison - Start.")

        #log.info("TEST CASE - [%s] - [%s] FINISHED SUCCESSFULLY." %(testCaseID, testCaseName))

        cmdhelper.cvLogout(CommServerName)
        #oraclehelper.removeCommonDir()
        if ResultFlag != False:
            log.info("TC 39393-PASSED")
            return 0
        else:
            log.info("TC-39393  - FAILED")
            return 1
    except:
        log.exception("Exception in testcase-run")
        log.error("Exception Raised. Execution of Test Case [%s] Failed." %
                  testCaseID)
        log.error(traceback.format_exc().splitlines())
        return 1
    finally:
        tearDown(CurrentRun)
Exemple #14
0
 def SubClientForm(
         self,
         subclientName,
         storagePolicy,
         dataStreams,
         dataBackup,
         dataBackupType,
         ArchiveLog,
         DeleteArchiveLog):
     """Creates a Oracle subclient
         subClient       : a string, name of the subclient we want to associate the backupset to
         storagePolicy   : a string, storage policy we want to associate to with this subclient
         streams         : a string,   the number of streams to be allocated
         dataBackup      : a boolean, True if the data needs to be backedup
         datatype        : a string, type of data to be backed up
         ArchiveLog      : a boolean, True if archive logs needs to be backedup
         DeleteArchiveLog: a boolean, True if archive logs needs to be deleted
         Return (True, 1) on successfull completion
                 (False, func_name, error_msg) otherwise
     """
     log = loghelper.getLog()
     try:
         self.Wait_for_Completion()
         log.info('Fills the subclient form')
         self.driver.find_element_by_xpath("//input[@name = 'subclientName']").clear()
         self.driver.find_element_by_xpath("//input[@name = 'subclientName']").send_keys(subclientName)
         # /html/body/div[1]/div/div/div[2]/form/div/label[2]/span[2]/isteven-multi-select/span/button
         self.driver.find_element_by_xpath("//div[1]/div/div/div/form/div[1]/div/div[2]/div/isteven-multi-select/span/button[@type='button' and @class='ng-binding']").click()
         #self.driver.find_element_by_xpath("//div[1]/div/div/div[2]/form/div/label[2]/span[2]/isteven-multi-select/span/button[@type='button' and @class='ng-binding']").click()
         parent = self.driver.find_elements_by_xpath("//div/div[@class='checkBoxContainer']/div")
         for i in parent:
             t = i.find_element_by_xpath("./div/label/span").text
             t = t.strip()
             t = t.replace(" ","")
             #log.info("Found plan:"+t)
             if t.find(storagePolicy)>=0:
                 log.info("matched")
                 i.find_element_by_xpath("./div/label/input/following-sibling::span").click()
                 break
             else:
                 continue
         self.Wait_for_Completion()
         self.driver.find_element_by_id('numberBackupStreams').clear()
         self.driver.find_element_by_id('numberBackupStreams').send_keys(dataStreams)
         if dataBackup == "False":
             log.info("Databackup is not required, so unchecking it")
             self.driver.find_element_by_xpath("//div[1]/div/div/div[2]/form/div/label[4]/span[1]/label[@for = 'dataBackup']").click()
         else:
             log.info("Databackup is true, selecting the datatype: " +dataBackupType)
             #self.driver.find_element_by_xpath("//input[@id='" + dataBackupType + "' and @type='radio']").click()
             self.driver.find_element_by_xpath("//input[@id='" + dataBackupType + "']").click()
         if ArchiveLog == "False":
             log.info("Archivelog is not required, so unchecking it")
             self.driver.find_element_by_xpath("//div[1]/div/div/div[2]/form/div/label[5]/span[1]/label[@for = 'logBackup']").click()
         else:
             log.info("Archivelog is required, checking if delete archive logs is required")
             if DeleteArchiveLog == "False":
                 log.info("DeleteArchivelog is not required so unchecking it")
                 self.driver.find_element_by_xpath("//div[1]/div/div/div[2]/form/div/label[6]/span[1]/label[@for = 'deleteArchiveLogs']").click()
         self.driver.find_element_by_xpath("//form/div/div[3]/button[2][@type = 'submit' and @class='btn btn-primary cvBusyOnAjax']").click()
         self.Wait_for_Completion()
         if self.Check_If_Entity_Exists("xpath", "//span[@class='error']"):
             warn = self.driver.find_element_by_xpath("//span[@class='error']").text
             log.info(str(warn))
             '''Closing the input form'''
             self.driver.find_element_by_xpath("//button[@type='button']").click()
             self.Wait_for_Completion()
             log.error(str(warn))
             fn = sys._getframe().f_code.co_name
             return False, fn, str(warn)
         else:
             return True, 1
     except Exception as e:
         log.exception(str(e))
         fn = sys._getframe().f_code.co_name
         return False, fn, str(e)
def setup(CurrentRun):
    "Set up function"
    log = loghelper.getLog()
    log.info("This is setup function of %s Testcase" %
             CurrentRun.getTestCaseName())
Exemple #16
0
 def ActionBackup(self, subclient, bkpLevel, cumulative):
     """Backups the subclient
         subclient   : a string, name of the subclient to be backed up
         bkpLevel    : a string, the type of backup to be performed
         cumulative  : a boolean, to decide if cumulative incremental backup needs to be done
         Return  (True,jobID), if the backup was submitted successfully
                 (False, func_name, error_msg), otherwise
     """
     log = loghelper.getLog()
     try:
         log.info("Backing up the subclient " + subclient)
         if self.Check_If_Entity_Exists("link", subclient):
             self.driver.find_element_by_xpath("//a[contains(text(),'" +subclient +"')]/../../div[3]/div/a/span[@class='grid-action-icon']").click()
             if self.Check_If_Entity_Exists("link", "Back up now"):
                 #self.driver.find_element_by_xpath("//div[1]/div[2]/div[2]/div/div[3]/div/div[3]/div/ul/li[1]/a[contains(text(),'Back up now')]").click()
                 self.driver.find_element_by_link_text('Back up now').click()
                 self.Wait_for_Completion()
                 #self.SubmitOracleBackup(bkpLevel, cumulative)
                 if bkpLevel == "FULL":
                     log.info('Full backup')
                     self.driver.find_element_by_xpath("//div[1]/div/div/div[2]/span[3]/div[2]/label[1]/input[@type='radio' and @value='" + bkpLevel + "']").click()
                 elif bkpLevel == "INCREMENTAL":
                     log.info('cumulative: '+ cumulative)
                     if cumulative == "True":
                         #self.driver.find_element_by_xpath("//input[@id='cumulative']").click()
                         self.Wait_for_Completion()
                         self.driver.find_element_by_xpath("//div[1]/div/div/div[2]/span[3]/div[2]/label[3]/label[@for ='cumulative']").click()
                         log.info('Cumulative also checked with Incremental')
                     else:
                         log.info('Only Incremental backup')
                 else:
                     e = "Please type the correct backup option"
                     log.error(e)
                     fn = sys._getframe().f_code.co_name
                     return False, fn, e
                 self.driver.find_element_by_xpath("/html/body/div[1]/div/div/div[2]/div/button[3]").click()
                 log.info('Backup Job submitted, Fetching job details...')
                 self.Wait_for_Completion()
                 JobText = self.driver.find_element_by_xpath("//div[@class='global-options remove-border-padding ng-binding']").text
                 log.info(JobText)
                 JobId = JobText.split("Job ")[-1].split(".")[0].strip()
                 JobID = int(JobId)
                 JID = str(JobID)
                 log.info("Backup job " + str(JobID) + " has started")
                 log.info("Checking status: ")
                 self.driver.find_element_by_xpath("//div[1]/div/div/div[2]/span[1]/div/a[contains(text(),' View job details')]").click()
                 self.Wait_for_Completion()
                 return True, str(JobID)
             else:
                 e = "there is no option to submit a backup"
                 log.error(e)
                 fn = sys._getframe().f_code.co_name
                 return False, fn, e
         else:
             e = "Could not find the subclient: " + subclient
             log.error(e)
             fn = sys._getframe().f_code.co_name
             return False, fn, e
     except Exception as e:
         log.exception(str(e))
         fn = sys._getframe().f_code.co_name
         return False, fn, str(e)
Exemple #17
0
    def EditInstance(self,
            Instance,
            oracleHome,
            osusername,
            osuserpassword,
            dbusername,
            dbpassword,
            instanceName,
            dbStoragePolicy,
            logStoragePolicy):
        """ Edits the instance with the given name.
            Instance        : a string, name of the Instance we want to add
            oracleHome      : a string, name of the Oracle home
            osusername      : a string, name of the oracle user
            osuserpassword  : a string, name of the oracle user password
            dbusername      : a string, the database username
            dbpassword      : a string, the database password
            instanceName    : a string, database instance name
                Return (True, 1) on successfull completion
                        (False, func_name, error_msg) otherwise
        """
        log = loghelper.getLog()
        try:
            log.info("Editing the required Instance")
            if self.Check_If_Entity_Exists("xpath", "//a[@data-ng-click = 'editInstance(instanceDetails.instance,true,instanceDetails)']"):
                self.driver.find_element_by_xpath("//a[@data-ng-click = 'editInstance(instanceDetails.instance,true,instanceDetails)']").click()
                self.Wait_for_Completion()
                self.driver.find_element_by_id("instanceName").clear()
                self.driver.find_element_by_id("instanceName").send_keys(Instance)
                self.driver.find_element_by_id("oracleHome").clear()
                self.driver.find_element_by_id("oracleHome").send_keys(oracleHome)
                self.driver.find_element_by_id("osUserName").clear()
                self.driver.find_element_by_id("osUserName").send_keys(osusername)
                #self.driver.find_element_by_id("osUserPassword").clear()
                #self.driver.find_element_by_id("osUserPassword").send_keys(osuserpassword)
                self.driver.find_element_by_id("dbUserName").clear()
                self.driver.find_element_by_id("dbUserName").send_keys(dbusername)
                self.driver.find_element_by_id("dbPassword").clear()
                self.driver.find_element_by_id("dbPassword").send_keys(dbpassword)
                self.driver.find_element_by_id("dbInstanceName").clear()
                self.driver.find_element_by_id("dbInstanceName").send_keys(instanceName)
                '''Submitting the form'''
                self.driver.find_element_by_xpath("//button[@type='submit']").click()
                '''checking if any error message after filling the form.'''
                self.Wait_for_Completion()
                if self.Check_If_Entity_Exists("xpath", "//span[@class='error']"):
                    warn = self.driver.find_element_by_xpath("//span[@class='error']").text
                    log.info(str(warn))
                    '''Closing the input form'''
                    self.driver.find_element_by_xpath("//button[@type='button']").click()
                    self.Wait_for_Completion()
                    log.error(str(warn))
                    fn = sys._getframe().f_code.co_name
                    return False, fn, str(warn)
                else:
                    return True, 1
                '''
                Old form
                self.driver.find_element_by_id(
                    "osUserPassword").send_keys(OSpwd)
                self.driver.find_element_by_id("dbPassword").send_keys(OSpwd)
                self.driver.find_element_by_id("dbInstanceName").clear()
                self.driver.find_element_by_id("dbInstanceName").send_keys(SID)

                Select(self.driver.find_element_by_id("DBStoragePolicy")
                       ).select_by_visible_text(cmdlineSP)
                Select(self.driver.find_element_by_id(
                    "LogStoragePolicy")).select_by_visible_text(LogSP)

                self.driver.find_element_by_xpath(
                    "//form/div[2]/button[2]").click()
                self.Wait_for_Completion()

                return True, 1'''
            else:
                e = "There is no way to edit the instnace: ", Instance
                log.error(e)
                fn = sys._getframe().f_code.co_name
                return False, fn, e

        except Exception as e:
            fn = sys._getframe().f_code.co_name
            log.exception(str(e))
            return False, fn, str(e)