示例#1
0
func get_projects(c swift.Connection) []string {
	opts := new(swift.ContainersOpts)
	opts.Prefix = "jobs"

	containers, err := c.ContainerNames(opts)
	if err != nil {
		panic(err)
	}
	return containers
}
示例#2
0
func Example() {
	// Create a connection
	c := swift.Connection{
		UserName: "******",
		ApiKey:   "key",
		AuthUrl:  "auth_url",
	}
	// Authenticate
	err := c.Authenticate()
	if err != nil {
		panic(err)
	}
	// List all the containers
	containers, err := c.ContainerNames(nil)
	fmt.Println(containers)
	// etc...
}
示例#3
0
func ExampleConnection() {
	// Create a v1 auth connection
	c := swift.Connection{
		// This should be your username
		UserName: "******",
		// This should be your api key
		ApiKey: "key",
		// This should be a v1 auth url, eg
		//  Rackspace US        https://auth.api.rackspacecloud.com/v1.0
		//  Rackspace UK        https://lon.auth.api.rackspacecloud.com/v1.0
		//  Memset Memstore UK  https://auth.storage.memset.com/v1.0
		AuthUrl: "auth_url",
	}

	// Authenticate
	err := c.Authenticate()
	if err != nil {
		panic(err)
	}
	// List all the containers
	containers, err := c.ContainerNames(nil)
	fmt.Println(containers)
	// etc...

	// ------ or alternatively create a v2 connection ------

	// Create a v2 auth connection
	c = swift.Connection{
		// This is the sub user for the storage - eg "admin"
		UserName: "******",
		// This should be your api key
		ApiKey: "key",
		// This should be a version2 auth url, eg
		//  Rackspace v2        https://identity.api.rackspacecloud.com/v2.0
		//  Memset Memstore v2  https://auth.storage.memset.com/v2.0
		AuthUrl: "v2_auth_url",
		// Region to use - default is use first region if unset
		Region: "LON",
		// Name of the tenant - this is likely your username
		Tenant: "jim",
	}

	// as above...
}
示例#4
0
文件: osync.go 项目: jiangytcn/osync
func Main() {
	headers["X-Log-Retention"] = "true"
	headers["X-Container-Meta-fubar"] = "false"
	config := getConfig()
	err := config.Parse(os.Args[1:])

	if err != nil {
		fmt.Printf("error verifying flags, %v. See 'osync --help'.", err)
		os.Exit(1)
	}

	prefixlen = len(config.DataDir)

	if err = config.InitializeOSAuth(); nil != err {
		panic("Initial Openstack Authtication Code Failed With " + err.Error())
	}

	headers[OS_TEMP_URL_KEY] = config.OSAuth.TempURLKey

	c := swift.Connection{
		UserName: config.OSAuth.Username,
		ApiKey:   config.OSAuth.Password,
		AuthUrl:  config.OSAuth.Host,
		Tenant:   config.OSAuth.ProjectName,
	}
	// Authenticate
	err = c.Authenticate()
	if err != nil {
		panic(err)
	}

	// List all the containers
	containers, err := c.ContainerNames(nil)
	fmt.Println(containers)

	worker(c, config.DataDir, 0)
}