Exemplo n.º 1
0
 def _test_host_storage_attributes(self):
     host = self.store.host
     storage = self.api.get(schema.HostStorage, base=host)
     assert isinstance(storage, schema.HostStorage)
     for stor in storage:
         assert isinstance(stor, schema.Storage)
         assert util.is_str(stor.id)
         assert util.is_str_href(stor.href)
         assert stor.type in ('ISCSI', 'FCP')
         assert stor.host is not None
         assert util.is_str_int(stor.host.id) or \
                     util.is_str_uuid(stor.host.id)
         assert util.is_str_href(stor.host.href)
         assert bool(stor.logical_unit) != bool(stor.volume_group)
         if stor.logical_unit:
             assert stor.logical_unit.id == stor.id
         else:
             assert stor.volume_group.id == stor.id
         # BUG: missing attributes
         if stor.type == 'ISCSI':
             assert util.is_str(stor.target)
         assert util.is_int(stor.size)
         if stor.logical_unit:
             assert util.is_int(stor.multipathing)
         elif stor.volume_group:
             assert util.is_str(volume_group.name)
             assert volume_group.logical_unit is not None
Exemplo n.º 2
0
 def test_attributes(self):
     template = self.store.template
     template = self.api.reload(template)
     assert util.is_str_uuid(template.id)
     assert util.is_str_href(template.href)
     assert util.is_str(template.name) and template.name
     if template.description:
         assert util.is_str(template.description)
     assert template.type in ('SERVER', 'DESKTOP')
     assert template.status in ('ILLEGAL', 'LOCKED', 'OK')
     assert template.origin in ('RHEV', 'VMWARE', 'XEN')
     assert isinstance(template.creation_time, datetime.datetime)
     assert util.is_int(template.memory)
     assert template.memory > 0
     assert template.cpu is not None
     assert template.cpu.topology is not None
     assert util.is_int(template.cpu.topology.cores)
     assert template.cpu.topology.cores > 0
     assert util.is_int(template.cpu.topology.sockets)
     assert template.cpu.topology.sockets > 0
     assert template.display is not None
     assert template.display.type in ('VNC', 'SPICE')
     assert util.is_int(template.display.monitors)
     assert template.display.monitors > 0
     assert template.os is not None
     assert util.is_str(template.os.type)
     assert template.os.boot is not None
     # Upper case?
     for dev in template.os.boot:
         assert dev.dev in ('cdrom', 'hd', 'network')
     assert util.is_bool(template.stateless)
     assert template.cluster is not None
     assert util.is_str_int(template.cluster.id) or util.is_str_uuid(template.cluster.id)
Exemplo n.º 3
0
 def _test_attributes(self):
     domain = self.store.storagedomain
     assert util.is_str(domain.name)
     assert domain.type in ('DATA', 'ISO', 'EXPORT')
     assert domain.storage is not None
     assert domain.storage.type in ('NFS', 'ISCSI', 'FCP')
     if domain.storage.type == 'NFS':
         assert util.is_str_host(domain.storage.address)
         assert util.is_str_path(domain.storage.path)
     assert util.is_int(domain.available)
     assert util.is_int(domain.used)
     assert util.is_int(domain.committed)
Exemplo n.º 4
0
 def _test_attributes(self):
     cluster = self.store.cluster
     assert util.is_str_uuid(cluster.id) or util.is_str_int(cluster.id)
     assert util.is_str(cluster.href) and cluster.href.endswith(cluster.id)
     assert util.is_str(cluster.name) and len(cluster.name) > 0
     assert cluster.description is None or util.is_str(cluster.description)
     assert cluster.data_center is not None
     assert util.is_str_uuid(cluster.data_center.id)
     assert cluster.version is not None
     assert util.is_int(cluster.version.major) and cluster.version.major > 0
     assert util.is_int(cluster.version.minor)
     assert cluster.supported_versions is not None
     for version in cluster.supported_versions.version:
         assert util.is_int(version.major) and version.major > 0
         assert util.is_int(version.minor)
     assert cluster.cpu is not None
     assert util.is_str(cluster.cpu.id)
     assert cluster.memory_policy is not None
     assert util.is_int(cluster.memory_policy.overcommit.percent)
     if cluster.scheduling_policy:
         assert cluster.scheduling_policy.policy in \
                     ('EVEN_DISTRIBUTION', 'POWER_SAVING')
         assert util.is_int(cluster.scheduling_policy.thresholds.low)
         assert util.is_int(cluster.scheduling_policy.thresholds.high)
         assert util.is_int(cluster.scheduling_policy.thresholds.duration)
Exemplo n.º 5
0
 def _test_network_attributes(self):
     cluster = self.store.cluster
     network = self.store.network
     atnetwork = self.store.atnetwork
     assert isinstance(atnetwork, schema.Network)
     assert util.is_str_uuid(atnetwork.id)
     assert atnetwork.id == network.id
     assert util.is_str_href(atnetwork.href)
     assert atnetwork.href != network.href
     assert atnetwork.href.startswith(cluster.href)
     assert atnetwork.href.endswith(network.id)
     assert util.is_str(atnetwork.name) and len(atnetwork.name) > 0
     assert atnetwork.name == network.name
     assert util.is_str(atnetwork.description) and len(atnetwork.description) > 0
     assert atnetwork.description == network.description
     assert atnetwork.status in ('OPERATIONAL', 'NON_OPERATIONAL')
     assert isinstance(atnetwork.data_center, schema.DataCenter)
     assert atnetwork.data_center.id == network.data_center.id
     assert isinstance(atnetwork.cluster, schema.Cluster)
     assert atnetwork.cluster.id == cluster.id
     assert util.is_bool(atnetwork.stp)
     assert atnetwork.stp == network.stp
     assert util.is_bool(atnetwork.display)
     assert isinstance(atnetwork.vlan, schema.VLAN)
     assert util.is_int(atnetwork.vlan.id)
     assert atnetwork.vlan.id == network.vlan.id
     assert isinstance(atnetwork.ip, schema.IP)
     assert util.is_str_ip(atnetwork.ip.address)
     assert util.is_str_ip(atnetwork.ip.netmask)
     assert util.is_str_ip(atnetwork.ip.gateway)
     assert atnetwork.ip.address == network.ip.address
     assert atnetwork.ip.netmask == network.ip.netmask
     assert atnetwork.ip.gateway == network.ip.gateway
Exemplo n.º 6
0
 def _test_attributes(self):
     host = self.store.host
     assert util.is_str_int(host.id) or util.is_str_uuid(host.id)
     assert util.is_str(host.href) and host.href.endswith(host.id)
     assert util.is_str(host.name) and len(host.name) > 0
     assert host.status in ( 'DOWN', 'ERROR', 'INITIALIZING', 'INSTALLING',
             'INSTALL_FAILED', 'MAINTENANCE', 'NON_OPERATIONAL',
             'NON_RESPONSIVE', 'PENDING_APPROVAL',
             'PREPARING_FOR_MAINTENANCE', 'PROBLEMATIC', 'REBOOT',
             'UNASSIGNED', 'UP')
     assert host.type in ('RHEV_H', 'RHEL')  # BUG: missing
     assert util.is_str_ip(host.address)  # BUG: missing
     assert util.is_str_int(host.cluster.id) or util.is_str_uuid(host.cluster.id)
     assert util.is_int(host.port) and host.port > 0
     assert host.root_password is None
     assert host.power_management is not None
     assert util.is_bool(host.power_management.enabled)
     if host.power_management.enabled:
         assert util.is_str_ip(host.power_management.address)
         assert util.is_str(host.power_management.username)
         assert host.power_management.password is None
         if host.power_management.options:
             opts = host.power_management.options.option
             for opt in opts:
                 assert util.is_str(opt.name) and len(opt.name) > 0
                 assert util.is_str(opt.value_)
     assert util.is_bool(host.storage_manager)
     assert isinstance(host.summary.vms.count, int)  # BUG: missing
     assert isinstance(host.summary.vms.active, int)  # BUG: missing
     assert isinstance(host.summary.vms.migrating, int)  # BUG: missing
Exemplo n.º 7
0
 def _test_attributes(self):
     dc = self.store.dc
     assert util.is_str_uuid(dc.id)
     assert util.is_str(dc.href) and dc.href.endswith(dc.id)
     assert util.is_str(dc.name) and len(dc.name) > 0
     assert dc.description is None or util.is_str(dc.description)
     assert dc.storage_type in ('nfs', 'iscsi', 'fcp')
     # A few statuses are probably missing
     assert dc.status in ('UP', 'DOWN', 'ERROR', 'UNINITIALIZED',
             'MAINTENANCE', 'NON_OPERATIONAL', 'NON_RESPONSIVE',
             'PROBLEMATIC')
     assert dc.version is not None
     assert util.is_int(dc.version.major) and dc.version.major > 0
     assert util.is_int(dc.version.minor)
     assert dc.supported_versions is not None
     for version in dc.supported_versions.version:
         assert util.is_int(version.major) and version.major > 0
         assert util.is_int(version.minor)
Exemplo n.º 8
0
 def _test_attributes(self):
     nic = self.store.nic
     assert nic is not None
     assert util.is_str_uuid(nic.id)
     assert util.is_str(nic.href) and nic.href.endswith(nic.id)
     assert util.is_str(nic.name) and len(nic.name) > 0
     assert nic.status in ('UP', 'DOWN')  # BUG: missing
     assert util.is_str_int(nic.host.id) or util.is_str_uuid(nic.host.id)
     assert util.is_str_uuid(nic.network.id)
     assert util.is_str_mac(nic.mac.address)
     assert util.is_str_ip(nic.ip.address)
     assert util.is_str_ip(nic.ip.netmask)
     assert util.is_str_ip(nic.ip.gateway)
     if nic.vlan is not None:
         assert util.is_int(nic.vlan.id) and nic.vlan.id > 0
     assert util.is_int(nic.speed)  # BUG: missing
     assert nic.boot_protocol in ('DHCP', 'STATIC', 'NONE')  # BUG: missing
     assert isinstance(nic.check_connectivity, bool)  # BUG: missing
Exemplo n.º 9
0
 def test_attributes(self):
     vm = self.store.vm
     vm = self.api.reload(vm)
     assert util.is_str_uuid(vm.id)
     assert util.is_str_href(vm.href)
     assert util.is_str(vm.name)
     assert vm.description is None or util.is_str(vm.description)
     assert vm.type in ('SERVER', 'DESKTOP')
     assert vm.status in ('UNASSIGNED', 'DOWN', 'UP', 'POWERING_UP',
             'POWERED_DOWN', 'PAUSED', 'MIGRATING_FROM', 'MIGRATING_TO',
             'UNKNOWN', 'NOT_RESPONDING', 'WAIT_FOR_LAUNCH',
             'REBOOT_IN_PROGRESS', 'SAVING_STATE', 'RESTORING_STATE',
             'SUSPENDED', 'IMAGE_ILLEGAL', 'IMAGE_LOCKED', 'POWERING_DOWN')
     assert vm.origin in ('RHEV', 'VMWARE', 'XEN')
     assert util.is_date(vm.creation_time)
     assert util.is_int(vm.memory) and vm.memory > 0
     assert vm.cpu is not None
     assert vm.cpu.topology is not None
     assert util.is_int(vm.cpu.topology.cores)
     assert vm.cpu.topology.cores > 0
     assert util.is_int(vm.cpu.topology.sockets)
     assert vm.cpu.topology.sockets > 0
     assert vm.display is not None
     assert vm.display.type in ('VNC', 'SPICE')
     if vm.status == 'UP':
         assert util.is_int(vm.display.port)
         assert vm.display.port > 0
         assert util.is_str_host(vm.display.address)
     assert util.is_int(vm.display.monitors)
     assert vm.display.monitors > 0
     assert vm.os is not None
     assert util.is_str(vm.os.type)
     assert vm.os.boot is not None
     for dev in vm.os.boot:
         assert dev.dev in ('cdrom', 'hd', 'network')
     assert util.is_bool(vm.stateless)
     if vm.host is not None:
         assert util.is_str_int(vm.host.id) or util.is_str_uuid(vm.host.id)
     assert vm.cluster is not None
     assert util.is_str_int(vm.cluster.id) or util.is_str_uuid(vm.cluster.id)
     assert vm.template is not None
     assert util.is_str_uuid(vm.template.id)
     if vm.vmpool is not None:
         assert util.is_str_uuid(vm.vmpool.id)
Exemplo n.º 10
0
 def test_disk_attributes(self):
     disk = self.store.disk
     assert util.is_int(disk.size)
     assert disk.type in ('DATA', 'SHARED', 'SYSTEM', 'SWAP', 'TEMP')
     assert disk.status in ('ILLEGAL', 'INVALID', 'LOCKED', 'OK')
     assert disk.interface in ('IDE', 'SCSI', 'VIRTIO')
     assert disk.format in ('COW', 'RAW')
     assert util.is_bool(disk.sparse)
     assert util.is_bool(disk.bootable)
     assert util.is_bool(disk.wipe_after_delete)
Exemplo n.º 11
0
 def test_disk_attributes(self):
     disk = self.store.disk
     assert util.is_int(disk.size)
     assert disk.type in ('data', 'system')
     assert disk.status in ('ILLEGAL', 'INVALID', 'LOCKED', 'OK')
     assert disk.interface in ('ide', 'scsi', 'virtio')
     assert disk.format in ('cow', 'raw')
     assert util.is_bool(disk.sparse)
     assert util.is_bool(disk.bootable)
     assert util.is_bool(disk.wipe_after_delete)
Exemplo n.º 12
0
 def test_ticket(self):
     vm = self.store.vm
     action = schema.new(schema.Action)
     action.expiry = 120
     action = self.api.action(vm, 'ticket')
     assert action.status == 'COMPLETE'
     assert isinstance(action.ticket, schema.Ticket)
     assert util.is_str(action.ticket.value_) and \
             len(action.ticket.value_) > 0
     assert util.is_int(action.ticket.expiry) and \
             action.ticket.expiry > 0
Exemplo n.º 13
0
 def test_statistics_attributes(self):
     vm = self.store.vm
     for stat in vm.statistics.statistic:
         assert isinstance(stat, schema.Statistic)
         assert util.is_str_uuid(stat.id)
         assert util.is_str(stat.name) and len(stat.name) > 0
         assert util.is_str(stat.description) and len(stat.description) > 0
         assert isinstance(stat.values, schema.Values)
         assert stat.values.type in ('DECIMAL', 'INTEGER')
         for val in stat.values.value_:
             assert isinstance(val, schema.Value)
             assert util.is_int(val.datum) or \
                     util.is_float(val.datum)
         assert stat.type in ('GAUGE', 'COUNTER')
         assert stat.unit in ('NONE', 'PERCENT', 'BYTES', 'SECONDS',
                              'BYTES_PER_SECOND', 'BITS_PER_SECOND',
                              'COUNT_PER_SECOND')
Exemplo n.º 14
0
 def _test_attributes(self):
     network = self.store.network
     assert util.is_str_uuid(network.id)
     assert util.is_str(network.href) and network.href.endswith(network.id)
     assert util.is_str(network.name) and len(network.name) > 0
     assert network.description is None or util.is_str(network.description)
     assert util.is_str_uuid(network.data_center.id)
     if network.ip is not None:
         assert network.ip.address is None or \
                 util.is_str_ip(network.ip.address)
         assert network.ip.netmask is None or \
                 util.is_str_ip(network.ip.netmask)
         assert network.ip.gateway is None or \
                 util.is_str_ip(network.ip.gateway)
     if network.vlan is not None:
         assert util.is_int(network.vlan.id)
     assert util.is_bool(network.stp)
     assert util.is_bool(network.display)
     assert network.status in ('OPERATIONAL', 'NON_OPERATIONAL')
Exemplo n.º 15
0
 def test_attributes(self):
     event = self.api.reload(self.store.event)
     assert isinstance(event, schema.Event)
     assert util.is_str(event.description) and len(event.description) > 1
     assert util.is_int(event.code)
     assert util.is_str(event.severity)