Skip to content

Commit e0d75f1

Browse files
authored
Merge pull request #12 from cloudify-incubator/for_review
Support for external vm and update ip on vm start
2 parents 308a9f0 + 5c0a598 commit e0d75f1

18 files changed

Lines changed: 1180 additions & 402 deletions

CHANGELOG.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ releases:
1717
v0.5.0:
1818
* Support for reuse external network
1919
* Support for kvm virtualization in embeded examples
20+
21+
v0.6.0:
22+
* Support for dump full vm snapshot to fs on backup
23+
* Update start action for fill in `network` in vm runtime properties
24+
* Cluster Example: Automatically add libvirt host to trusted
25+
* Support for reuse external vm
26+
* move use_external_resource to top of instance properties
27+
* add `update` action for sync vm size to values from runtime properties.
28+
* rename `memory_size` to `memory_maxsize`

README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,29 @@ Description for VM
4141
**Supported properties:**
4242
* `libvirt_auth`: connection url, by default: `qemu:///system`
4343
* `backup_dir`: directory for save backups, by default: `./`
44+
* `use_external_resource`: (optional) Use external object. The default is
45+
`false`.
46+
* `resource_id`: (optional) Used to identify the object when
47+
`use_external_resource` is true.
48+
* `params`: params used for create object, useful for embeded template.
49+
* `vcpu`: CPU count
50+
* `memory_size`: VM memory size in KiB
51+
* `memory_maxsize`: (optional) recomended VM memory size in KiB for
52+
downgrade. The default is value from `memory_size` * 2.
53+
* `nvram`: (optional) path to nvram (useful for arm)
54+
* `disks`: list connected disks
55+
* `networks`: list connected networks
56+
* `full_dump`: make full dump for backups with memory snapshot to dump file.
57+
On create/restore backup will be removed all snapshots in domain.
58+
* `wait_for_ip`: (optional) wait until we have some private ip on interfaces
59+
The default is `true`.
60+
* `domain_type`: (optional) type of virtualization. The default is `qemu`
4461

4562
**Inputs for actions:**
4663
* `configure`:
4764
* `params`: list of params for template, can be empty
48-
* `domain_file`: Template for domain. Defaults is [domain.xml](cloudify_libvirt/templates/domain.xml)
65+
* `domain_file`: Template for domain. Defaults is
66+
[domain.xml](cloudify_libvirt/templates/domain.xml)
4967

5068
**Runtime properties:**
5169
* `resource_id`: resource name.
@@ -57,17 +75,20 @@ Description for Network
5775
**Supported properties:**
5876
* `libvirt_auth`: connection url, by default: `qemu:///system`
5977
* `backup_dir`: directory for save backups, by default: `./`
78+
* `use_external_resource`: (optional) Use external object. The default is
79+
`false`.
80+
* `resource_id`: (optional) Used to identify the object when
81+
`use_external_resource` is true.
6082
* `params`: params used for create object.
61-
* `use_external_resource`: (optional) Use external object. The default is `false`.
62-
* `resource_id`: (optional) Used to identify the object when `use_external_resource` is true.
6383
* `dev`: Device name
6484
* `forwards`: settings for network `forwards`.
6585
* `ips`: settings for network `ips`.
6686

6787
**Inputs for actions:**
6888
* `create`:
6989
* `params`: list of params for template, can be empty
70-
* `network_file`: Template for network. Defaults is [network.xml](cloudify_libvirt/templates/network.xml)
90+
* `network_file`: Template for network. Defaults is
91+
[network.xml](cloudify_libvirt/templates/network.xml)
7192

7293
**Runtime properties:**
7394
* `resource_id`: resource name.
@@ -167,3 +188,5 @@ You should to install [libvirt-devel](examples/bootstraps/centos.sh#L2) before c
167188
168189
## TODO:
169190
* Add more examples with different vm struct and archictures: mips, powerpc
191+
* Implement storage volume/pool
192+
* Implement firewall rules

cloudify_libvirt/common.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ def get_libvirt_params(**kwargs):
3131
template_params.update(ctx.instance.runtime_properties.get('params', {}))
3232
template_params.update(kwargs.get('params', {}))
3333
ctx.instance.runtime_properties['params'] = template_params
34+
35+
# update 'resource_id', 'use_external_resource' from kwargs
36+
for field in ['resource_id', 'use_external_resource']:
37+
if field in kwargs:
38+
ctx.instance.runtime_properties[field] = kwargs[field]
39+
3440
return libvirt_auth, template_params
3541

3642

@@ -70,3 +76,26 @@ def delete_node_state(backup_dir, object_name):
7076
if not os.path.isfile("{}/{}.xml".format(backup_dir, object_name)):
7177
return
7278
os.remove("{}/{}.xml".format(backup_dir, object_name))
79+
80+
81+
def get_binary_place(backup_dir, object_name):
82+
# return path to binary/directory place
83+
return "{}/{}_raw".format(backup_dir, object_name)
84+
85+
86+
def check_binary_place(backup_dir, object_name):
87+
# check binary/directory place exists
88+
return os.path.isfile(get_binary_place(backup_dir, object_name))
89+
90+
91+
def create_binary_place(backup_dir):
92+
# create binary/directory place
93+
if not os.path.isdir(backup_dir):
94+
os.makedirs(backup_dir)
95+
96+
97+
def delete_binary_place(backup_dir, object_name):
98+
# create binary/directory place
99+
full_path = get_binary_place(backup_dir, object_name)
100+
if os.path.isfile(full_path):
101+
os.remove(full_path)

0 commit comments

Comments
 (0)