Go to main content
Oracle® ZFS Storage Appliance 관리 설⁠명⁠서, 릴⁠리⁠스 OS8.6.x

인쇄 보기 종료

업데이트 날짜: 2016년 9월
 
 

CLI 컨텍스트

CLI의 핵심 원리는 명령이 실행되는 컨텍스트입니다. 컨텍스트는 어떤 시스템 요소를 관리할 수 있고 어떤 명령을 사용할 수 있는지 결정합니다. 컨텍스트에는 컨텍스트 자체에 중첩된 컨텍스트가 포함되는 트리 구조와 일반적으로 BUI 보기의 구조를 미러링하는 구조가 있습니다.

로그인 시 처음으로 표시되는 컨텍스트가 루트 컨텍스트입니다. 이는 모든 컨텍스트의 부모 또는 상위 항목 역할을 합니다. 컨텍스트로 이동하려면 컨텍스트 이름을 명령으로 실행합니다. 예를 들어, 브라우저의 Configuration(구성) 보기에서 사용 가능한 기능을 CLI의 configuration 컨텍스트에서 사용할 수 있습니다. 루트 컨텍스트에서 직접 입력하여 기능에 액세스할 수 있습니다.

dory:> configuration
dory:configuration> 

프롬프트는 컨텍스트가 반영되도록 변경되며, 컨텍스트는 프롬프트에서 콜론과 초과 기호 사이에 제공됩니다.

show 명령을 실행하면 자식 컨텍스트가 표시됩니다. 예를 들어, configuration 컨텍스트에서 실행하면 다음이 표시됩니다.

dory:configuration> show
Children:
                             net => Configure networking
                        services => Configure services
                         version => Display system version
                           users => Configure administrative users
                           roles => Configure administrative roles
                     preferences => Configure user preferences
                          alerts => Configure alerts
                         storage => Configure Storage

이러한 자식 컨텍스트는 Configuration:Network(네트워크), Configuration:Services(서비스), Configuration:Users(사용자), Configuration:Preferences(환경 설정) 등을 비롯하여 브라우저의 Configuration(구성) 보기 아래에 제공되는 보기에 해당합니다. 이러한 자식 컨텍스트 중 하나를 선택하려면 해당 이름을 입력합니다.

dory:configuration> preferences 
dory:configuration preferences> 

중간 컨텍스트를 지정(공백으로 구분)하면 상위 컨텍스트에서 종속 컨텍스트로 바로 이동할 수 있습니다. 예를 들어, 루트 컨텍스트에서 configuration preferences로 바로 이동하려면 해당 명령을 입력하기만 하면 됩니다.

dory:> configuration preferences
dory:configuration preferences>

일부 자식 컨텍스트는 브라우저의 고정 보기 대신 사용자나 시스템이 만든 동적 엔티티에 해당한다는 점에서 동적입니다. 이러한 컨텍스트로 이동하는 방법에는 두 가지가 있습니다. select 명령 뒤에 동적 컨텍스트의 이름을 붙여서 사용하거나, 동적 컨텍스트 이름을 큰 따옴표로 묶을 수 있습니다. list 명령을 사용하면 특정 컨텍스트 내에 포함된 동적 컨텍스트의 이름이 표시됩니다. 예를 들어, users 컨텍스트는 정적 컨텍스트지만 각 사용자가 자체 동적 컨텍스트입니다.

dory:> configuration users
dory:configuration users> list 
NAME                     USERNAME                 UID        TYPE
John Doe                 bmc                      12345      Dir
Super-User               root                     0          Loc

이름이 bmc인 사용자를 선택하려면 select bmc 또는 "bmc" 명령을 실행합니다.:

dory:configuration users> "bmc" 
dory:configuration users bmc> 

또는 일부 경우에 큰따옴표, selectdestroy를 사용해서 해당 등록 정보를 기준으로 엔티티를 선택할 수 있습니다. 예를 들어, 다음 명령을 실행하여 maintenance logs system 컨텍스트에 있는 reboot 모듈에 의해 실행된 로그 항목을 선택할 수 있습니다.

dory:maintenance logs system> select module=reboot 
dory:maintenance logs system entry-034> show
Properties:                                   
  timestamp = 2010-8-14 06:24:41
     module = reboot
   priority = crit
       text = initiated by root on /dev/console syslogd: going down on signal 15

다른 명령에서와 같이 select 또는 큰따옴표를 컨텍스트 변경 명령에 추가할 수 있습니다. 예를 들어, 루트 컨텍스트에서 이름이 bmc인 사용자를 선택하려면 다음과 같이 입력합니다.

dory:> configuration users select bmc 
dory:configuration users bmc>

last 명령을 사용하여 이전에 선택하거나 만든 컨텍스트로 이동할 수 있습니다. 다음 예에서는 복제 작업을 만든 다음 last 및 get id 명령을 사용하여 복제 작업 ID를 검색합니다. 그러면 다른 작업이 선택되고 last 및 get id 명령을 통해 마지막으로 확인된 복제 작업의 ID가 검색됩니다.

last를 사용하면 마지막으로 확인된 노드로 돌아갈 수 있습니다.

dory:configuration net interfaces> "igb4"
dory:configuration net interfaces igb4> done
dory:configuration net interfaces> last
net:configuration net interfaces igb4>

last 명령은 또한 동적 노드를 만드는 동안 어플라이언스에서 자동으로 설정한 값을 검색하는 데도 유용합니다. 예를 들어 어플라이언스 생성 시 어플라이언스에 의해 각 복제 작업에 ID가 지정됩니다. last 명령을 get id 명령과 함께 사용하면 복제 작업의 이름을 사용하지 않고 ID를 검색할 수 있습니다.

dory:shares p1/share replication> create
dory:shares p1/share action (uncommitted)> set target=dory
                               target = dory (uncommitted)
dory:shares p1/share action (uncommitted)> set pool=p0
                               pool = p0 (uncommitted)
dory:shares p1/share action (uncommitted)> commit
dory:shares p1/share replication> last get id
                               id = 7034367a-d4d8-e26f-fa93-c3b454e3b595
dory:shares p1/share replication>

last를 다른 명령(이 경우 get id)과 함께 사용할 경우 명령이 마지막으로 확인된 노드의 컨텍스트에서 실행될 뿐 현재 노드는 변경되지 않은 상태로 남아 있습니다.

last를 사용하면 노드 이름을 지정하지 않고도 마지막으로 확인된 노드와 해당 값을 검색할 수 있으므로 이 명령은 특히 스크립트 작성에 사용하면 편리합니다.

script
              project = 'myproj';
              target = 'mytarget';
              target_pool = 'notmypool';
     
              run('cd /');
              run('shares select ' + project);
              run('replication');
              run('create');
              set('target', target);
              set('pool', target_pool);
              run('commit');
              run('last');
              id = get('id');
              printf("Sending update for replication action id %s ...", id);
              run('sendupdate');
              while (get('state') != 'idle') {
                     printf(".");
                     run('sleep 1');
              }
              printf("done\n");
 .

이전 컨텍스트로 돌아가려면 done 명령을 사용합니다.

dory:configuration> done
dory:> 

이 명령을 실행하면 이전 컨텍스트로 돌아가지만 다음과 같이 이전 컨텍스트가 부모 컨텍스트가 아닐 수도 있습니다.

dory:> configuration users select bmc 
dory:configuration users bmc> done
dory:> 

done 명령을 여러 번 사용하여 이전 컨텍스트를 역추적할 수 있습니다.

dory:> configuration
dory:configuration> users 
dory:configuration users> select bmc 
dory:configuration users bmc> done
dory:configuration users> done
dory:configuration> done
dory:>

부모 컨텍스트로 이동하려면 cd 명령을 사용합니다. 전형적인 UNIX 명령의 영향을 받아 생성된 cd에는 부모 컨텍스트로의 이동을 나타내기 위해 ".." 인수가 사용됩니다.

dory:> configuration users select bmc
dory:configuration users bmc> cd ..
dory:configuration users> 

또한 UNIX 명령과 마찬가지로 "cd /"를 실행하면 루트 컨텍스트로 이동됩니다.

dory:> configuration
dory:configuration> users 
dory:configuration users> select bmc 
dory:configuration users bmc> cd /
dory:>

또한 해당 UNIX 유사 항목과 마찬가지로 "cd ../.."를 사용하여 최상위 컨텍스트로 이동할 수 있습니다.

dory:> configuration
dory:configuration> users 
dory:configuration users> select bmc 
dory:configuration users bmc> cd ../..
dory:configuration>

컨텍스트 이름은 정적 컨텍스트인지 아니면 동적 컨텍스트인지에 관계없이 탭 완성됩니다(정적 컨텍스트의 경우 일반적인 명령 완성을 통해, 동적 컨텍스트의 경우 select 명령의 명령 완성을 통해 처리됨). 다음은 키를 15번만 눌러 루트 컨텍스트에서 이름이 bmc인 사용자를 선택하는 예입니다. 탭 완성을 사용하지 않을 경우 키를 31번 눌러야 합니다.

dory:> configtab 
dory:> configuration utab 
dory:> configuration users setab 
dory:> configuration users select tab 
bmc   root  
dory:> configuration users select btab 
dory:> configuration users select bmcenter 
dory:configuration users bmc>

컨텍스트에 있는 경우 컨텍스트별 명령을 실행할 수 있습니다. 예를 들어, 현재 사용자의 환경 설정을 가져오려면 configuration preferences 컨텍스트에서 get 명령을 실행합니다.

dory:configuration preferences> get
                       locale = C
                 login_screen = status/dashboard
              session_timeout = 15
           session_annotation = 
           advanced_analytics = false

컨텍스트를 변경하는 명령 다음에 입력 값이 있을 경우 해당 명령은 대상 컨텍스트에서 실행되지만 제어가 호출 컨텍스트로 반환됩니다. 예를 들어, 컨텍스트를 변경하지 않고 루트 컨텍스트에서 환경 설정을 가져오려면 컨텍스트 탐색 명령에 get 명령을 추가합니다.

dory:> configuration preferences get 
                       locale = C
                 login_screen = status/dashboard
              session_timeout = 15
           session_annotation = 
           advanced_analytics = false

시스템에서 새 엔티티를 만들 때는 새 엔티티와 연관된 컨텍스트가 커밋되지 않은 상태로 만들어지는 경우가 많습니다. 예를 들어, configuration alerts threshold 컨텍스트에서 create 명령을 실행하여 임계값 경보를 만듭니다.

dory:> configuration alerts thresholds create 
dory:configuration alerts threshold (uncommitted)>

프롬프트의 (uncommitted)는 이 엔티티가 커밋되지 않은 컨텍스트임을 나타냅니다. 커밋되지 않은 엔티티는 commit 명령을 통해 커밋됩니다. 커밋되지 않은 컨텍스트를 종료하려고 하면 확인 메시지가 표시됩니다.

dory:configuration alerts threshold (uncommitted)> cd /
Leaving will abort creation of "threshold". Are you sure? (Y/N)

커밋되지 않은 엔티티를 커밋할 때는 새 엔티티와 연관된 등록 정보가 검증되고 엔티티를 만들 수 없는 경우 오류가 생성됩니다. 예를 들어, 새 임계값 경보를 만들려면 통계 이름을 지정해야 합니다. 이 이름을 설정하지 못하면 오류가 발생합니다.

dory:configuration alerts threshold (uncommitted)> commit
error: missing value for property "statname"

문제를 해결하려면 오류를 처리하고 다시 커밋합니다.

dory:configuration alerts threshold (uncommitted)> set statname=cpu.utilization  
                     statname = cpu.utilization (uncommitted)
dory:configuration alerts threshold (uncommitted)> commit
error: missing value for property "limit"
dory:configuration alerts threshold (uncommitted)> set limit=90
                        limit = 90 (uncommitted)
dory:configuration alerts threshold (uncommitted)> commit
dory:configuration alerts thresholds> list
THRESHOLD          LIMIT       TYPE STATNAME
threshold-000         90     normal cpu.utilization

관련 항목