Полное описание входных и выходных данных методов команды onehost.

Команда onehost

Метод XML-RPC 

Необходимые разрешения

Пример

enable

disable

offline

 

one.host.status

HOST:ADMIN

 Отключение сервера с идентификатором 1:

import pyone
auth_url = "http://127.0.0.1:2633/RPC2"
auth_user = "brestman"
auth_token = "1c93e09e349066932e2c6604cbf65f13cb9e91e18ee271bf49d30baec9a827d1"
client = pyone.OneServer(auth_url, session=auth_user + ':' + auth_token)

result = client.host.status(1, 2)
print(result)
CODE


update

one.host.update

HOST:ADMIN

Обновление шаблона сервера с идентификатором 1:

import pyone
auth_url = "http://127.0.0.1:2633/RPC2"
auth_user = "brestman"
auth_token = "1c93e09e349066932e2c6604cbf65f13cb9e91e18ee271bf49d30baec9a827d1"
client = pyone.OneServer(auth_url, session=auth_user + ':' + auth_token)

host_template = """
ATTRIBUTE1="VALUE1"
RESERVED_CPU="-75"
RESERVED_MEM="-65"
                """

result = client.host.update(1, host_template, 1)
print(result)
CODE


create

one.host.allocate

HOST:CREATE

[CLUSTER:ADMIN]

Создание сервера front1.test.loc на кластере по умолчанию:

import pyone
auth_url = "http://127.0.0.1:2633/RPC2"
auth_user = "brestmaster1"
auth_token = "7e111fb1738e24285b31aed3d5ad039958b84254a07d6d855b2e027ac53f6a8b"
client = pyone.OneServer(auth_url, session=auth_user + ':' + auth_token)

result = client.host.allocate("front1.test.loc","kvm","kvm",-1)
print(result)
CODE



delete

one.host.delete

HOST:ADMIN

Удаление сервера с идентификатором 1:

import pyone
auth_url = "http://127.0.0.1:2633/RPC2"
auth_user = "brestmaster1"
auth_token = "7e111fb1738e24285b31aed3d5ad039958b84254a07d6d855b2e027ac53f6a8b"
client = pyone.OneServer(auth_url, session=auth_user + ':' + auth_token)

result = client.host.delete(1)
print(result)
CODE


rename

one.host.rename

HOST:ADMIN

 Изменение имени сервера с идентификатором 1:

import pyone
auth_url = "http://127.0.0.1:2633/RPC2"
auth_user = "brestman"
auth_token = "1c93e09e349066932e2c6604cbf65f13cb9e91e18ee271bf49d30baec9a827d1"
client = pyone.OneServer(auth_url, session=auth_user + ':' + auth_token)

result = client.host.rename(1,"new_host_name")
print(result)
CODE


showone.host.infoHOST:USE

Вывод информации о состояниях сервера с идентификатором 1:

import pyone
auth_url = "http://127.0.0.1:2633/RPC2"
auth_user = "brestmaster1"
auth_token = "7e111fb1738e24285b31aed3d5ad039958b84254a07d6d855b2e027ac53f6a8b"
client = pyone.OneServer(auth_url, session=auth_user + ':' + auth_token)

brest_host = client.host.info(1)

HOST_STATES = ['INIT', 'MONITORING_MONITORED', 'ENABLED', 'ERROR','DISABLED',
'MONITORING_ERROR', 'MONITORING_INIT', 'MONITORING_DISABLED', 'OFFLINE']

print(HOST_STATES[brest_host.get_STATE()])
CODE

Вывод информации о всех серверах:

import pyone
auth_url = "http://127.0.0.1:2633/RPC2"
auth_user = "brestmaster1"
auth_token="7e111fb1738e24285b31aed3d5ad039958b84254a07d6d855b2e027ac53f6a8b"
client = pyone.OneServer(auth_url, session=auth_user + ':' + auth_token)

hostpool = client.hostpool.info()
host = hostpool.HOST[0]
id = host.NAME

print(id)
CODE