Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Commit

Permalink
Cleanup of TODO and rename of python tests
Browse files Browse the repository at this point in the history
- removed useless TODOs. The majority of them are resolved,
and for those not resolved new issued are created (e.g. #205 #206)
- renamed tests_*.py to *_test.py to make consistent with go tests,
which are always named *_test.go (enforced by 'go test')
  • Loading branch information
Mark Sterin committed Mar 28, 2016
1 parent 5787024 commit 4295320
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 103 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -200,7 +200,7 @@ ECHO = $(DEBUG) echo
test-esx:
$(TAR) cz --no-recursion $(ESX_SRC)/*.py | $(SSH) root@$(ESX) "cd /tmp; $(TAR) xz"
$(ECHO) Running unit tests for vmdk-opsd python code on $(ESX)...
$(SSH) root@$(ESX) "python /tmp/$(ESX_SRC)/tests_vmdk_ops.py"
$(SSH) root@$(ESX) "python /tmp/$(ESX_SRC)/vmdk_ops_test.py"
$(SSH) root@$(ESX) rm -rf /tmp/$(ESX_SRC)

testremote: test-esx test-vm
Expand Down
47 changes: 9 additions & 38 deletions plugin.go
@@ -1,43 +1,14 @@
package main

//
// A VMDK Docker Data Volume plugin
// (for now just an outline)
// VMWare VMDK Docker Data Volume plugin.
//
// It checks that it can connect to ESX via vSocket , and then
// fakes the successful ops by returning success and printing a messafe,
// without doing anything useful (useful stuff is work in progress)
// Provide suport for --driver=vmdk in Docker, when Docker VM is running under ESX.
//
// TBD: add check for the guest communicates from ROOT - check the doc wrt security
// TBD: check we are running inside ESX and tools installed - in CODE , not make

// TODO:
// convert all to return error() and only response to docker to return msg
//
// make sure msg and err is properly initialized everywhere (and check in go if it's needed)
// This code received requests from Docker Engine and requests/coordinates
// related VMDK operations with vmdk-opsd service running on enclosing host ESX
// (see ./vmdkops-esxsrv)
///
//TODO :
// Potentially: add unit test , fully contained on 1 Linux machine:
//- make server code actually create a loop block device and do a bind mount for volume test
//- hardcode location for testing (/var/vmware/dvolplug/volumes/vol-name
// fallocate -d -l <length> volume.img
// losetup -v /dev/loop$(id) -f volume.img
// mkfs.ext4 /dev/loop$(id)
// mount /dev/lopp$(id) /mnt/loop$(id) # mount all here. Or skip
// mount -o bind # bind mount where Docker asks
// Good refs: https://www.suse.com/communities/blog/accessing-file-systems-disk-block-image-files/
//)
// for actual mounts:
//- add actual create/mount code instead of prints
//
// TODO: add volumes tracking per the following docker spec:
//
// multiple containers on the same docker engine may use the same vmdk volume
// thus we need to track the volumes already attached, and just do bind mount for them
// Also it means we need to serialize all ops with mutex

// We also need to track volumes attached and mounted to save on this ops if requested
// On start, we need to list vmdks attached to the VM and polulate list of volumes from it

import (
// "encoding/json"
Expand All @@ -55,7 +26,7 @@ const (
)

type vmdkDriver struct {
m *sync.Mutex // create() serialization
m *sync.Mutex // create() serialization - FFU
mockEsx bool
ops vmdkops.VmdkOps
}
Expand All @@ -68,7 +39,6 @@ func newVmdkDriver(mockEsx bool) vmdkDriver {
vmdkCmd = vmdkops.VmdkCmd{}
}
d := vmdkDriver{
// TODO: volumes map(string)volinfo, (name->uuid/refcount/creationtime)
m: &sync.Mutex{},
mockEsx: mockEsx,
ops: vmdkops.VmdkOps{Cmd: vmdkCmd},
Expand Down Expand Up @@ -112,9 +82,10 @@ func (d vmdkDriver) mountVolume(r volume.Request, path string) error {
return nil
}

// TODO: refcount if the volume is already mounted (for other container) and
// TODO: Issue #28
// - refcount if the volume is already mounted (for other container) and
// just return volume.Response{Mountpoint: m} in this case
// TODO: save info abouf voliume mount , in memory
// - save info abouf voliume mount , in memory
// d.volumes[m] = &volumeName{name: r.Name, connections: 1}
if err := d.ops.Attach(r.Name, r.Options); err != nil {
return err
Expand Down
75 changes: 11 additions & 64 deletions vmdkops-esxsrv/vmdk_ops.py
@@ -1,73 +1,20 @@
#!/usr/bin/env python

'''
TOP TODO
0. extract attach/detach code and make sure it work fine without anything else
1. add WaitForTask in Python and drop sleep, Also add time track for reconfigure
2. Add scsi_resync to plugin.go. Check how mount is done in flocker and in VIC
3. Go over code, and collect TODO in one place (add TODO file)
4. add simple test script (or sketch it)
5. Look at cleaning up makefile and adding godeps
'''
ESX-side service handling VMDK create/attach requests from VMCI clients
The requests (create/delete/attach/detach) are JSON formatted.
#
# ESX-side service handling VMDK creat/attach requests from VMCI clients
#
# The requests (create/delete/attach/detach) are JSON formatted.
#
# All operations are using requester VM (docker host) datastore and
# "Name" in request refers to vmdk basename
# VMDK name is formed as [vmdatastore] dvol/"Name".vmdk
#
# Commands ("cmd" in request):
# "create" - create a VMDK in "[vmdatastore] dvol"
# "remove" - remove a VMDK. We assume it's not open, and fail if it is
# "list" - [future, need docker support] enumerate related VMDK
# "attach" - attach a VMDK to the requesting VM
# "detach" - detach a VMDK from the requesting VM (assuming it's unmounted)
#
#
# known issues:
# - need interrupt handler to restart listen() on control-c
# - call VirtualDiskManager directly instead of cmd line
# - todo/tbd below
All operations are using requester VM (docker host) datastore and
"Name" in request refers to vmdk basename
VMDK name is formed as [vmdatastore] dvol/"Name".vmdk
'''
TODO
==
Drop command line and use VDM for disk manipulation:
spec=vim.FileBackedVirtualDiskSpec(capacityKB=1024, profile = None ,adapterType='lsiLogic', diskType = 'thin')
vdm = si.content.virtualDiskManager
vdm.CreateVirtualDisk_Task(name="[datastore] eek/a1.vmdk", datadatacenter=dc, spec = spec)
vm = findVmByName()... ; vm.config.datastoreUrl[0].name is datastore
see https://opengrok.eng.vmware.com/source/xref/vmcore-main.perforce.1666/bora/vmkernel/tests/vsan/vsansparse_sanity.py#314
or even better https://gist.github.com/hartsock/d8b9c56cd7f779c92a78 (fails if exists)
for examples
==
make sure backend name is properly calculated -
OR replace it all with in-guest formatting (but then we'd need to locate the proper blockdevice()
With the current approach, new device is found for mount with blkid -L <volume-name>, which is easier
===
check size format and handle policy on -o flags
==
make sure the NEW disk is really formatted if if it does not have -flat.vmdk
==
findChild seems to generate a task - too slow. Find out where and drop
==
Pass error as a code in the VMCI package, rather than a hack with server.c:vmci_reply
===
* TBD: authorization/access config:
* - location configuration. And generally, configuration... host profile/adv.conf?
* - a local version, talking over Unix Socket, to debug all I can on Linux - with logic and fake responses (part of build unit test)
* - an ESX version, talking over http , to debug logic on a random ESX - with full vigor API usage
* - an ESX version, with vSocket (C I suppose) connection, to finalize debugging on actual guest/host story
Commands ("cmd" in request):
"create" - create a VMDK in "[vmdatastore] dvol"
"remove" - remove a VMDK. We assume it's not open, and fail if it is
"list" - [future, need docker support] enumerate related VMDK
"attach" - attach a VMDK to the requesting VM
"detach" - detach a VMDK from the requesting VM (assuming it's unmounted)
'''

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 4295320

Please sign in to comment.