예제 #1
0
    def setUp(self):
        self.block_size = 1024
        self.test_disk_blocks = 256000  # 250MB
        global skip_tests

        if not skip_tests:
            vixconfig = setupConfigs(
            )  # make sure that the vix configuration file exists
            self.options = Options()
            # we must have a ~/.visdkrc.vcenter file for this to work
            try:
                self.options.load(
                    "~/.visdkrc.esxi-prod-01.vm.kingsolutions.local")
            except:
                skip_tests = True
                raise

            print self.options
            # make a VISDK connection to the vcenter
            self.vim = Vim(self.options.VI_SERVER)
            self.vim.login(self.options.VI_USERNAME, self.options.VI_PASSWORD)

            # get the virtual machine that we want to test with...
            self.vm = self.vim.getVirtualMachine("puppetTestAppServer")

            # Connect to the vcenter with the vix_disk_lib using the managed object reference of the vm we will use
            creds = VixCredentials(
                vmxSpec=self.vm.ref.value,
                host=self.options.VI_SERVER,
                username=self.options.VI_USERNAME,
                password=self.options.VI_PASSWORD,
            )

            self.disk = VixDisk(creds, libdir=libdir, config=vixconfig)
            self.disk.connect(readonly=False)
예제 #2
0
def get_connection(block_size=default_block_size):
    vix_config = setupConfigs()

    disk = VixDisk(libdir="/usr/lib/vmware-vix-disklib/lib64",
                   config=vix_config,
                   block_size=block_size)
    disk.connect(readonly=False)
    return disk