diff --git a/docs/source/index.rst b/docs/source/index.rst index 72d77d3..28d7a53 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -12,6 +12,7 @@ Welcome to ucloud's documentation! introduction/introduction introduction/installation + introduction/usage Indices and tables ================== diff --git a/docs/source/introduction/installation.rst b/docs/source/introduction/installation.rst index 71269b6..f42ca3e 100644 --- a/docs/source/introduction/installation.rst +++ b/docs/source/introduction/installation.rst @@ -184,17 +184,3 @@ profile e.g *~/.profile* alias uotp='cd /root/uotp/ && pipenv run python app.py' and run :code:`source ~/.profile` - - -Running ucloud -~~~~~~~~~~~~~~ - -.. code-block:: sh - - ucloud api - -We need to create a host by executing the following command - -.. code-block:: sh - - \ No newline at end of file diff --git a/docs/source/introduction/usage.rst b/docs/source/introduction/usage.rst new file mode 100644 index 0000000..5cab865 --- /dev/null +++ b/docs/source/introduction/usage.rst @@ -0,0 +1,35 @@ +Usage +===== + +Start API +---------- + +.. code-block:: sh + + ucloud api + +Host Creation +------------- + +Currently, we don't have any host (that runs virtual machines). +So, we need to create it by executing the following command + +.. code-block:: sh + + ucloud-cli host create --hostname ungleich.ch --cpu 32 --ram '32GB' --os-ssd '32GB' + +You should see something like the following + +.. code-block:: json + + { + "message": "Host Created" + } + +Start Scheduler +--------------- + +.. code-block:: sh + + ucloud scheduler + diff --git a/host/main.py b/host/main.py index 8a81e86..9d9f396 100755 --- a/host/main.py +++ b/host/main.py @@ -19,8 +19,8 @@ import etcd3 def update_heartbeat(host): client = Etcd3Wrapper(*etcd_wrapper_args, **etcd_wrapper_kwargs) host_pool = HostPool(client, HOST_PREFIX) - this_host = host_pool.get(host) - + this_host = next(filter(lambda h: h.hostname == host, host_pool.hosts), None) + while True: this_host.update_heartbeat() host_pool.put(this_host) @@ -78,8 +78,8 @@ def main(): heartbeat_updating_process = mp.Process(target=update_heartbeat, args=(args.hostname,)) host_pool = HostPool(etcd_client, HOST_PREFIX) - host = host_pool.get(args.hostname) - assert host, "No such host" + host = next(filter(lambda h: h.hostname == args.hostname, host_pool.hosts), None) + assert host is not None, "No such host" try: heartbeat_updating_process.start()