_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q177000 | StoragePoolNodeVolumeGetTypeByProject | test | func (c *Cluster) StoragePoolNodeVolumeGetTypeByProject(project, volumeName string, volumeType int, poolID int64) (int64, *api.StorageVolume, error) {
return c.StoragePoolVolumeGetType(project, volumeName, volumeType, poolID, c.nodeID)
} | go | {
"resource": ""
} |
q177001 | StoragePoolVolumeUpdate | test | func (c *Cluster) StoragePoolVolumeUpdate(volumeName string, volumeType int, poolID int64, volumeDescription string, volumeConfig map[string]string) error {
volumeID, _, err := c.StoragePoolNodeVolumeGetType(volumeName, volumeType, poolID)
if err != nil {
return err
}
err = c.Transaction(func(tx *ClusterTx) erro... | go | {
"resource": ""
} |
q177002 | StoragePoolVolumeDelete | test | func (c *Cluster) StoragePoolVolumeDelete(project, volumeName string, volumeType int, poolID int64) error {
volumeID, _, err := c.StoragePoolNodeVolumeGetTypeByProject(project, volumeName, volumeType, poolID)
if err != nil {
return err
}
err = c.Transaction(func(tx *ClusterTx) error {
err := storagePoolVolumeR... | go | {
"resource": ""
} |
q177003 | StoragePoolVolumeRename | test | func (c *Cluster) StoragePoolVolumeRename(project, oldVolumeName string, newVolumeName string, volumeType int, poolID int64) error {
volumeID, _, err := c.StoragePoolNodeVolumeGetTypeByProject(project, oldVolumeName, volumeType, poolID)
if err != nil {
return err
}
err = c.Transaction(func(tx *ClusterTx) error {... | go | {
"resource": ""
} |
q177004 | storagePoolVolumeReplicateIfCeph | test | func storagePoolVolumeReplicateIfCeph(tx *sql.Tx, volumeID int64, project, volumeName string, volumeType int, poolID int64, f func(int64) error) error {
driver, err := storagePoolDriverGet(tx, poolID)
if err != nil {
return err
}
volumeIDs := []int64{volumeID}
// If this is a ceph volume, we want to duplicate t... | go | {
"resource": ""
} |
q177005 | StoragePoolVolumeCreate | test | func (c *Cluster) StoragePoolVolumeCreate(project, volumeName, volumeDescription string, volumeType int, snapshot bool, poolID int64, volumeConfig map[string]string) (int64, error) {
var thisVolumeID int64
err := c.Transaction(func(tx *ClusterTx) error {
nodeIDs := []int{int(c.nodeID)}
driver, err := storagePool... | go | {
"resource": ""
} |
q177006 | StoragePoolVolumeGetTypeID | test | func (c *Cluster) StoragePoolVolumeGetTypeID(project string, volumeName string, volumeType int, poolID, nodeID int64) (int64, error) {
volumeID := int64(-1)
query := `SELECT storage_volumes.id
FROM storage_volumes
JOIN storage_pools ON storage_volumes.storage_pool_id = storage_pools.id
JOIN projects ON storage_volume... | go | {
"resource": ""
} |
q177007 | StoragePoolNodeVolumeGetTypeID | test | func (c *Cluster) StoragePoolNodeVolumeGetTypeID(volumeName string, volumeType int, poolID int64) (int64, error) {
return c.StoragePoolVolumeGetTypeID("default", volumeName, volumeType, poolID, c.nodeID)
} | go | {
"resource": ""
} |
q177008 | StoragePoolVolumeTypeToName | test | func StoragePoolVolumeTypeToName(volumeType int) (string, error) {
switch volumeType {
case StoragePoolVolumeTypeContainer:
return StoragePoolVolumeTypeNameContainer, nil
case StoragePoolVolumeTypeImage:
return StoragePoolVolumeTypeNameImage, nil
case StoragePoolVolumeTypeCustom:
return StoragePoolVolumeTypeN... | go | {
"resource": ""
} |
q177009 | DevicesAdd | test | func DevicesAdd(tx *sql.Tx, w string, cID int64, devices types.Devices) error {
// Prepare the devices entry SQL
str1 := fmt.Sprintf("INSERT INTO %ss_devices (%s_id, name, type) VALUES (?, ?, ?)", w, w)
stmt1, err := tx.Prepare(str1)
if err != nil {
return err
}
defer stmt1.Close()
// Prepare the devices conf... | go | {
"resource": ""
} |
q177010 | Devices | test | func (c *Cluster) Devices(project, qName string, isprofile bool) (types.Devices, error) {
err := c.Transaction(func(tx *ClusterTx) error {
enabled, err := tx.ProjectHasProfiles(project)
if err != nil {
return err
}
if !enabled {
project = "default"
}
return nil
})
if err != nil {
return nil, err
... | go | {
"resource": ""
} |
q177011 | Patches | test | func (n *Node) Patches() ([]string, error) {
inargs := []interface{}{}
outfmt := []interface{}{""}
query := fmt.Sprintf("SELECT name FROM patches")
result, err := queryScan(n.db, query, inargs, outfmt)
if err != nil {
return []string{}, err
}
response := []string{}
for _, r := range result {
response = ap... | go | {
"resource": ""
} |
q177012 | PatchesMarkApplied | test | func (n *Node) PatchesMarkApplied(patch string) error {
stmt := `INSERT INTO patches (name, applied_at) VALUES (?, strftime("%s"));`
_, err := n.db.Exec(stmt, patch)
return err
} | go | {
"resource": ""
} |
q177013 | entityType | test | func entityType(pkg string, entity string) string {
typ := lex.Capital(entity)
if pkg != "db" {
typ = pkg + "." + typ
}
return typ
} | go | {
"resource": ""
} |
q177014 | entityPost | test | func entityPost(entity string) string {
return fmt.Sprintf("%sPost", lex.Capital(lex.Plural(entity)))
} | go | {
"resource": ""
} |
q177015 | stmtCodeVar | test | func stmtCodeVar(entity string, kind string, filters ...string) string {
name := fmt.Sprintf("%s%s", entity, lex.Camel(kind))
if len(filters) > 0 {
name += "By"
name += strings.Join(filters, "And")
}
return name
} | go | {
"resource": ""
} |
q177016 | destFunc | test | func destFunc(slice string, typ string, fields []*Field) string {
f := fmt.Sprintf(`func(i int) []interface{} {
%s = append(%s, %s{})
return []interface{}{
`, slice, slice, typ)
for _, field := range fields {
f += fmt.Sprintf("&%s[i].%s,\n", slice, field.Name)
}
f += ... | go | {
"resource": ""
} |
q177017 | CompareConfigs | test | func CompareConfigs(config1, config2 map[string]string, exclude []string) error {
if exclude == nil {
exclude = []string{}
}
delta := []string{}
for key, value := range config1 {
if shared.StringInSlice(key, exclude) {
continue
}
if config2[key] != value {
delta = append(delta, key)
}
}
for key, ... | go | {
"resource": ""
} |
q177018 | CopyConfig | test | func CopyConfig(config map[string]string) map[string]string {
copy := map[string]string{}
for key, value := range config {
copy[key] = value
}
return copy
} | go | {
"resource": ""
} |
q177019 | NewNotifier | test | func NewNotifier(state *state.State, cert *shared.CertInfo, policy NotifierPolicy) (Notifier, error) {
address, err := node.ClusterAddress(state.Node)
if err != nil {
return nil, errors.Wrap(err, "failed to fetch node address")
}
// Fast-track the case where we're not clustered at all.
if address == "" {
null... | go | {
"resource": ""
} |
q177020 | Events | test | func Events(endpoints *endpoints.Endpoints, cluster *db.Cluster, f func(int64, api.Event)) (task.Func, task.Schedule) {
listeners := map[int64]*lxd.EventListener{}
// Update our pool of event listeners. Since database queries are
// blocking, we spawn the actual logic in a goroutine, to abort
// immediately when w... | go | {
"resource": ""
} |
q177021 | eventsConnect | test | func eventsConnect(address string, cert *shared.CertInfo) (*lxd.EventListener, error) {
client, err := Connect(address, cert, true)
if err != nil {
return nil, err
}
// Set the project to the special wildcard in order to get notified
// about all events across all projects.
client = client.UseProject("*")
re... | go | {
"resource": ""
} |
q177022 | StoragePoolInit | test | func (s *storageDir) StoragePoolInit() error {
err := s.StorageCoreInit()
if err != nil {
return err
}
return nil
} | go | {
"resource": ""
} |
q177023 | getAAProfileContent | test | func getAAProfileContent(c container) string {
profile := strings.TrimLeft(AA_PROFILE_BASE, "\n")
// Apply new features
if aaParserSupports("unix") {
profile += `
### Feature: unix
# Allow receive via unix sockets from anywhere
unix (receive),
# Allow all unix in the container
unix peer=(label=@{profil... | go | {
"resource": ""
} |
q177024 | AALoadProfile | test | func AALoadProfile(c container) error {
state := c.DaemonState()
if !state.OS.AppArmorAdmin {
return nil
}
if err := mkApparmorNamespace(c, AANamespace(c)); err != nil {
return err
}
/* In order to avoid forcing a profile parse (potentially slow) on
* every container start, let's use apparmor's binary pol... | go | {
"resource": ""
} |
q177025 | AADestroy | test | func AADestroy(c container) error {
state := c.DaemonState()
if !state.OS.AppArmorAdmin {
return nil
}
if state.OS.AppArmorStacking && !state.OS.AppArmorStacked {
p := path.Join("/sys/kernel/security/apparmor/policy/namespaces", AANamespace(c))
if err := os.Remove(p); err != nil {
logger.Error("Error remo... | go | {
"resource": ""
} |
q177026 | AAParseProfile | test | func AAParseProfile(c container) error {
state := c.DaemonState()
if !state.OS.AppArmorAvailable {
return nil
}
return runApparmor(APPARMOR_CMD_PARSE, c)
} | go | {
"resource": ""
} |
q177027 | getSystemHandler | test | func getSystemHandler(syslog string, debug bool, format log.Format) log.Handler {
return nil
} | go | {
"resource": ""
} |
q177028 | NotifyUpgradeCompleted | test | func NotifyUpgradeCompleted(state *state.State, cert *shared.CertInfo) error {
notifier, err := NewNotifier(state, cert, NotifyAll)
if err != nil {
return err
}
return notifier(func(client lxd.ContainerServer) error {
info, err := client.GetConnectionInfo()
if err != nil {
return errors.Wrap(err, "failed t... | go | {
"resource": ""
} |
q177029 | KeepUpdated | test | func KeepUpdated(state *state.State) (task.Func, task.Schedule) {
f := func(ctx context.Context) {
ch := make(chan struct{})
go func() {
maybeUpdate(state)
close(ch)
}()
select {
case <-ctx.Done():
case <-ch:
}
}
schedule := task.Every(5 * time.Minute)
return f, schedule
} | go | {
"resource": ""
} |
q177030 | maybeUpdate | test | func maybeUpdate(state *state.State) {
shouldUpdate := false
enabled, err := Enabled(state.Node)
if err != nil {
logger.Errorf("Failed to check clustering is enabled: %v", err)
return
}
if !enabled {
return
}
err = state.Cluster.Transaction(func(tx *db.ClusterTx) error {
outdated, err := tx.NodeIsOutda... | go | {
"resource": ""
} |
q177031 | NewServer | test | func NewServer(apiURL string, apiKey string, agentAuthURL string, agentUsername string, agentPrivateKey string, agentPublicKey string) (*Server, error) {
r := Server{
apiURL: apiURL,
apiKey: apiKey,
lastSyncID: "",
lastChange: time.Time{},
resources: make(map[string]string),... | go | {
"resource": ""
} |
q177032 | StartStatusCheck | test | func (r *Server) StartStatusCheck() {
// Initialize the last changed timestamp
r.hasStatusChanged()
r.statusDone = make(chan int)
go func() {
for {
select {
case <-r.statusDone:
return
case <-time.After(time.Minute):
if r.hasStatusChanged() {
r.flushCache()
}
}
}
}()
} | go | {
"resource": ""
} |
q177033 | SyncProjects | test | func (r *Server) SyncProjects() error {
if r.ProjectsFunc == nil {
return fmt.Errorf("ProjectsFunc isn't configured yet, cannot sync")
}
resources := []rbacResource{}
resourcesMap := map[string]string{}
// Get all projects
projects, err := r.ProjectsFunc()
if err != nil {
return err
}
// Convert to RBAC... | go | {
"resource": ""
} |
q177034 | AddProject | test | func (r *Server) AddProject(id int64, name string) error {
resource := rbacResource{
Name: name,
Identifier: strconv.FormatInt(id, 10),
}
// Update RBAC
err := r.postResources([]rbacResource{resource}, nil, false)
if err != nil {
return err
}
// Update project map
r.resourcesLock.Lock()
r.resourc... | go | {
"resource": ""
} |
q177035 | DeleteProject | test | func (r *Server) DeleteProject(id int64) error {
// Update RBAC
err := r.postResources(nil, []string{strconv.FormatInt(id, 10)}, false)
if err != nil {
return err
}
// Update project map
r.resourcesLock.Lock()
for k, v := range r.resources {
if v == strconv.FormatInt(id, 10) {
delete(r.resources, k)
b... | go | {
"resource": ""
} |
q177036 | RenameProject | test | func (r *Server) RenameProject(id int64, name string) error {
return r.AddProject(id, name)
} | go | {
"resource": ""
} |
q177037 | IsAdmin | test | func (r *Server) IsAdmin(username string) bool {
r.permissionsLock.Lock()
defer r.permissionsLock.Unlock()
// Check whether the permissions are cached
_, cached := r.permissions[username]
if !cached {
r.syncPermissions(username)
}
return shared.StringInSlice("admin", r.permissions[username][""])
} | go | {
"resource": ""
} |
q177038 | HasPermission | test | func (r *Server) HasPermission(username, project, permission string) bool {
r.permissionsLock.Lock()
defer r.permissionsLock.Unlock()
// Check whether the permissions are cached
_, cached := r.permissions[username]
if !cached {
r.syncPermissions(username)
}
r.resourcesLock.Lock()
permissions := r.permissio... | go | {
"resource": ""
} |
q177039 | rsyncSend | test | func rsyncSend(conn *websocket.Conn, path string, rsyncArgs string) error {
cmd, dataSocket, stderr, err := rsyncSendSetup(path, rsyncArgs)
if err != nil {
return err
}
if dataSocket != nil {
defer dataSocket.Close()
}
readDone, writeDone := shared.WebsocketMirror(conn, dataSocket, io.ReadCloser(dataSocket)... | go | {
"resource": ""
} |
q177040 | rsyncSendSetup | test | func rsyncSendSetup(path string, rsyncArgs string) (*exec.Cmd, net.Conn, io.ReadCloser, error) {
auds := fmt.Sprintf("@lxd-p2c/%s", uuid.NewRandom().String())
if len(auds) > shared.ABSTRACT_UNIX_SOCK_LEN-1 {
auds = auds[:shared.ABSTRACT_UNIX_SOCK_LEN-1]
}
l, err := net.Listen("unix", auds)
if err != nil {
ret... | go | {
"resource": ""
} |
q177041 | tlsClientConfig | test | func tlsClientConfig(info *shared.CertInfo) (*tls.Config, error) {
keypair := info.KeyPair()
ca := info.CA()
config := shared.InitTLSConfig()
config.Certificates = []tls.Certificate{keypair}
config.RootCAs = x509.NewCertPool()
if ca != nil {
config.RootCAs.AddCert(ca)
}
// Since the same cluster keypair is us... | go | {
"resource": ""
} |
q177042 | tlsCheckCert | test | func tlsCheckCert(r *http.Request, info *shared.CertInfo) bool {
cert, err := x509.ParseCertificate(info.KeyPair().Certificate[0])
if err != nil {
// Since we have already loaded this certificate, typically
// using LoadX509KeyPair, an error should never happen, but
// check for good measure.
panic(fmt.Sprint... | go | {
"resource": ""
} |
q177043 | internalClusterContainerMovedPost | test | func internalClusterContainerMovedPost(d *Daemon, r *http.Request) Response {
project := projectParam(r)
containerName := mux.Vars(r)["name"]
err := containerPostCreateContainerMountPoint(d, project, containerName)
if err != nil {
return SmartError(err)
}
return EmptySyncResponse
} | go | {
"resource": ""
} |
q177044 | containerPostCreateContainerMountPoint | test | func containerPostCreateContainerMountPoint(d *Daemon, project, containerName string) error {
c, err := containerLoadByProjectAndName(d.State(), project, containerName)
if err != nil {
return errors.Wrap(err, "Failed to load moved container on target node")
}
poolName, err := c.StoragePool()
if err != nil {
re... | go | {
"resource": ""
} |
q177045 | Contains | test | func (list Devices) Contains(k string, d Device) bool {
// If it didn't exist, it's different
if list[k] == nil {
return false
}
old := list[k]
return deviceEquals(old, d)
} | go | {
"resource": ""
} |
q177046 | Update | test | func (list Devices) Update(newlist Devices) (map[string]Device, map[string]Device, map[string]Device, []string) {
rmlist := map[string]Device{}
addlist := map[string]Device{}
updatelist := map[string]Device{}
for key, d := range list {
if !newlist.Contains(key, d) {
rmlist[key] = d
}
}
for key, d := rang... | go | {
"resource": ""
} |
q177047 | DeviceNames | test | func (list Devices) DeviceNames() []string {
sortable := sortableDevices{}
for k, d := range list {
sortable = append(sortable, namedDevice{k, d})
}
sort.Sort(sortable)
return sortable.Names()
} | go | {
"resource": ""
} |
q177048 | Infof | test | func Infof(format string, args ...interface{}) {
if Log != nil {
Log.Info(fmt.Sprintf(format, args...))
}
} | go | {
"resource": ""
} |
q177049 | Debugf | test | func Debugf(format string, args ...interface{}) {
if Log != nil {
Log.Debug(fmt.Sprintf(format, args...))
}
} | go | {
"resource": ""
} |
q177050 | Warnf | test | func Warnf(format string, args ...interface{}) {
if Log != nil {
Log.Warn(fmt.Sprintf(format, args...))
}
} | go | {
"resource": ""
} |
q177051 | Errorf | test | func Errorf(format string, args ...interface{}) {
if Log != nil {
Log.Error(fmt.Sprintf(format, args...))
}
} | go | {
"resource": ""
} |
q177052 | Critf | test | func Critf(format string, args ...interface{}) {
if Log != nil {
Log.Crit(fmt.Sprintf(format, args...))
}
} | go | {
"resource": ""
} |
q177053 | eventForward | test | func eventForward(id int64, event api.Event) {
if event.Type == "logging" {
// Parse the message
logEntry := api.EventLogging{}
err := json.Unmarshal(event.Metadata, &logEntry)
if err != nil {
return
}
if !debug && logEntry.Level == "dbug" {
return
}
if !debug && !verbose && logEntry.Level == "... | go | {
"resource": ""
} |
q177054 | StorageProgressReader | test | func StorageProgressReader(op *operation, key string, description string) func(io.ReadCloser) io.ReadCloser {
return func(reader io.ReadCloser) io.ReadCloser {
if op == nil {
return reader
}
progress := func(progressInt int64, speedInt int64) {
progressWrapperRender(op, key, description, progressInt, spee... | go | {
"resource": ""
} |
q177055 | StorageProgressWriter | test | func StorageProgressWriter(op *operation, key string, description string) func(io.WriteCloser) io.WriteCloser {
return func(writer io.WriteCloser) io.WriteCloser {
if op == nil {
return writer
}
progress := func(progressInt int64, speedInt int64) {
progressWrapperRender(op, key, description, progressInt, ... | go | {
"resource": ""
} |
q177056 | GetLSBRelease | test | func GetLSBRelease() (map[string]string, error) {
osRelease, err := getLSBRelease("/etc/os-release")
if os.IsNotExist(err) {
return getLSBRelease("/usr/lib/os-release")
}
return osRelease, err
} | go | {
"resource": ""
} |
q177057 | Reset | test | func Reset(path string, imports []string) error {
content := fmt.Sprintf(`package %s
// The code below was generated by %s - DO NOT EDIT!
import (
`, os.Getenv("GOPACKAGE"), os.Args[0])
for _, uri := range imports {
content += fmt.Sprintf("\t%q\n", uri)
}
content += ")\n\n"
// FIXME: we should only import w... | go | {
"resource": ""
} |
q177058 | Append | test | func Append(path string, snippet Snippet) error {
buffer := newBuffer()
buffer.N()
err := snippet.Generate(buffer)
if err != nil {
return errors.Wrap(err, "Generate code snippet")
}
var file *os.File
if path == "-" {
file = os.Stdout
} else {
file, err = os.OpenFile(path, os.O_APPEND|os.O_WRONLY, 0644)... | go | {
"resource": ""
} |
q177059 | ContainerToArgs | test | func ContainerToArgs(container *Container) ContainerArgs {
args := ContainerArgs{
ID: container.ID,
Project: container.Project,
Name: container.Name,
Node: container.Node,
Ctype: ContainerType(container.Type),
Architecture: container.Architecture,
Ephemeral: conta... | go | {
"resource": ""
} |
q177060 | ContainerNames | test | func (c *ClusterTx) ContainerNames(project string) ([]string, error) {
stmt := `
SELECT containers.name FROM containers
JOIN projects ON projects.id = containers.project_id
WHERE projects.name = ? AND containers.type = ?
`
return query.SelectStrings(c.tx, stmt, project, CTypeRegular)
} | go | {
"resource": ""
} |
q177061 | ContainerNodeAddress | test | func (c *ClusterTx) ContainerNodeAddress(project string, name string) (string, error) {
stmt := `
SELECT nodes.id, nodes.address
FROM nodes
JOIN containers ON containers.node_id = nodes.id
JOIN projects ON projects.id = containers.project_id
WHERE projects.name = ? AND containers.name = ?
`
var address string
... | go | {
"resource": ""
} |
q177062 | ContainersListByNodeAddress | test | func (c *ClusterTx) ContainersListByNodeAddress(project string) (map[string][]string, error) {
offlineThreshold, err := c.NodeOfflineThreshold()
if err != nil {
return nil, err
}
stmt := `
SELECT containers.name, nodes.id, nodes.address, nodes.heartbeat
FROM containers
JOIN nodes ON nodes.id = containers.nod... | go | {
"resource": ""
} |
q177063 | ContainerListExpanded | test | func (c *ClusterTx) ContainerListExpanded() ([]Container, error) {
containers, err := c.ContainerList(ContainerFilter{})
if err != nil {
return nil, errors.Wrap(err, "Load containers")
}
profiles, err := c.ProfileList(ProfileFilter{})
if err != nil {
return nil, errors.Wrap(err, "Load profiles")
}
// Index... | go | {
"resource": ""
} |
q177064 | ContainersByNodeName | test | func (c *ClusterTx) ContainersByNodeName(project string) (map[string]string, error) {
stmt := `
SELECT containers.name, nodes.name
FROM containers
JOIN nodes ON nodes.id = containers.node_id
JOIN projects ON projects.id = containers.project_id
WHERE containers.type=?
AND projects.name = ?
`
rows, err := c... | go | {
"resource": ""
} |
q177065 | SnapshotIDsAndNames | test | func (c *ClusterTx) SnapshotIDsAndNames(name string) (map[int]string, error) {
prefix := name + shared.SnapshotDelimiter
length := len(prefix)
objects := make([]struct {
ID int
Name string
}, 0)
dest := func(i int) []interface{} {
objects = append(objects, struct {
ID int
Name string
}{})
retur... | go | {
"resource": ""
} |
q177066 | ContainerNodeList | test | func (c *ClusterTx) ContainerNodeList() ([]Container, error) {
node, err := c.NodeName()
if err != nil {
return nil, errors.Wrap(err, "Local node name")
}
filter := ContainerFilter{
Node: node,
Type: int(CTypeRegular),
}
return c.ContainerList(filter)
} | go | {
"resource": ""
} |
q177067 | ContainerNodeProjectList | test | func (c *ClusterTx) ContainerNodeProjectList(project string) ([]Container, error) {
node, err := c.NodeName()
if err != nil {
return nil, errors.Wrap(err, "Local node name")
}
filter := ContainerFilter{
Project: project,
Node: node,
Type: int(CTypeRegular),
}
return c.ContainerList(filter)
} | go | {
"resource": ""
} |
q177068 | ContainerRemove | test | func (c *Cluster) ContainerRemove(project, name string) error {
return c.Transaction(func(tx *ClusterTx) error {
return tx.ContainerDelete(project, name)
})
} | go | {
"resource": ""
} |
q177069 | ContainerProjectAndName | test | func (c *Cluster) ContainerProjectAndName(id int) (string, string, error) {
q := `
SELECT projects.name, containers.name
FROM containers
JOIN projects ON projects.id = containers.project_id
WHERE containers.id=?
`
project := ""
name := ""
arg1 := []interface{}{id}
arg2 := []interface{}{&project, &name}
err :=... | go | {
"resource": ""
} |
q177070 | ContainerConfigClear | test | func ContainerConfigClear(tx *sql.Tx, id int) error {
_, err := tx.Exec("DELETE FROM containers_config WHERE container_id=?", id)
if err != nil {
return err
}
_, err = tx.Exec("DELETE FROM containers_profiles WHERE container_id=?", id)
if err != nil {
return err
}
_, err = tx.Exec(`DELETE FROM containers_dev... | go | {
"resource": ""
} |
q177071 | ContainerConfigGet | test | func (c *Cluster) ContainerConfigGet(id int, key string) (string, error) {
q := "SELECT value FROM containers_config WHERE container_id=? AND key=?"
value := ""
arg1 := []interface{}{id, key}
arg2 := []interface{}{&value}
err := dbQueryRowScan(c.db, q, arg1, arg2)
if err == sql.ErrNoRows {
return "", ErrNoSuchO... | go | {
"resource": ""
} |
q177072 | ContainerConfigRemove | test | func (c *Cluster) ContainerConfigRemove(id int, key string) error {
err := exec(c.db, "DELETE FROM containers_config WHERE key=? AND container_id=?", key, id)
return err
} | go | {
"resource": ""
} |
q177073 | ContainerSetStateful | test | func (c *Cluster) ContainerSetStateful(id int, stateful bool) error {
statefulInt := 0
if stateful {
statefulInt = 1
}
err := exec(c.db, "UPDATE containers SET stateful=? WHERE id=?", statefulInt, id)
return err
} | go | {
"resource": ""
} |
q177074 | ContainerProfilesInsert | test | func ContainerProfilesInsert(tx *sql.Tx, id int, project string, profiles []string) error {
enabled, err := projectHasProfiles(tx, project)
if err != nil {
return errors.Wrap(err, "Check if project has profiles")
}
if !enabled {
project = "default"
}
applyOrder := 1
str := `
INSERT INTO containers_profiles ... | go | {
"resource": ""
} |
q177075 | ContainerProfiles | test | func (c *Cluster) ContainerProfiles(id int) ([]string, error) {
var name string
var profiles []string
query := `
SELECT name FROM containers_profiles
JOIN profiles ON containers_profiles.profile_id=profiles.id
WHERE container_id=?
ORDER BY containers_profiles.apply_order`
inargs := []inte... | go | {
"resource": ""
} |
q177076 | ContainerConfig | test | func (c *Cluster) ContainerConfig(id int) (map[string]string, error) {
var key, value string
q := `SELECT key, value FROM containers_config WHERE container_id=?`
inargs := []interface{}{id}
outfmt := []interface{}{key, value}
// Results is already a slice here, not db Rows anymore.
results, err := queryScan(c.d... | go | {
"resource": ""
} |
q177077 | ContainerSetState | test | func (c *Cluster) ContainerSetState(id int, state string) error {
err := c.Transaction(func(tx *ClusterTx) error {
// Set the new value
str := fmt.Sprintf("INSERT OR REPLACE INTO containers_config (container_id, key, value) VALUES (?, 'volatile.last_state.power', ?)")
stmt, err := tx.tx.Prepare(str)
if err != ... | go | {
"resource": ""
} |
q177078 | ContainerUpdate | test | func ContainerUpdate(tx *sql.Tx, id int, description string, architecture int, ephemeral bool,
expiryDate time.Time) error {
str := fmt.Sprintf("UPDATE containers SET description=?, architecture=?, ephemeral=?, expiry_date=? WHERE id=?")
stmt, err := tx.Prepare(str)
if err != nil {
return err
}
defer stmt.Close... | go | {
"resource": ""
} |
q177079 | ContainerLastUsedUpdate | test | func (c *Cluster) ContainerLastUsedUpdate(id int, date time.Time) error {
stmt := `UPDATE containers SET last_use_date=? WHERE id=?`
err := exec(c.db, stmt, date, id)
return err
} | go | {
"resource": ""
} |
q177080 | ContainerGetSnapshots | test | func (c *Cluster) ContainerGetSnapshots(project, name string) ([]string, error) {
result := []string{}
regexp := name + shared.SnapshotDelimiter
length := len(regexp)
q := `
SELECT containers.name
FROM containers
JOIN projects ON projects.id = containers.project_id
WHERE projects.name=? AND containers.type=? A... | go | {
"resource": ""
} |
q177081 | ContainerGetSnapshotsFull | test | func (c *ClusterTx) ContainerGetSnapshotsFull(project string, name string) ([]Container, error) {
filter := ContainerFilter{
Parent: name,
Project: project,
Type: int(CTypeSnapshot),
}
return c.ContainerList(filter)
} | go | {
"resource": ""
} |
q177082 | ContainerNextSnapshot | test | func (c *Cluster) ContainerNextSnapshot(project string, name string, pattern string) int {
base := name + shared.SnapshotDelimiter
length := len(base)
q := `
SELECT containers.name
FROM containers
JOIN projects ON projects.id = containers.project_id
WHERE projects.name=? AND containers.type=? AND SUBSTR(contain... | go | {
"resource": ""
} |
q177083 | ContainerPool | test | func (c *ClusterTx) ContainerPool(project, containerName string) (string, error) {
// Get container storage volume. Since container names are globally
// unique, and their storage volumes carry the same name, their storage
// volumes are unique too.
poolName := ""
query := `
SELECT storage_pools.name FROM storage_... | go | {
"resource": ""
} |
q177084 | ContainerGetBackup | test | func (c *Cluster) ContainerGetBackup(project, name string) (ContainerBackupArgs, error) {
args := ContainerBackupArgs{}
args.Name = name
containerOnlyInt := -1
optimizedStorageInt := -1
q := `
SELECT containers_backups.id, containers_backups.container_id,
containers_backups.creation_date, containers_backup... | go | {
"resource": ""
} |
q177085 | ContainerGetBackups | test | func (c *Cluster) ContainerGetBackups(project, name string) ([]string, error) {
var result []string
q := `SELECT containers_backups.name FROM containers_backups
JOIN containers ON containers_backups.container_id=containers.id
JOIN projects ON projects.id=containers.project_id
WHERE projects.name=? AND containers.nam... | go | {
"resource": ""
} |
q177086 | ContainerBackupCreate | test | func (c *Cluster) ContainerBackupCreate(args ContainerBackupArgs) error {
_, err := c.ContainerBackupID(args.Name)
if err == nil {
return ErrAlreadyDefined
}
err = c.Transaction(func(tx *ClusterTx) error {
containerOnlyInt := 0
if args.ContainerOnly {
containerOnlyInt = 1
}
optimizedStorageInt := 0
... | go | {
"resource": ""
} |
q177087 | ContainerBackupRemove | test | func (c *Cluster) ContainerBackupRemove(name string) error {
id, err := c.ContainerBackupID(name)
if err != nil {
return err
}
err = exec(c.db, "DELETE FROM containers_backups WHERE id=?", id)
if err != nil {
return err
}
return nil
} | go | {
"resource": ""
} |
q177088 | ContainerBackupRename | test | func (c *Cluster) ContainerBackupRename(oldName, newName string) error {
err := c.Transaction(func(tx *ClusterTx) error {
str := fmt.Sprintf("UPDATE containers_backups SET name = ? WHERE name = ?")
stmt, err := tx.tx.Prepare(str)
if err != nil {
return err
}
defer stmt.Close()
logger.Debug(
"Calling... | go | {
"resource": ""
} |
q177089 | ContainerBackupsGetExpired | test | func (c *Cluster) ContainerBackupsGetExpired() ([]string, error) {
var result []string
var name string
var expiryDate string
q := `SELECT containers_backups.name, containers_backups.expiry_date FROM containers_backups`
outfmt := []interface{}{name, expiryDate}
dbResults, err := queryScan(c.db, q, nil, outfmt)
i... | go | {
"resource": ""
} |
q177090 | DefaultOS | test | func DefaultOS() *OS {
newOS := &OS{
VarDir: shared.VarPath(),
CacheDir: shared.CachePath(),
LogDir: shared.LogPath(),
}
newOS.InotifyWatch.Fd = -1
newOS.InotifyWatch.Targets = make(map[string]*InotifyTargetInfo)
return newOS
} | go | {
"resource": ""
} |
q177091 | Init | test | func (s *OS) Init() error {
err := s.initDirs()
if err != nil {
return err
}
s.Architectures, err = util.GetArchitectures()
if err != nil {
return err
}
s.LxcPath = filepath.Join(s.VarDir, "containers")
s.BackingFS, err = util.FilesystemDetect(s.LxcPath)
if err != nil {
logger.Error("Error detecting b... | go | {
"resource": ""
} |
q177092 | GetWebsocket | test | func (op *operation) GetWebsocket(secret string) (*websocket.Conn, error) {
return op.r.GetOperationWebsocket(op.ID, secret)
} | go | {
"resource": ""
} |
q177093 | Refresh | test | func (op *operation) Refresh() error {
// Get the current version of the operation
newOp, _, err := op.r.GetOperation(op.ID)
if err != nil {
return err
}
// Update the operation struct
op.Operation = *newOp
return nil
} | go | {
"resource": ""
} |
q177094 | CancelTarget | test | func (op *remoteOperation) CancelTarget() error {
if op.targetOp == nil {
return fmt.Errorf("No associated target operation")
}
return op.targetOp.Cancel()
} | go | {
"resource": ""
} |
q177095 | GetTarget | test | func (op *remoteOperation) GetTarget() (*api.Operation, error) {
if op.targetOp == nil {
return nil, fmt.Errorf("No associated target operation")
}
opAPI := op.targetOp.Get()
return &opAPI, nil
} | go | {
"resource": ""
} |
q177096 | up | test | func (e *Endpoints) up(config *Config) error {
e.mu.Lock()
defer e.mu.Unlock()
e.servers = map[kind]*http.Server{
devlxd: config.DevLxdServer,
local: config.RestServer,
network: config.RestServer,
cluster: config.RestServer,
pprof: pprofCreateServer(),
}
e.cert = config.Cert
e.inherited = map[kind... | go | {
"resource": ""
} |
q177097 | Down | test | func (e *Endpoints) Down() error {
e.mu.Lock()
defer e.mu.Unlock()
if e.listeners[network] != nil || e.listeners[local] != nil {
logger.Infof("Stopping REST API handler:")
err := e.closeListener(network)
if err != nil {
return err
}
err = e.closeListener(local)
if err != nil {
return err
}
}
... | go | {
"resource": ""
} |
q177098 | serveHTTP | test | func (e *Endpoints) serveHTTP(kind kind) {
listener := e.listeners[kind]
if listener == nil {
return
}
ctx := log.Ctx{"socket": listener.Addr()}
if e.inherited[kind] {
ctx["inherited"] = true
}
message := fmt.Sprintf(" - binding %s", descriptions[kind])
logger.Info(message, ctx)
server := e.servers[kin... | go | {
"resource": ""
} |
q177099 | closeListener | test | func (e *Endpoints) closeListener(kind kind) error {
listener := e.listeners[kind]
if listener == nil {
return nil
}
delete(e.listeners, kind)
logger.Info(" - closing socket", log.Ctx{"socket": listener.Addr()})
return listener.Close()
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.