Example #1
0
def test_orch_ls(_describe_service):
    cmd = {
        'prefix': 'orch ls',
    }
    m = OrchestratorCli('orchestrator', 0, 0)
    r = m._handle_command(None, cmd)
    out = 'NAME  PORTS  RUNNING  REFRESHED  AGE  PLACEMENT  \n' \
          'osd              123  -          -               '
    assert r == HandleCommandResult(retval=0, stdout=out, stderr='')
Example #2
0
def test_handle_command():
    cmd = {
        'prefix': 'orch daemon add',
        'daemon_type': 'mon',
        'placement': 'smithi044:[v2:172.21.15.44:3301,v1:172.21.15.44:6790]=c',
    }
    m = OrchestratorCli('orchestrator', 0, 0)
    r = m._handle_command(None, cmd)
    assert r == HandleCommandResult(
        retval=-2, stdout='', stderr='No orchestrator configured (try `ceph orch set backend`)')
Example #3
0
def test_orch_ps(_describe_service):

    # Ensure natural sorting on daemon names (osd.1, osd.2, osd.10)
    cmd = {
        'prefix': 'orch ps'
    }
    m = OrchestratorCli('orchestrator', 0, 0)
    r = m._handle_command(None, cmd)
    out = 'NAME    HOST       PORTS  STATUS   REFRESHED  AGE  MEM USE  MEM LIM  VERSION    IMAGE ID   \n'\
          'osd.1   <unknown>         unknown          -    -        -        -  <unknown>  <unknown>  \n'\
          'osd.2   <unknown>         unknown          -    -        -        -  <unknown>  <unknown>  \n'\
          'osd.10  <unknown>         unknown          -    -        -        -  <unknown>  <unknown>  '
    assert r == HandleCommandResult(retval=0, stdout=out, stderr='')
Example #4
0
def test_orch_host_ls(_describe_service):

    # Ensure natural sorting on hostnames (ceph-node-1, ceph-node-2, ceph-node-10)
    cmd = {
        'prefix': 'orch host ls'
    }
    m = OrchestratorCli('orchestrator', 0, 0)
    r = m._handle_command(None, cmd)
    out = 'HOST          ADDR          LABELS  STATUS  \n'\
        'ceph-node-1   ceph-node-1                   \n'\
        'ceph-node-2   ceph-node-2                   \n'\
        'ceph-node-10  ceph-node-10                  \n'\
        '3 hosts in cluster'
    assert r == HandleCommandResult(retval=0, stdout=out, stderr='')
Example #5
0
def test_orch_device_ls():
    devices = Devices([Device("/dev/vdb", available=True)])
    ilist = OrchResult([InventoryHost("ceph-node-1", devices=devices), InventoryHost("ceph-node-2",
                       devices=devices), InventoryHost("ceph-node-10", devices=devices)])

    with mock.patch("orchestrator.OrchestratorCli.get_inventory", return_value=ilist):
        # Ensure natural sorting on hostnames (ceph-node-1, ceph-node-2, ceph-node-10)
        cmd = {
            'prefix': 'orch device ls'
        }
        m = OrchestratorCli('orchestrator', 0, 0)
        r = m._handle_command(None, cmd)
        out = 'HOST          PATH      TYPE     DEVICE ID   SIZE  AVAILABLE  REFRESHED  REJECT REASONS  \n'\
              'ceph-node-1   /dev/vdb  unknown  None          0   Yes        0s ago                     \n'\
              'ceph-node-2   /dev/vdb  unknown  None          0   Yes        0s ago                     \n'\
              'ceph-node-10  /dev/vdb  unknown  None          0   Yes        0s ago                     '
        assert r == HandleCommandResult(retval=0, stdout=out, stderr='')
Example #6
0
def test_orch_ls(_describe_service):
    cmd = {
        'prefix': 'orch ls',
    }
    m = OrchestratorCli('orchestrator', 0, 0)
    r = m._handle_command(None, cmd)
    out = 'NAME  PORTS  RUNNING  REFRESHED  AGE  PLACEMENT  \n' \
          'osd              123  -          -               '
    assert r == HandleCommandResult(retval=0, stdout=out, stderr='')

    cmd = {
        'prefix': 'orch ls',
        'format': 'yaml',
    }
    m = OrchestratorCli('orchestrator', 0, 0)
    r = m._handle_command(None, cmd)
    out = textwrap.dedent("""
        service_type: osd
        service_name: osd
        spec:
          filter_logic: AND
          objectstore: bluestore
        status:
          running: 123
          size: 0
        """).lstrip()
    assert r == HandleCommandResult(retval=0, stdout=out, stderr='')