REST 명령을 사용하여 애플리케이션 배치: 예

다음 예에서는 REST 명령을 사용하여 애플리케이션을 배치하는 방법을 설명합니다.

시작하기 전에

이 예에서는 단순 helloWorld 배치 작성 학습서의 단계에 따릅니다. 이 예에 따라 수행하기 전에 학습서를 검토하십시오. helloWorld 학습서 시스템 구성에서 설명한 대로 시스템을 구성하십시오. 서버 이름, 사용자 이름 및 비밀번호를 적절한 값으로 대체하십시오.

이 태스크 정보

이 예는 REST 명령을 실행하기 위해 Linux curl 프로그램을 사용하는 방법을 표시합니다. 수많은 다양한 프로그램 또는 프로그래밍 언어를 사용하여 REST 명령을 실행할 수 있습니다. 코드가 명령행에서 사용자 이름 및 비밀번호를 지정하여 서버와 인증합니다. REST 명령 실행 및 인증에 대한 자세한 정보는 REST 명령 실행REST 명령 인증의 내용을 참조하십시오.

이 예에서 사용되는 서버는 server.example.com입니다. 사용자는 nsmith이며 비밀번호는 passwd입니다.

프로시저

  1. 컴포넌트를 작성하고 가져오십시오.
    1. createComponent PUT 명령을 사용하여 컴포넌트를 작성하십시오.
      curl -k -u nsmith:passwd
        https://server.example.com:8443/cli/component/create
        -X PUT -d @newComponent.json
      참고: 명령을 한 행에 입력해야 합니다. 여기에서는 명료하게 표시하기 위해 명령이 여러 행으로 구분되어 있습니다.
      다음 JSON 파일은 컴포넌트를 나타냅니다.
      {
        "name": "helloWorld",
        "description": "",
        "importAutomatically": false,
        "useVfs": true,
        "sourceConfigPlugin": "File System (Versioned)",
        "defaultVersionType": "FULL",
        "properties": {
          "FileSystemVersionedComponentProperties/basePath": "/home/user1/artifacts/shared/helloWorld"
        }
      }
      이 명령은 다음 JSON 정보와 유사한 결과를 리턴합니다.
      {
        "id":"cf355787-a772-4533-be45-3e169e9da6eb",
        "securityResourceId":"23504603-ab8c-4740-bc2d-d18c08f790e9",
        "name":"helloWorld",
        "description":"",
        "created":1396878409753,
        "importAutomatically":false,
        "useVfs":true,
        "active":true,
        "integrationFailed":false,
        "deleted":false,
        "defaultVersionType":"FULL",
        "cleanupDaysToKeep":0,
        "cleanupCountToKeep":0,
        "tags":[],
        "user":"nsmith"
      }
    2. setComponentProperty PUT 명령을 사용하여 컴포넌트 특성을 설정하십시오.
      curl -k -u nsmith:passwd
        "https://server.example.com:8443/cli/
        component/propValue?component=helloWorld&name=helloHome&value=c%3A%5ChelloWorld" -X PUT
      이 명령은 다음 JSON 정보와 유사한 결과를 리턴합니다.
      {
        "id":"194b6e0c-3f30-4d9a-b3cf-dd61dd1a7328",
        "name":"helloHome",
        "value":"c:\\helloWorld",
        "secure":false
      }
    3. importVersions PUT 명령을 사용하여 컴포넌트 버전을 가져오십시오.
      curl -k -u nsmith:passwd
        https://server.example.com:8443/cli/component/integrate
        -X PUT -d {"component":"helloWorld"}
      이 명령은 다음 결과를 리턴합니다.
      {}
  2. createComponentProcess PUT 명령을 사용하여 컴포넌트 프로세스를 작성하십시오.
    curl -k -u nsmith:passwd
      https://server.example.com:8443/cli/componentProcess/create
      -X PUT -d @componentProcess.json
    다음 JSON 파일은 이 컴포넌트 프로세스를 나타냅니다.
    {
      "active": "true",
      "component": "helloWorld",
      "configActionType": "ADD",
      "defaultWorkingDir": "${p:resource/work.dir}/${p:component.name}",
      "description": "",
      "inventoryActionType": "ADD",
      "name": "helloProcess",
      "propDefs": [],
      "rootActivity": {
        "children": [
          {
            "allowFailure": false,
            "children": [],
            "commandName": "Delete Files and Directories",
            "impersonationUseSudo": false,
            "name": "Clean work space",
            "pluginName": "File Utils",
            "pluginVersion": 31,
            "properties":{
                "baseDir":".",
                "includes":"*",
                "excludes":"",
                "followSymlinks":"false",
                "caseSensitive":"true"
             },
            "showHidden": false,
            "type": "plugin",
            "useImpersonation": false
          },
          {
            "allowFailure": false,
            "children": [],
            "commandName": "Download Artifacts",
            "impersonationUseSudo": false,
            "name": "Download Artifacts",
            "pluginName": "IBM UrbanCode Deploy Versioned File Storage",
            "pluginVersion": 18,
            "properties":{
               "directoryOffset":".",
               "artifactSetBaseDir":"",
               "fileIncludePatterns":"**/*",
               "fileExcludePatterns":"",
               "syncMode":"true",
               "fullVerification":"true",
               "setFileExecuteBits":"false",
               "verifyFileIntegrity":"false",
               "repositoryUrl":"${p:server.url}/vfs",
               "repositoryId":"${p:component/code_station/repository}",
               "label":"${p:version.name}",
               "serverUrl":"${p:server.url}",
               "compId":"${p:component.id}",
               "resId":"${p:resource.id}",
               "charset":""
            },
            "showHidden": false,
            "type": "plugin",
            "useImpersonation": false
          },
          {
             "allowFailure":false,
             "children": [],
             "commandName":"Create .zip File",
             "impersonationUseSudo":false,
             "name":"Compress artifacts",
             "pluginName":"File Utils",
             "pluginVersion":31,
             "properties":{
                "zipName":"helloWorld.zip",
                "baseDir":".",
                "includes":"*",
                "excludes":"",
                "update":"false",
                "followSymlinks":"false",
                "caseSensitive":"true"
             },
            "showHidden": false,
            "type": "plugin",
            "useImpersonation": false
          },
          {
             "allowFailure":false,
             "children": [],
             "commandName":"Move Directory",
             "impersonationUseSudo":false,
             "name":"Deploy artifacts",
             "pluginName":"File Utils",
             "pluginVersion":31,
             "properties":{
                "sourceDir":".",
                "destDir":"${p:helloHome}/target",
                "includes":"*.zip",
                "excludes":"",
                "mapperRules":""
             },
            "showHidden": false,
            "type": "plugin",
            "useImpersonation": false
          },
          {
            "children": [],
            "name": "FINISH",
            "type": "finish"
          }
        ],
        "edges": [
          {
            "to": "Clean work space",
            "type": "ALWAYS",
            "value": ""
          },
          {
            "from": "Clean work space",
            "to": "Download Artifacts",
            "type": "ALWAYS",
            "value": ""
          },
          {
            "from": "Download Artifacts",
            "to": "Compress artifacts",
            "type": "ALWAYS",
            "value": ""
          },
          {
            "from": "Compress artifacts",
            "to": "Deploy artifacts",
            "type": "ALWAYS",
            "value": ""
          },
          {
            "from": "Deploy artifacts",
            "to": "FINISH",
            "type": "ALWAYS",
            "value": ""
          }
        ],
        "name": "GRAPH",
        "offsets": [
          {
            "name": "Clean work space",
            "x": "-65",
            "y": "90"
          },
          {
            "name": "Download Artifacts",
            "x": "-70",
            "y": "210"
          },
          {
            "name": "Compress artifacts",
            "x": "-70",
            "y": "290"
          },
          {
            "name": "Deploy artifacts",
            "x": "-65",
            "y": "370"
          },
          {
            "name": "FINISH",
            "x": "-60",
            "y": "450"
          }
        ],
        "type": "graph"
      },
      "status": "Active",
      "takesVersion": "true"
    }
    이 명령은 다음 JSON 정보와 유사한 결과를 리턴합니다.
    {
      "id":"12f65517-5fc1-44ff-a58b-2401cfba8f2f",
      "name":"helloProcess",
      "description":"",
      "defaultWorkingDir":"${p:resource\/work.dir}\/${p:component.name}",
      "takesVersion":true,
      "inventoryActionType":"ADD",
      "status":"Active",
      "active":true,
      "versionCount":1,
      "version":1,
      "commit":0,
      "path":"components\/cf355787-a772-4533-be45-3e169e9da6eb\/processes\/12f65517-5fc1-44ff-a58b-2401cfba8f2f"
    }
  3. 애플리케이션을 작성한 다음 컴포넌트와 애플리케이션을 연관시키십시오.
    1. createApplication PUT 명령을 사용하여 애플리케이션을 작성하십시오.
      curl -k -u nsmith:passwd
        https://server.example.com:8443/cli/application/create
        -X PUT -d @newApplication.json
      다음 JSON 파일은 애플리케이션을 나타냅니다.
      {
        "name": "hello Application",
        "description": "",
        "notificationScheme": "None",
        "enforceCompleteSnapshots": "false"
      }
      이 명령은 다음 JSON 정보와 유사한 결과를 리턴합니다.
      {
        "id":"932452cc-3562-4545-8de5-c57aa7efbcc4",
        "securityResourceId":"2bc72218-dbfe-4c11-b16f-752b7ca63d06",
        "name":"hello Application",
        "description":"",
        "created":1396882026943,
        "enforceCompleteSnapshots":false,
        "active":true,
        "tags":[],
        "user":"nsmith"
      }
    2. addComponentToApp PUT 명령을 사용하여 컴포넌트와 애플리케이션을 연관시키십시오.
      curl -k -u nsmith:passwd
        "https://server.example.com:8443/cli/
        application/addComponentToApp?component=helloWorld&application=hello%20Application"
        -X PUT
      이 명령은 다음 결과를 리턴합니다.
      {}
  4. 환경을 작성하고 해당 환경을 자원과 연관시키십시오.
    1. createEnvironment PUT 명령을 사용하여 환경을 작성하십시오.
      curl -k -u nsmith:passwd
        "https://server.example.com:8443/cli/environment/createEnvironment?application=hello%20Application&name=helloDeploy"
        -X PUT
      이 명령은 다음 문자열과 유사한 환경 ID를 리턴합니다.
      2142c0e3-7ebe-4a2f-9e0d-14ccacc70a79
    2. addEnvironmentBaseResources PUT 명령을 사용하여 이전에 구성한 자원과 환경을 연관시키십시오.
      curl -k -u nsmith:passwd
        "https://server.example.com:8443/cli/environment/addBaseResource?application=hello%20Application&environment=helloDeploy&resource=%2FhelloWorld%20Tutorial"
        -X PUT
      자원이 환경과 올바르게 연관된 경우, 이 명령은 결과를 리턴하지 않습니다.
    3. createResource PUT 명령을 사용하여 helloWorld 컴포넌트를 에이전트 자원에 맵핑하십시오.
      curl -k -u nsmith:passwd
        https://server.example.com:8443/cli/resource/resource
        -X PUT -d @componentResource.json
      다음 JSON 파일은 컴포넌트 자원을 나타냅니다.
      {
        "roleId":"09456abd-65e3-469e-94c6-a6a873b971a8",
        "name":"helloWorld",
        "description":"",
        "inheritTeam":"true",
        "useImpersonation":"false",
        "roleProperties":{},
        "parentId":"b2ff919e-b4c0-4d13-8973-eff44e4835e2",
        "teamMappings":[]
      }
      이 명령은 다음 JSON 정보와 유사한 결과를 리턴합니다.
      {
        "id":"ba958487-fb86-4290-9240-da766af37963",
        "securityResourceId":"66685b67-21ab-411d-99bb-f577a74d88b3",
        "name":"helloWorld",
        "path":"\/helloWorld Tutorial\/fit-vm11-157\/helloWorld",
        "active":true,
        "description":"",
        "inheritTeam":true,
        "impersonationPassword":"****",
        "impersonationUseSudo":false,
        "impersonationForce":false,
        "type":"subresource",
        "status":"ONLINE",
        "hasAgent":true,
        "tags":[]
      }
    4. addTagToResource PUT 명령을 사용하여 컴포넌트 자원에 태그를 추가하십시오.
      curl -k -u nsmith:passwd
        "https://server.example.com:8443/cli/
        resource/tag?resource=ba958487-fb86-4290-9240-da766af37963&tag=blueCycle&color=0000FF"
        -X PUT
      컴포넌트에 태그가 올바르게 지정된 경우, 이 명령은 결과를 리턴하지 않습니다.
  5. createApplicationProcess PUT 명령을 사용하여 애플리케이션 프로세스를 작성하십시오.
    curl -k -u nsmith:passwd
      https://server.example.com:8443/cli/application/create
      -X PUT -d @applicationProcess.json
    다음 JSON 파일은 애플리케이션 프로세스를 나타냅니다. 애플리케이션 ID는 3단계에서 리턴된 ID와 동일합니다.
    {
      "application": "932452cc-3562-4545-8de5-c57aa7efbcc4",
      "description": "",
      "inventoryManagementType": "AUTOMATIC",
      "name": "hello App Process",
      "offlineAgentHandling": "PRE_EXECUTION_CHECK",
      "rootActivity": {
        "children": [
          {
            "children": [{
              "children": [{
                "allowFailure": false,
                "children": [],
                "componentName": "helloWorld",
                "componentProcessName": "helloProcess",
                "name": "Deploy helloWorld",
                "properties": {},
                "type": "componentProcess"
              }],
              "componentName": "helloWorld",
              "name": "inventoryVersionCheck",
              "status": "Active",
              "type": "inventoryVersionDiff"
            }],
            "componentName": "helloWorld",
            "failFast": "false",
            "maxIteration": "-1",
            "name": "Deploy helloWorld",
            "runOnlyOnFirst": "false",
            "type": "componentEnvironmentIterator"
          },
          {
            "children": [],
            "name": "FINISH",
            "type": "finish"
          }
        ],
        "edges": [
          {
            "to": "Deploy helloWorld",
            "type": "ALWAYS",
            "value": ""
          },
          {
            "from": "Deploy helloWorld",
            "to": "FINISH",
            "type": "ALWAYS",
            "value": ""
          }
        ],
        "name": "GRAPH",
        "offsets": [
          {
            "name": "Deploy helloWorld",
            "x": "-35",
            "y": "210"
          },
          {
            "name": "FINISH",
            "x": "0",
            "y": "420"
          }
        ],
        "propDefs": [],
        "type": "graph"
      }
    }
    이 명령은 다음 JSON 정보와 유사한 결과를 리턴합니다.
    {
      "id":"37d563ce-7885-48f1-b8c0-f79046c0f024",
      "name":"hello App Process",
      "description":"",
      "active":true,
      "inventoryManagementType":"AUTOMATIC",
      "offlineAgentHandling":"PRE_EXECUTION_CHECK",
      "versionCount":1,
      "version":1,
      "commit":0,
      "path":"applications\/932452cc-3562-4545-8de5-c57aa7efbcc4\/processes\/37d563ce-7885-48f1-b8c0-f79046c0f024"
    }
  6. requestApplicationProcess PUT 명령을 사용하여 애플리케이션을 배치하십시오.
    curl -k -u nsmith:passwd
      https://server.example.com:8443/cli/applicationProcessRequest/request
      -X PUT -d @applicationDeploy.json
    다음 JSON 파일은 배치 요청을 나타냅니다.
    {
      "application": "hello Application",
      "applicationProcess": "hello App Process",
      "environment": "helloDeploy",
      "versions": [{
        "version": "1.0",
        "component": "helloWorld"
      }]
    }
    이 명령은 다음 JSON 정보와 유사한 결과를 리턴합니다.
    {"requestId":"bffff82f-ff69-4c07-b010-26ca3f21be39"}

피드백