티스토리 뷰
openstack API를 활용한 VM live_migration을 수행하는 python script 이다.
import os from keystoneauth1.identity import v3 from keystoneauth1 import session from novaclient import client def auth(user, passwd, url): auth = v3.Password(auth_url=url, username=user, password=passwd, project_name='admin', user_domain_id='default', project_domain_name='default') sess = session.Session(auth=auth, verify=False) return sess def migrate(srv, new_host): return srv.live_migrate(host=new_host, block_migration=False) def main(): user = 'admin' passwd = 'Password' sess = auth(user, passwd, 'http://192.168.1.1:5000/v3') nova = client.Client(2, session=sess) for srv in nova.servers.list(): hostname = getattr(srv, "OS-EXT-SRV-ATTR:host") if (srv.name.find('TESTVM1') is 0) and \ (hostname != "overcloud-compute-2.localdomain"): migrate(srv, "overcloud-compute-2.localdomain") print srv.name, hostname if (srv.name.find('TESTVM2') is 0) and \ (hostname != "overcloud-compute-0.localdomain"): migrate(srv, "overcloud-compute-0.localdomain") print srv.name, hostname if __name__ == '__main__': main()
아래 base.py에 보면 일반적으로 사용되는 function들이 나와있다. 참고하도록 한다.
- https://github.com/openstack/python-novaclient/blob/master/novaclient/base.py
참고사이트
- https://gist.github.com/djoreilly/888abbfc3425e54fa290
- https://www.ibm.com/developerworks/cloud/library/cl-openstack-pythonapis/index.html
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- vmware openstack
- kubernetes
- GateKeeper
- nginx-ingress
- socket
- metallb
- macvlan
- Jenkinsfile
- azure policy
- aquasecurity
- ansible
- open policy agent
- boundary ssh
- Helm Chart
- openstacksdk
- kata container
- OpenStack
- minio
- openstack backup
- kubernetes install
- Terraform
- crashloopbackoff
- minikube
- jenkins
- mattermost
- DevSecOps
- wsl2
- hashicorp boundary
- ceph
- K3S
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함