def pushFile(request): vcenter = Vcenter.objects.get(pk=1) vc = vmvc.connect_vcenter(vcenter) vm = vc.get_vm_by_name("dborysenko-test-vm") vm.login_in_guest("oracle", "qwer1234") files = vm.list_files("/users/oracle") vc.disconnect() return render(request, 'vmware/fileList.html', {"files": files})
def cloneVm(request): vcenter = Vcenter.objects.get(pk=1) vc = vmvc.connect_vcenter(vcenter) template = vc.get_vm_by_name(request.POST['template']) cluster_name = request.POST['vm_cluster_name'] try: cluster = [k for k, v in vc.get_clusters().items() if v == cluster_name][0] resource_pool = vc.get_resource_pools(from_mor=cluster).items()[0][0] except IndexError, e: vc.disconnect() print "Error: Cannot find cluster - " + cluster_name print str(e)