示例#1
0
文件: app.go 项目: gaurav36/heketi
	"github.com/heketi/heketi/utils"
	"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
}

func NewApp() *App {
	app := &App{}

	// Setup asynchronous manager
	app.asyncManager = rest.NewAsyncHttpManager(ASYNC_ROUTE)

	// Setup BoltDB database
示例#2
0
文件: sshexec.go 项目: pkoro/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)
	godbc.Require(DEFAULT_MAX_CONNECTIONS > 1)

	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
示例#3
0
// 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)
示例#4
0
文件: asynchttp.go 项目: pkoro/heketi
// See the License for the specific language governing permissions and
// limitations under the License.
//
package rest

import (
	"github.com/gorilla/mux"
	"github.com/heketi/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