Esempio n. 1
0
 def get_vm_template(self, vm):
     code, template = vm.follow('virtualmachinetemplate').get()
     try:
         check_response(200, code, template)
     except Exception as e:
         self.fail_with_error(e)
     return template
Esempio n. 2
0
 def get_vm_nics(self, vm):
     code, nics = vm.follow('nics').get()
     try:
         check_response(200, code, nics)
     except Exception as e:
         self.fail_with_error(e)
     return nics
Esempio n. 3
0
 def get_vm_tags(self, vm):
     code, tags = vm.follow('tags').get()
     try:
         check_response(200, code, tags)
     except Exception as e:
         self.fail_with_error(e)
     return tags
Esempio n. 4
0
 def update_vm_metadata(self, vm):
     code, metadata = vm.follow('metadata').get()
     try:
         check_response(200, code, metadata)
     except Exception as e:
         self.fail_with_error(e)
     vm.json['metadata'] = metadata.json
Esempio n. 5
0
    def get_vm_volumes(self, vm):
        code, vols = vm.follow('volumes').get()
        try:
            check_response(200, code, vols)
        except Exception as e:
            self.fail_with_error(e)

        return vols
Esempio n. 6
0
    def get_vm_disks(self, vm):
        code, disks = vm.follow('harddisks').get()
        try:
            check_response(200, code, disks)
        except Exception as e:
            self.fail_with_error(e)

        return disks
Esempio n. 7
0
 def get_vms(self):
     code, vms = self.api.cloud.virtualmachines.get(
         headers={'accept': 'application/vnd.abiquo.virtualmachines+json'})
     try:
         check_response(200, code, vms)
     except Exception as e:
         self.fail_with_error(e)
     return vms
Esempio n. 8
0
 def get_vms_by_vdc(self, vdc: str):
     code, vms = self.api.cloud.virtualdatacenters(
         vdc
     ).action.virtualmachines.get(
         headers={'accept': 'application/vnd.abiquo.virtualmachines+json'})
     try:
         check_response(200, code, vms)
     except Exception as e:
         self.fail_with_error(e)
     return vms
Esempio n. 9
0
    def get_vm_network_names(self, vm):
        net_names = []
        code, nics = vm.follow('nics').get()
        try:
            check_response(200, code, nics)
            for nic in nics:
                private_nic_link = nic._extract_link('privatenetwork')
                ext_nic_link = nic._extract_link('externalnetwork')
                pub_nic_link = nic._extract_link('publicnetwork')

                if private_nic_link is not None:
                    net_names.append(private_nic_link['title'])
                elif ext_nic_link is not None:
                    net_names.append(ext_nic_link['title'])
                elif pub_nic_link is not None:
                    net_names.append(pub_nic_link['title'])
                else:
                    continue
            return net_names
        except Exception as e:
            self.fail_with_error(e)
Esempio n. 10
0
import json

from abiquo.client import Abiquo
from abiquo.client import check_response


def collection(resource, rel, media):
    return resource.follow(rel).get(
        headers={'accept': 'application/vnd.abiquo.%s+json' % media})


api = Abiquo("https://mothership.bcn.abiquo.com/api",
             auth=("ajulbe", "julbe1991"))
code, vdcs = api.cloud.virtualdatacenters.get(
    headers={'accept': 'application/vnd.abiquo.virtualdatacenters+json'})
check_response(200, code, vdcs)
"""print ("Response code vdcs: %s" % code)"""

for vdc in vdcs:
    code, vapps = collection(vdc, 'virtualappliances', 'virtualappliances')
    check_response(200, code, vapps)
    print
    print vdc.name

    for vapp in vapps:
        code, vms = collection(vapp, 'virtualmachines', 'virtualmachines')
        check_response(200, code, vms)
        mensaje = '*****'
        mensaje2 = '*****' * 2
        mensaje3 = '*****' * 3
        print