Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.95 KB | None | 0 0
  1. package com.ipswitch.automation.ft.central.webadmin.tests;
  2.  
  3. import static com.ipswitch.automation.ft.central.webadmin.utils.SessionContainer.getCentralApi;
  4. import static com.ipswitch.automation.ft.central.webadmin.utils.SessionContainer.putCentralApi;
  5.  
  6. import com.ipswitch.automation.ft.central.webadmin.api.GeneralApiHelper;
  7. import com.stdnet.moveit.MICentralAPIInternal;
  8. import org.testng.annotations.BeforeTest;
  9. import org.testng.annotations.Test;
  10.  
  11. public class Generator {
  12.  
  13.     String sftpTemplate = "<SSHFTP Host=\"1.1.1.1\" ID=\"%s\"  Name=\"SFTP_%s\"></SSHFTP>";
  14.  
  15.     String tasktesmplate = "<Task Active=\"0\" AR=\"0\" CacheNames=\"random\" NextEID=\"12\" TT=\"\" UseDefStateCaching=\"1\" ID=\"%s\" Name=\"%s\">\n" +
  16.         "            <Schedules/>\n" +
  17.         "            <NextActions/>\n" +
  18.         "            <Info>\n" +
  19.         "                <Description></Description>\n" +
  20.         "                <Notes></Notes>\n" +
  21.         "            </Info>\n" +
  22.         "            <Source DeleteOrig=\"0\" DelRename=\"1\" ExFile=\"\" ExFo=\"\" FileMask=\"*.*\" NewFilesOnly=\"0\" RenameTo=\"\" Unzip=\"0\" BlindDL=\"0\" ClientKeyID=\"0\" ConnTimeoutSecs=\"120\" HostID=\"%s\" MxBy=\"0\" MxFi=\"0\" MD5File=\"MD5SUM\" MD5Get=\"Never\" Path=\"\" RescanSecs=\"0\" RetryIfNoFiles=\"0\" Rsm=\"0\" SearchSubdirs=\"0\" Type=\"SSHFTP\" UDMxBy=\"1\" UDMxFi=\"1\" UseDefBlindDL=\"1\" UseDefClientKey=\"1\" UseDefConnTimeoutSecs=\"1\" UseDefMD5File=\"1\" UseDefMD5Get=\"1\" UseDefRescanSecs=\"1\" UseDefRetryCount=\"1\" UseDefRetryTimeoutSecs=\"1\" UseDefRsm=\"1\" UseDefUser=\"1\" Username=\"\" Password=\"\" ID=\"11\" RetryCount=\"0\" RetryTimeoutSecs=\"30\"/>\n" +
  23.         "        </Task>";
  24.  
  25.     GeneralApiHelper generalApiHelper;
  26.  
  27.     @BeforeTest
  28.     public void setUp() {
  29.         putCentralApi(new MICentralAPIInternal());
  30.         generalApiHelper = GeneralApiHelper.getInstance();
  31.         generalApiHelper.connect();
  32.     }
  33.  
  34.     @Test
  35.     public void createSftpHosts() {
  36.         int initHostId = 320000000;
  37.  
  38.         boolean result;
  39.         for (int i = initHostId; i < initHostId + 100; i++) {
  40.  
  41.             String id = String.valueOf(i);
  42.             String host = String.format(sftpTemplate, id, id);
  43.             result = getCentralApi().createItem("Host", id, host);
  44.  
  45.             if (result) {
  46.                 System.out.println(id + " created");
  47.             } else {
  48.                 System.out.println(id + " failed");
  49.             }
  50.         }
  51.  
  52. //        int initTaskId = 220000000;
  53. //
  54. //        for (int i = initTaskId; i < initTaskId + 99; i++) {
  55. //
  56. //            String id = String.valueOf(i);
  57. //            String task = String.format(tasktesmplate, id, id, i - 100000000);
  58. //            result = getCentralApi().createItem("Task", id, task);
  59. //
  60. //            if (result) {
  61. //                System.out.println(id + " created");
  62. //            } else {
  63. //                System.out.println(id + " failed");
  64. //            }
  65. //        }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement