1. User can now use image name instead of image uuid when creation vm.
For Example, now user can create an alpine vm using the following
command
```shell
ucloud-cli vm create --vm-name myvm --cpu 2 --ram '2GB' \
--os-ssd '10GB' --image images:alpine
```
2. Instead of directly running code, code is now placed under a function
main and is called using the following code
```python
if __name__ == "__main__":
main()
```
3. Multiprocess (Process) is used instead of threading (Thread) to update
heart beat of host.
4. IP Address of vm is included in vm's status which is retrieved by the
following command
```shell
ucloud-cli vm status --vm-name myvm
```
22 lines
464 B
Python
22 lines
464 B
Python
import logging
|
|
|
|
from etcd3_wrapper import Etcd3Wrapper
|
|
from decouple import config
|
|
|
|
from ucloud_common.vm import VmPool
|
|
|
|
logging.basicConfig(
|
|
level=logging.DEBUG,
|
|
filename="log.txt",
|
|
filemode="a",
|
|
format="%(asctime)s: %(levelname)s - %(message)s",
|
|
datefmt="%d-%b-%y %H:%M:%S",
|
|
)
|
|
|
|
|
|
VM_PREFIX = config("VM_PREFIX")
|
|
USER_PREFIX = config("USER_PREFIX")
|
|
|
|
etcd_client = Etcd3Wrapper(host=config("ETCD_URL"))
|
|
|
|
VM_POOL = VmPool(etcd_client, VM_PREFIX)
|