コード例 #1
0
ファイル: app.go プロジェクト: vbellur/heketi
	"io"
	"net/http"
	"time"
)

const (
	ASYNC_ROUTE           = "/queue"
	BOLTDB_BUCKET_CLUSTER = "CLUSTER"
	BOLTDB_BUCKET_NODE    = "NODE"
	BOLTDB_BUCKET_VOLUME  = "VOLUME"
	BOLTDB_BUCKET_DEVICE  = "DEVICE"
	BOLTDB_BUCKET_BRICK   = "BRICK"
)

var (
	logger     = utils.NewLogger("[heketi]", utils.LEVEL_DEBUG)
	dbfilename = "heketi.db"
)

type App struct {
	asyncManager *rest.AsyncHttpManager
	db           *bolt.DB
	executor     executors.Executor
	allocator    Allocator
	conf         *GlusterFSConfig

	// For testing only.  Keep access to the object
	// not through the interface
	xo *mockexec.MockExecutor
}
コード例 #2
0
ファイル: heketi_test.go プロジェクト: vbellur/heketi
// These are the settings for the vagrant file
const (

	// The heketi server must be running on the host
	heketiUrl = "http://127.0.0.1:8080"

	// VMs
	DISKS = 24
	NODES = 30
)

var (
	// Heketi client
	heketi = client.NewClient(heketiUrl, "admin", "adminkey")
	logger = utils.NewLogger("[test]", utils.LEVEL_DEBUG)
)

func getdisks() []string {

	diskletters := make([]string, DISKS)
	for index, i := 0, []byte("b")[0]; index < DISKS; index, i = index+1, i+1 {
		diskletters[index] = "/dev/vd" + string(i)
	}

	return diskletters
}

func getnodes() []string {
	nodelist := make([]string, NODES)
コード例 #3
0
ファイル: sshexec.go プロジェクト: vbellur/heketi
	throttlemap     map[string]chan bool
	lock            sync.Mutex
	exec            *ssh.SshExec
	config          *SshConfig
}

type SshConfig struct {
	PrivateKeyFile string `json:"keyfile"`
	User           string `json:"user"`

	// Experimental Settings
	RebalanceOnExpansion bool `json:"rebalance_on_expansion"`
}

var (
	logger           = utils.NewLogger("[sshexec]", utils.LEVEL_DEBUG)
	ErrSshPrivateKey = errors.New("Unable to read private key file")
)

func NewSshExecutor(config *SshConfig) *SshExecutor {
	godbc.Require(config != nil)

	s := &SshExecutor{}
	s.throttlemap = make(map[string]chan bool)

	// Set configuration
	if config.PrivateKeyFile == "" {
		s.private_keyfile = os.Getenv("HOME") + "/.ssh/id_rsa"
	} else {
		s.private_keyfile = config.PrivateKeyFile
	}
コード例 #4
0
ファイル: app4.go プロジェクト: lpabon/go-slides
import (
	"encoding/json"
	"github.com/gorilla/mux"
	"github.com/heketi/rest" // HL
	"github.com/heketi/utils"
	"log"
	"net/http"
	"sync"
	"time"
)

// Log Var OMIT
var (
	// Unmarshal using github.com/heketi/utils
	logger = utils.NewLogger("[app]", utils.LEVEL_DEBUG)
)

// end Log Var OMIT

// App struct OMIT
type App struct {
	keys         map[string]string
	lock         sync.Mutex
	asyncManager *rest.AsyncHttpManager // HL
}

// end App struct OMIT

type AppValue struct {
	Value string `json:"value"`
コード例 #5
0
ファイル: asynchttp.go プロジェクト: heketi/rest
// See the License for the specific language governing permissions and
// limitations under the License.

package rest

import (
	"github.com/gorilla/mux"
	"github.com/heketi/utils"
	"github.com/lpabon/godbc"
	"net/http"
	"sync"
	"time"
)

var (
	logger = utils.NewLogger("[asynchttp]", utils.LEVEL_INFO)
)

// Contains information about the asynchronous operation
type AsyncHttpHandler struct {
	err          error
	completed    bool
	manager      *AsyncHttpManager
	location, id string
}

// Manager of asynchronous operations
type AsyncHttpManager struct {
	lock     sync.RWMutex
	route    string
	handlers map[string]*AsyncHttpHandler