mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 23:25:24 +00:00
Merge pull request #179 from honza801/master
patch for cloning rbd images
This commit is contained in:
commit
7153a6196c
3 changed files with 48 additions and 2 deletions
21
README.md
21
README.md
|
@ -32,7 +32,7 @@ print(''.join([random.SystemRandom().choice(haystack) for _ in range(50)]))
|
||||||
### Install WebVirtCloud panel (Ubuntu)
|
### Install WebVirtCloud panel (Ubuntu)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo apt-get -y install git python-virtualenv python-dev python-lxml libvirt-dev zlib1g-dev libxslt1-dev nginx supervisor libsasl2-modules gcc pkg-config python-guestfs
|
sudo apt-get -y install git virtualenv python-virtualenv python-dev python-lxml libvirt-dev zlib1g-dev libxslt1-dev nginx supervisor libsasl2-modules gcc pkg-config python-guestfs
|
||||||
git clone https://github.com/retspen/webvirtcloud
|
git clone https://github.com/retspen/webvirtcloud
|
||||||
cd webvirtcloud
|
cd webvirtcloud
|
||||||
cp webvirtcloud/settings.py.template webvirtcloud/settings.py
|
cp webvirtcloud/settings.py.template webvirtcloud/settings.py
|
||||||
|
@ -219,6 +219,25 @@ login: admin
|
||||||
password: admin
|
password: admin
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
### Configuring Compute SSH connection
|
||||||
|
This is a short example of configuring cloud and compute side of the ssh connection.
|
||||||
|
|
||||||
|
On the webvirtcloud machine you need to generate ssh keys and optionally disable StrictHostKeyChecking.
|
||||||
|
```
|
||||||
|
chown www-data -R ~www-data
|
||||||
|
sudo -u www-data ssh-keygen
|
||||||
|
cat > ~www-data/.ssh/config << EOF
|
||||||
|
Host *
|
||||||
|
StrictHostKeyChecking no
|
||||||
|
EOF
|
||||||
|
chown www-data -R ~www-data/.ssh/config
|
||||||
|
```
|
||||||
|
|
||||||
|
You need to put cloud public key into authorized keys on the compute node. Simpliest way of doing this is to use ssh tool from the webvirtcloud server.
|
||||||
|
```
|
||||||
|
sudo -u www-data ssh-copy-id root@compute1
|
||||||
|
```
|
||||||
|
|
||||||
### Cloud-init
|
### Cloud-init
|
||||||
Currently supports only root ssh authorized keys and hostname. Example configuration of the cloud-init client follows.
|
Currently supports only root ssh authorized keys and hostname. Example configuration of the cloud-init client follows.
|
||||||
```
|
```
|
||||||
|
|
|
@ -1279,6 +1279,8 @@
|
||||||
image = new_vname + "-" + disk_minus_suffix;
|
image = new_vname + "-" + disk_minus_suffix;
|
||||||
} else if (disk_name.lastIndexOf('.') > -1 && disk_dot_suffix.length <= 7) {
|
} else if (disk_name.lastIndexOf('.') > -1 && disk_dot_suffix.length <= 7) {
|
||||||
image = new_vname + "." + disk_dot_suffix
|
image = new_vname + "." + disk_dot_suffix
|
||||||
|
} else if (new_vname != disk_name) {
|
||||||
|
image = new_vname
|
||||||
} else {
|
} else {
|
||||||
image = new_vname + '-clone';
|
image = new_vname + '-clone';
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,10 @@ class wvmInstance(wvmConnect):
|
||||||
try:
|
try:
|
||||||
dev = disk.xpath('target/@dev')[0]
|
dev = disk.xpath('target/@dev')[0]
|
||||||
src_fl = disk.xpath('source/@file|source/@dev|source/@name|source/@volume')[0]
|
src_fl = disk.xpath('source/@file|source/@dev|source/@name|source/@volume')[0]
|
||||||
disk_format = disk.xpath('driver/@type')[0]
|
try:
|
||||||
|
disk_format = disk.xpath('driver/@type')[0]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
vol = self.get_volume_by_path(src_fl)
|
vol = self.get_volume_by_path(src_fl)
|
||||||
volume = vol.name()
|
volume = vol.name()
|
||||||
|
@ -719,6 +722,28 @@ class wvmInstance(wvmConnect):
|
||||||
stg = vol.storagePoolLookupByVolume()
|
stg = vol.storagePoolLookupByVolume()
|
||||||
stg.createXMLFrom(vol_clone_xml, vol, meta_prealloc)
|
stg.createXMLFrom(vol_clone_xml, vol, meta_prealloc)
|
||||||
|
|
||||||
|
source_protocol = elm.get('protocol')
|
||||||
|
if source_protocol == 'rbd':
|
||||||
|
source_name = elm.get('name')
|
||||||
|
clone_name = "%s/%s" % (os.path.dirname(source_name), target_file)
|
||||||
|
elm.set('name', clone_name)
|
||||||
|
|
||||||
|
vol = self.get_volume_by_path(source_name)
|
||||||
|
vol_format = util.get_xml_path(vol.XMLDesc(0),
|
||||||
|
"/volume/target/format/@type")
|
||||||
|
|
||||||
|
vol_clone_xml = """
|
||||||
|
<volume type='network'>
|
||||||
|
<name>%s</name>
|
||||||
|
<capacity>0</capacity>
|
||||||
|
<allocation>0</allocation>
|
||||||
|
<target>
|
||||||
|
<format type='%s'/>
|
||||||
|
</target>
|
||||||
|
</volume>""" % (target_file, vol_format)
|
||||||
|
stg = vol.storagePoolLookupByVolume()
|
||||||
|
stg.createXMLFrom(vol_clone_xml, vol, meta_prealloc)
|
||||||
|
|
||||||
source_dev = elm.get('dev')
|
source_dev = elm.get('dev')
|
||||||
if source_dev:
|
if source_dev:
|
||||||
clone_path = os.path.join(os.path.dirname(source_dev), target_file)
|
clone_path = os.path.join(os.path.dirname(source_dev), target_file)
|
||||||
|
|
Loading…
Reference in a new issue