ucloud-host can not be started by using hostname
This commit is contained in:
		
					parent
					
						
							
								da5a600ccb
							
						
					
				
			
			
				commit
				
					
						e37222c1c7
					
				
			
		
					 4 changed files with 40 additions and 18 deletions
				
			
		| 
						 | 
					@ -12,6 +12,7 @@ Welcome to ucloud's documentation!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   introduction/introduction
 | 
					   introduction/introduction
 | 
				
			||||||
   introduction/installation
 | 
					   introduction/installation
 | 
				
			||||||
 | 
					   introduction/usage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Indices and tables
 | 
					Indices and tables
 | 
				
			||||||
==================
 | 
					==================
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -184,17 +184,3 @@ profile e.g *~/.profile*
 | 
				
			||||||
    alias uotp='cd /root/uotp/ && pipenv run python app.py'
 | 
					    alias uotp='cd /root/uotp/ && pipenv run python app.py'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
and run :code:`source ~/.profile`
 | 
					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
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
							
								
								
									
										35
									
								
								docs/source/introduction/usage.rst
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								docs/source/introduction/usage.rst
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,7 @@ import etcd3
 | 
				
			||||||
def update_heartbeat(host):
 | 
					def update_heartbeat(host):
 | 
				
			||||||
    client = Etcd3Wrapper(*etcd_wrapper_args, **etcd_wrapper_kwargs)
 | 
					    client = Etcd3Wrapper(*etcd_wrapper_args, **etcd_wrapper_kwargs)
 | 
				
			||||||
    host_pool = HostPool(client, HOST_PREFIX)
 | 
					    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:
 | 
					    while True:
 | 
				
			||||||
        this_host.update_heartbeat()
 | 
					        this_host.update_heartbeat()
 | 
				
			||||||
| 
						 | 
					@ -78,8 +78,8 @@ def main():
 | 
				
			||||||
    heartbeat_updating_process = mp.Process(target=update_heartbeat, args=(args.hostname,))
 | 
					    heartbeat_updating_process = mp.Process(target=update_heartbeat, args=(args.hostname,))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    host_pool = HostPool(etcd_client, HOST_PREFIX)
 | 
					    host_pool = HostPool(etcd_client, HOST_PREFIX)
 | 
				
			||||||
    host = host_pool.get(args.hostname)
 | 
					    host = next(filter(lambda h: h.hostname == args.hostname, host_pool.hosts), None)
 | 
				
			||||||
    assert host, "No such host"
 | 
					    assert host is not None, "No such host"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        heartbeat_updating_process.start()
 | 
					        heartbeat_updating_process.start()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue