On 05/08/2014 11:37 PM, Gary Lloyd wrote:
When I add direct Luns this way the size shows as <1 on the GUI
and 0 when called from the rest api. All the other items mentioned are not present.
Thanks
Ah, I understand. This is probably related to the fact that you aren't
creating a storage domain, only the storage connection. This should work
correctly, but I guess that either the GUI or the backend aren't
completely prepared for this. I'm checking.
> On 8 May 2014, at 18:05, Juan Hernandez
<jhernand(a)redhat.com> wrote:
>
>> On 05/08/2014 05:04 PM, Gary Lloyd wrote:
>>
>> We are working on a script so that we can create an ISCSI LUN on our SAN
>> and then directly assign it to a vm.
>>
>> We have been able to get it to work but with one small annoyance. I
>> can't figure out how to populate size,serial,vendor_id and product_id
>> via the api. Would anyone be able to point me in the right direction ?
>> code (see def add_disk):
>>
>> def get_clusterid(cluster_name):
>> cluster = ovirt_api.clusters.get(cluster_name)
>> try:
>> return cluster.id <
http://cluster.id>
>> except:
>> logging.error('the cluster: %s does not appear to exist' %
>> cluster_name )
>> sys.exit(1)
>>
>> def nominate_host(cluster_id):
>> for host in ovirt_api.hosts.list():
>> if host.cluster.id <
http://host.cluster.id> == cluster_id and
>> host.status.state == 'up':
>> host.iscsidiscover
>> return host
>> logging.error('could not find a suitable host to nominate in
cluster:')
>> sys.exit(1)
>>
>>
>> def iscsi_discover_and_login(cluster,target,portal,chap_user,chap_pass):
>> clusterid=get_clusterid(cluster)
>> host=nominate_host(clusterid)
>>
>> iscsidet = params.IscsiDetails()
>> iscsidet.address=portal
>> iscsidet.username=chap_user
>> iscsidet.password=chap_pass
>> iscsidet.target=target
>>
>> host.iscsidiscover(params.Action(iscsi=iscsidet))
>> result = host.iscsilogin(params.Action(iscsi=iscsidet))
>>
>> if result.status.state == 'complete':
>>
>> storecon = params.StorageConnection()
>> storecon.address=portal
>> storecon.type_='iscsi'
>> storecon.port=3260
>> storecon.target=target
>> storecon.username=chap_user
>> storecon.password=chap_pass
>>
>> ovirt_api.storageconnections.add(storecon)
>>
>> return result
>> # error checking code needs to be added to this function
>>
>> def add_disk(vm_name,wwid,target,size,portal):
>>
>> logunit = params.LogicalUnit()
>> logunit.id <
http://logunit.id>=wwid
>> logunit.vendor_id='EQLOGIC'
>> logunit.product_id='100E-00'
>> logunit.port=3260
>> logunit.lun_mapping=0
>> logunit.address=portal
>> logunit.target=target
>> logunit.size=size * 1073741824
>>
>> stor = params.Storage(logical_unit=[logunit])
>> stor.type_='iscsi'
>>
>>
>> disk = params.Disk()
>> disk.alias = 'vm-' + vm_name
>> disk.name <
http://disk.name> = disk.alias
>> disk.interface = 'virtio'
>> disk.bootable = True
>> disk.type_ = 'iscsi'
>> disk.format='raw'
>> disk.set_size(size * 1073741824)
>> #disk.size=size * 1073741824
>> #disk.active=True
>>
>> disk.lun_storage=stor
>>
>> try:
>> result = ovirt_api.disks.add(disk)
>> except:
>> logging.error('Could not add disk')
>> sys.exit(1)
>>
>> attachdisk=ovirt_api.disks.get(disk.alias)
>> attachdisk.active = True
>>
>> try:
>> ovirt_api.vms.get(vm_name).disks.add(attachdisk)
>> except:
>> logging.error('Could attach disk to vm')
>> sys.exit(1)
>>
>> return result
>>
>>
>>
>> If we could just get the size to show correctly that would be enough,
>> the others don't really matter to me.
>>
>>
>> Thanks
>>
>> /Gary Lloyd/
>
> For a direct LUN disk all these values are ready only. Why do you need
> to change them?
>
> --
> Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
> 3ºD, 28016 Madrid, Spain
> Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.
_______________________________________________
Users mailing list
Users(a)ovirt.org
http://lists.ovirt.org/mailman/listinfo/users
--
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
3ºD, 28016 Madrid, Spain
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.