當前位置: 首頁>>代碼示例>>Golang>>正文


Golang container.RemoveDirectory函數代碼示例

本文整理匯總了Golang中github.com/juju/juju/container.RemoveDirectory函數的典型用法代碼示例。如果您正苦於以下問題:Golang RemoveDirectory函數的具體用法?Golang RemoveDirectory怎麽用?Golang RemoveDirectory使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了RemoveDirectory函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: DestroyContainer

func (manager *containerManager) DestroyContainer(id instance.Id) error {
	start := time.Now()
	name := string(id)
	lxcContainer := LxcObjectFactory.New(name)
	if useRestartDir() {
		// Remove the autostart link.
		if err := os.Remove(restartSymlink(name)); err != nil {
			logger.Errorf("failed to remove restart symlink: %v", err)
			return err
		}
	}

	// Detach loop devices backed by files inside the container's rootfs.
	rootfs := filepath.Join(LxcContainerDir, name, "rootfs")
	if err := manager.loopDeviceManager.DetachLoopDevices(rootfs, "/"); err != nil {
		logger.Errorf("failed to detach loop devices from lxc container: %v", err)
		return err
	}

	if err := lxcContainer.Destroy(); err != nil {
		logger.Errorf("failed to destroy lxc container: %v", err)
		return err
	}

	err := container.RemoveDirectory(name)
	logger.Tracef("container %q stopped: %v", name, time.Now().Sub(start))
	return err
}
開發者ID:claudiu-coblis,項目名稱:juju,代碼行數:28,代碼來源:lxc.go

示例2: TestRemoveContainerDir

func (s *DirectorySuite) TestRemoveContainerDir(c *gc.C) {
	dir, err := container.NewDirectory("testing")
	c.Assert(err, jc.ErrorIsNil)
	err = container.RemoveDirectory("testing")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(dir, jc.DoesNotExist)
	c.Assert(filepath.Join(s.removedDir, "testing"), jc.IsDirectory)
}
開發者ID:howbazaar,項目名稱:juju,代碼行數:8,代碼來源:directory_test.go

示例3: DestroyContainer

func (manager *containerManager) DestroyContainer(id instance.Id) error {
	name := string(id)
	kvmContainer := KvmObjectFactory.New(name)
	if err := kvmContainer.Stop(); err != nil {
		logger.Errorf("failed to stop kvm container: %v", err)
		return err
	}
	return container.RemoveDirectory(name)
}
開發者ID:klyachin,項目名稱:juju,代碼行數:9,代碼來源:kvm.go

示例4: TestRemoveContainerDirWithClash

func (s *DirectorySuite) TestRemoveContainerDirWithClash(c *gc.C) {
	dir, err := container.NewDirectory("testing")
	c.Assert(err, jc.ErrorIsNil)

	clash := filepath.Join(s.removedDir, "testing")
	err = os.MkdirAll(clash, 0755)
	c.Assert(err, jc.ErrorIsNil)

	err = container.RemoveDirectory("testing")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(dir, jc.DoesNotExist)
	c.Assert(filepath.Join(s.removedDir, "testing.1"), jc.IsDirectory)
}
開發者ID:howbazaar,項目名稱:juju,代碼行數:13,代碼來源:directory_test.go


注:本文中的github.com/juju/juju/container.RemoveDirectory函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。