示例#1
0
    def setUp(self):
        """
        Connects to the host and creates test VM.
        """
        self._host = vimhost.Host()
        connect.SetSi(self._host._si)
        # Create dummy test VM
        self._vmname = "ttt.%s" % str(self.__class__.__module__)
        if (self._vmname is None):
            raise self.failureException(
                "Test VM name is not a valid path name. %s" % (self._vmname))
        try:
            self.destroyTestVM(self._vmname)
            envBrowser = invt.GetEnv()
            cfgTarget = envBrowser.QueryConfigTarget(None)
            if len(cfgTarget.GetDatastore()) == 0:
                cm = host.GetHostConfigManager(self._si)
                dsm = cm.GetDatastoreSystem()
                # todo is this going to work on vmkernel
                dsm.CreateLocalDatastore("tttds1", "/var/tmp")

            # create a quick dummy test VM with one SCSI disk
            self._vm = vm.CreateQuickDummy(self._vmname, 1)
            vm1 = vm.VM(self._vm, None, None)
            if (not vm1.IsPoweredOff()):
                raise self.failureException(
                    "Newly created test VM should be powered off.")
        except Exception as msg:
            raise self.failureException(
                "Failed to create test VM \"%s\" on host=\"%s\": %s" %
                (self._vmname, self._host, msg))
        print("INFO: created vm %s " % (self._vmname))
示例#2
0
 def __init__(self, si):
    self._si = si
    self._hostSystem = host.GetHostSystem(si)
    self._configMgr = host.GetHostConfigManager(si)
    self._storageSystem = self._configMgr.GetStorageSystem()
    self._vFlashManager = self._configMgr.GetVFlashManager()
    self._datastoreSystem = self._configMgr.GetDatastoreSystem()
示例#3
0
def main():
   supportedArgs = [ (["h:", "host="], "localhost", "Host name", "host"),
                    (["u:", "user="******"root", "User name", "user"),
                    (["p:", "pwd="], "", "password", "pwd"),
                    (("t:", "test="), "lun", "test lun, vmfs, or nas", "test")
                    ]

   supportedToggles = [ (["usage", "help"], False, "Show usage information", "usage") ]

   args = arguments.Arguments(sys.argv, supportedArgs, supportedToggles)
   if args.GetKeyValue("usage") == True:
      args.Usage()
      sys.exit(0)

   si = Connect(host=args.GetKeyValue("host"),
                user=args.GetKeyValue("user"),
                pwd=args.GetKeyValue("pwd"),
                version=newestVersions.get('vim'))

   atexit.register(Disconnect, si)
   global datastoreSystem
   datastoreSystem = host.GetHostConfigManager(si).GetDatastoreSystem()
   global storageSystem
   storageSystem = host.GetHostConfigManager(si).GetStorageSystem()
   test = args.GetKeyValue("test")
   if test == "lun":
      LunVerify()
      LunSimpleTest()
      LunNegativeTest()
   elif test == "vmfs":
      VmfsVerify()
      VmfsSimpleTest()
      VmfsNegativeTest()
   elif test == "nas":
      NasVerify()
      NasSimpleTest()
      NasNegativeTest()
   else:
      raise Exception("Unsupported test = " + test)
示例#4
0
def main():
    supportedArgs = [(["h:", "host="], "localhost", "Host name", "host"),
                     (["u:", "user="******"root", "User name", "user"),
                     (["p:", "pwd="], "", "password", "pwd"),
                     (("t:", "test="), "all", "test Options", "test")]

    supportedToggles = [(["usage",
                          "help"], False, "Show usage information", "usage")]

    args = arguments.Arguments(sys.argv, supportedArgs, supportedToggles)
    if args.GetKeyValue("usage") == True:
        args.Usage()
        sys.exit(0)
    '''
    si = Connect(host=args.GetKeyValue("host"),  #can be VC too
                 user=args.GetKeyValue("user"),
                 pwd=args.GetKeyValue("pwd"),
                 version=newestVersions.Get('vim'))
                 '''
    si = SmartConnect(host=args.GetKeyValue("host"),
                      user=args.GetKeyValue("user"),
                      pwd=args.GetKeyValue("pwd"))

    atexit.register(Disconnect, si)

    global datastoreSystem
    datastoreSystem = host.GetHostConfigManager(si).GetDatastoreSystem()

    global storageSystem
    storageSystem = host.GetHostConfigManager(si).GetStorageSystem()
    test = args.GetKeyValue("test")
    #    print(storageSystem.storageDeviceInfo)

    if test == "printDS":
        PrintDatastoreNames()

    if test == "getLuns":
        getLuns()
    if test == "getVolumes":
        getVolumes()
    if test == "getDisks":
        getDisks()
    if test == "getDS":
        getDS()
    if test == "getAll":
        getLuns()
        getVolumes()
        getDisks()
        getDS()
    if test == "testVMSpec":
        testVMSpec()

    if test == "datastoreSystem":
        getDS()
        RemoveDatastores()
        getDisks()
        CreateDatastores(diskIDs)
        if debug: PrintDatastoreNames()
        pass  # for Syntax check in case uncommneted all the up function call
    #separate different API calls, error prone if test them all together.
    if test == "storageSystem":
        getLuns()
        getVolumes()
        UnmountVolumes()  # must run this twice to successfully do detach
        UnmountVolumes()
        UnmountVolumes()
        UnmountVolumes()
        UnmountVolumes()
        DetachLuns()
        AttachLuns()
        MountVolumes(
        )  #must run twice for the host really see the mounts, i.e.
        #i.e.      able to see all  ls /vmfs/volume
        MountVolumes()
        pass

    if test == "all":
        getLuns()
        getVolumes()
        getDisks()
        RemoveDatastores()
        CreateDatastores(diskIDs)
        UnmountVolumes()  # must run this twice to successfully do detach
        UnmountVolumes()
        DetachLuns()
        AttachLuns()
        MountVolumes()  #must run twice for the host really see the mounts
        MountVolumes()

    if test == "removeDS":
        getDS()
        RemoveDatastores()

    if test == "createDS":
        getDisks()
        CreateDatastores(diskIDs)

    if test == "unmount":
        getVolumes()
        UnmountVolumes()
        UnmountVolumes()
        pass
    if test == "detach":
        print("Going to detach, make sure the volumes are unmounted first.")
        getLuns()
        DetachLuns()
        pass
    if test == "attach":
        getLuns()
        AttachLuns()
        pass
    if test == "mount":
        getVolumes()
        MountVolumes()
        MountVolumes()
        pass
    if test == "rescanVmfs":
        RescanVmfs()
    if test == "rescanHBA":
        RescanHBA()

    if test == "extra":
        global vols
        vols = []
        QueryUnresolvedVmfsVolume()
示例#5
0
文件: dataStore.py 项目: free-Zen/pvc
RemoveAllDataStores = False;
RemoveTestDataStores = True;
RemoveLocalDataStores = False;
testStorageSystem = False;
testCompute = True;
testResize = False;
testCreate = True;
testExpand = False;
testExtend = False;
delayBeforeDiskUpdates = 0 #60

si = connect.Connect('mckinley187', 443, 'root', 'ca$hc0w', "hostd", "SOAP", "vim25/5.5");
atexit.register(connect.Disconnect, si)
hostSystem = host.GetHostSystem(si);
configMgr = host.GetHostConfigManager(si);
dataStoreSystem = configMgr.GetDatastoreSystem();
storageSystem = configMgr.GetStorageSystem();

def RemoveDataStores():
	for ds in dataStoreSystem.datastore:
		print(ds.info.name)
#		print(ds.host)
		vmfsFileSystemInfos = [ fileSystemMountInfo
		for host in ds.host
			for fileSystemMountInfo in storageSystem.fileSystemVolumeInfo.mountInfo
				if fileSystemMountInfo.mountInfo.path == host.mountInfo.path
					and fileSystemMountInfo.volume.type=='VMFS'
		];
#		print(vmfsFileSystemInfos)
#		Possible Duplicates in device paths for multiple extents on the same disk