Skip to content

Commit

Permalink
added new features
Browse files Browse the repository at this point in the history
  • Loading branch information
CSUC authored and CSUC committed May 31, 2017
1 parent f89a739 commit c5c15cd
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 18 deletions.
68 changes: 55 additions & 13 deletions 5.0/remotes/vmm/vcloud/vcloud_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,37 @@ def encrypt_password(pass)

######################### Datastore Operations ####################################################

###################################################################################################
# Create a VirtualDisk
# @param img_name [String] name of the image
# @param ds_name [String] name of the datastore on which the VD will be
# created
# @param size [String] size of the new image in MB
# @param adapter_type [String] as described in
# http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.wssdk.apiref.doc/vim.VirtualDiskManager.VirtualDiskAdapterType.html
# @param disk_type [String] as described in
# http://pubs.vmware.com/vsphere-60/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc%2Fvim.VirtualDiskManager.VirtualDiskType.html
# @return name of the final image
############################################################################
def create_virtual_disk(img_name, ds_name, size, adapter_type, disk_type)
#NOT IMPLEMENTED YET
#return true
@vdc_ci.create_disk(img_name,size.to_i)

"#{img_name}.vmdk"
end

###################################################################################################
# Delete a VirtualDisk
# @param img_name [String] name of the image
# @param ds_name [String] name of the datastore where the VD resides
###################################################################################################
def delete_virtual_disk(img_name, ds_name)
#NOT IMPLEMENTED YET
#return true
@vdc_ci.delete_disk_by_name(img_name)
end

###################################################################################################
# Returns Datastore information
# @param ds_name [String] name of the datastore
Expand Down Expand Up @@ -768,17 +799,17 @@ def self.attach_nic(deploy_id, mac, bridge, hostname,vm_id,target)
end

#Add firewall rule
#net_enrouted = VCDConnection::network_enrouted(bridge)
#tcp_ports = vm_one.retrieve_elements("/VM/USER_TEMPLATE/CONTEXT/WHITE_TCP_PORTS").first
net_enrouted = VCDConnection::network_enrouted(bridge)
tcp_ports = vm_one.retrieve_elements("/VM/USER_TEMPLATE/CONTEXT/WHITE_TCP_PORTS").first

#if net_enrouted and !tcp_ports.nil?
if net_enrouted and !tcp_ports.nil?
#ports = tcp_ports.split(",")
#public_address = VCDConnection::public_ip(vm,connection.vdc_ci)
#enrouted_address = enrouted_ip(vm)
#configure_firewall(connection,vapp.name,public_address,ports) if !public_address.empty?
#public_net = connection.vdc_ci.edge_gateways.first.public_net_name
#configure_nat(connection,vapp.name,enrouted_address.first,public_address.first,public_net,ports) if !public_address.empty? or !enrouted_address.empty?
#end
end
end

###################################################################################################
Expand Down Expand Up @@ -923,17 +954,28 @@ def self.clone_vm(xml_text, hostname)
vdc_name = connection.vdc
vApp_description = "vApp instantiated by OpenNebula by user #{user}"

disks = xml.root.get_elements("/VM/TEMPLATE/DISK[DISK_ID='0']")
vm_params = []
disks = xml.root.get_elements("/VM/TEMPLATE/DISK[DISK_ID='0']")
storage_profile = xml.root.get_elements("//USER_TEMPLATE/STORAGE_PROFILE").first.text if !xml.root.get_elements("//USER_TEMPLATE/STORAGE_PROFILE").empty?

sp_link = nil
disk_conf = nil

if !storage_profile.nil? and connection.vdc_ci.storage_profile_exists?(storage_profile)
sp_link = connection.vdc_ci.find_storage_profile_by_name(storage_profile).href
end

if !disks.nil?
disk_id = disks.first.elements["DISK_ID"].text
disk_opt = {
disk_conf = {
:id => disk_id,
:size => disks.first.elements["SIZE"].text
}
vm_params.push(disk_opt)
end
}
end

vm_params = {
:disk_opt => disk_conf,
:storage_profile => sp_link
}

vapp = catalog.instantiate_vapp_template(template.name,vdc_name,vApp_name,vApp_description,nil,nil,vm_params)

Expand Down Expand Up @@ -1149,14 +1191,14 @@ def self.reconfigure_vm(vapp, xml, newvm, hostname,connection=nil)
vm.reconfigure(options_vm)

#FIREWALL && NAT CONFIGURATION
#nics = vm.nics
#if !nics.nil? and !ports.nil?
nics = vm.nics
if !nics.nil? and !ports.nil?
#public_address = VCDConnection::public_ip(vm,connection.vdc_ci)
#enrouted_address = enrouted_ip(vm)
#configure_firewall(connection,vApp_name,public_address,ports) if !public_address.empty?
#public_net = connection.vdc_ci.edge_gateways.first.public_net_name
#configure_nat(connection,vApp_name,enrouted_address.first,public_address.first,public_net,ports) if !public_address.empty? or !enrouted_address.empty?
#end
end
end

###################################################################################################
Expand Down
9 changes: 5 additions & 4 deletions Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@ The first step is import to OpenNebula the resources hosted in vCloud using the

During the instanciation, vcloud driver takes some variables from the template to configure capabilities such as CUSTOMIZATION. If this variables are not in the template, the capabilities won't be configured correctly. Please add or modify the variables that you need.

* CUSTOMIZATION = "YES" The DEFAULT value is NO. If you want to activate customization, change the value to "YES".
* OS = "LINUX | WINDOWS | OTHER" Check this variable and modify the value for the OS of the template. This value is important because is used during the customization process.
* WHITE_TCP_PORTS = "PORT,PORT,..." If you add coma-separated TCP port numbers, during the instanciation the driver will open that ports in the vShield. Only if the network is
enrouted by vShield.
* CUSTOMIZATION = "YES" The DEFAULT value is NO. If you want to activate customization, change the value to "YES".
* OS = "LINUX | WINDOWS | OTHER" Check this variable and modify the value for the OS of the template. This value is important because is used during the customization process.
* WHITE_TCP_PORTS = "PORT,PORT,..." If you add coma-separated TCP port numbers, during the instanciation the driver will open that ports in the vShield. Only if the network is
enrouted by vShield.
* STORAGE_PROFILE = "STORAGE_PROFILE_NAME" You can select the storage profile. If you don't select anyone, the vm will be storaged in the default storage profile defined in vcloud vapp template.

### USER'S CONTEXT VARIABLES

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ This addon has the following capabilities:
* Create, delete and revert snapshots of VM's.
* Change RAM and CPU values of VM.
* It's able to hot-attach and detach NICs to VM's.
* Attach disks to VM. Now, during the deployment process only.
* Attach disks to VM, only in cold.
* Resize disks during the instantiation. Only increase the size, not decrease.
* Automatized customization of the VMs instanciated.
* It's able to choose wich storage profile will be storaged the VM's disk or disks.
* Port filtering via vShield during the VM instanciation.
* Obtain monitoring information from the VDC, Datastore and VM's.
* In this development version we manage vApps with one VMs inside (A VM in OpenNebula equals a vApp with one VM in vCloud).
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
###V0.3 Beta (2016-12-15)
* It's able to:
* Cold Attach & detach volatile disks to VM's
* Resize disks during the instantiation
* Select the profile storage

###TODO

Expand Down
9 changes: 9 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ CP=/bin/cp
MKDIR=/bin/mkdir
CHOWN=/bin/chown
CHMOD=/bin/chmod
TOUCH=/bin/touch

echo "copying files...."

Expand All @@ -30,6 +31,14 @@ $CHMOD -R +x /var/lib/one/remotes/vmm/vcloud /var/lib/one/remotes/im/vcloud.d /v

echo "Finished copying files"

echo "Creating log files"

$TOUCH /var/lib/one/vcloud.log
$CHOWN oneadmin:oneadmin /var/lib/one/vcloud.log

$TOUCH /var/lib/one/rest
$CHOWN oneadmin:oneadmin /var/lib/one/rest

echo "Installing gem dependences...."

if [ -n "`command -v apt-get`" ]; then
Expand Down

0 comments on commit c5c15cd

Please sign in to comment.