On 03/03/2015 11:20, Christy Perez wrote:
>
> On 03/03/2015 03:04 AM, Royce Lv wrote:
>> I think we may need to do a work around in UI as debug report did.
>> If a user clicked "+" on VM page, then this request get 202 response.
>> but after next round of GET /vms query, this VM may still not displayed
>> in VM tab, making user want to issue create again or wander if POST
>> request properly handled.
>>
>> So we may want to display a vm creating in progress icon to users in UI.
> Definitely. I just had to leave that part implemented since I'm not so
> UI-savy.
To update the UI, look for "getTasksByFilter" and update the filter
parameter according to your changes.
I can do that (and did do that) to update the
clone tasks, but I can't
create a a new one for the *create* filter and add the progress
indicator, etc. I think that's what Royce was talking about (create, not
clone).
>> On 02/27/2015 10:41 AM, Christy Perez wrote:
>>> Signed-off-by: Christy Perez <christy(a)linux.vnet.ibm.com>
>>> ---
>>> src/kimchi/control/vms.py | 4 ++--
>>> src/kimchi/model/vms.py | 28 +++++++++++++++++++++++++---
>>> 2 files changed, 27 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py
>>> index 5068b7c..8a31dc0 100644
>>> --- a/src/kimchi/control/vms.py
>>> +++ b/src/kimchi/control/vms.py
>>> @@ -17,13 +17,13 @@
>>> # License along with this library; if not, write to the Free
>>> Software
>>> # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
>>> 02110-1301 USA
>>>
>>> -from kimchi.control.base import Collection, Resource
>>> +from kimchi.control.base import AsyncCollection, Resource
>>> from kimchi.control.utils import internal_redirect, UrlSubNode
>>> from kimchi.control.vm import sub_nodes
>>>
>>>
>>> @UrlSubNode('vms', True)
>>> -class VMs(Collection):
>>> +class VMs(AsyncCollection):
>>> def __init__(self, model):
>>> super(VMs, self).__init__(model)
>>> self.resource = VM
>>> diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
>>> index 078e63e..8b55278 100644
>>> --- a/src/kimchi/model/vms.py
>>> +++ b/src/kimchi/model/vms.py
>>> @@ -78,6 +78,7 @@ def __init__(self, **kargs):
>>> self.conn = kargs['conn']
>>> self.objstore = kargs['objstore']
>>> self.caps = CapabilitiesModel(**kargs)
>>> + self.task = TaskModel(**kargs)
>>>
>>> @staticmethod
>>> def _update_guests_stats(names, conn):
>>> @@ -181,7 +182,6 @@ def _get_disk_io_rate(vm_uuid, dom, seconds):
>>> 'diskWrKB': diskWrKB})
>>>
>>> def create(self, params):
>>> - conn = self.conn.get()
>>> t_name = template_name_from_uri(params['template'])
>>> vm_uuid = str(uuid.uuid4())
>>> vm_list = self.get_list()
>>> @@ -203,6 +203,26 @@ def create(self, params):
>>>
>>> t.validate()
>>>
>>> + taskid = add_task(u'/vms/%s' % name, 'create',
>>> + self._create_task, self.objstore,
>>> + {'vm_uuid': vm_uuid, 'template':
t, 'name':
>>> name})
>>> +
>>> + return self.task.lookup(taskid)
>>> +
>>> + def _create_task(self, cb, params):
>>> + """
>>> + params: A dict with the following values:
>>> + - vm_uuid: The UUID of the VM being created
>>> + - template: The template being used to create the VM
>>> + - name: The name for the new VM
>>> + """
>>> +
>>> + vm_uuid = params['vm_uuid']
>>> + t = params['template']
>>> + name = params['name']
>>> + conn = self.conn.get()
>>> +
>>> + cb('Storing VM icon')
>>> # Store the icon for displaying later
>>> icon = t.info.get('icon')
>>> if icon:
>>> @@ -217,6 +237,7 @@ def create(self, params):
>>>
>>> # If storagepool is SCSI, volumes will be LUNs and must be
>>> passed by
>>> # the user from UI or manually.
>>> + cb('Provisioning storage for new VM')
>>> vol_list = []
>>> if t._get_storage_type() not in ["iscsi",
"scsi"]:
>>> vol_list = t.fork_vm_storage(vm_uuid)
>>> @@ -229,6 +250,7 @@ def create(self, params):
>>> graphics=graphics,
>>> volumes=vol_list)
>>>
>>> + cb('Defining new VM')
>>> try:
>>> conn.defineXML(xml.encode('utf-8'))
>>> except libvirt.libvirtError as e:
>>> @@ -239,10 +261,10 @@ def create(self, params):
>>> raise OperationFailed("KCHVM0007E", {'name':
name,
>>> 'err':
>>> e.get_error_message()})
>>>
>>> + cb('Updating VM metadata')
>>> VMModel.vm_update_os_metadata(VMModel.get_vm(name,
>>> self.conn), t.info,
>>> self.caps.metadata_support)
>>> -
>>> - return name
>>> + cb('OK', True)
>>>
>>> def get_list(self):
>>> return VMsModel.get_vms(self.conn)
>> _______________________________________________
>> Kimchi-devel mailing list
>> Kimchi-devel(a)ovirt.org
>>
http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel(a)ovirt.org
>
http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>