Ejemplo n.º 1
0
func (t *rpcType) ConfigureSubs(conn *srpc.Conn,
	request dominator.ConfigureSubsRequest,
	reply *dominator.ConfigureSubsResponse) error {
	if conn.Username() == "" {
		t.logger.Printf("ConfigureSubs()\n")
	} else {
		t.logger.Printf("ConfigureSubs(): by %s\n", conn.Username())
	}
	return t.herd.ConfigureSubs(sub.Configuration(request))
}
Ejemplo n.º 2
0
func (t *rpcType) EnableUpdates(conn *srpc.Conn,
	request dominator.EnableUpdatesRequest,
	reply *dominator.EnableUpdatesResponse) error {
	if conn.Username() == "" {
		t.logger.Printf("EnableUpdates(%s)\n", request.Reason)
	} else {
		t.logger.Printf("EnableUpdates(%s): by %s\n",
			request.Reason, conn.Username())
	}
	return t.herd.EnableUpdates()
}
Ejemplo n.º 3
0
func (t *rpcType) ClearSafetyShutoff(conn *srpc.Conn,
	request dominator.ClearSafetyShutoffRequest,
	reply *dominator.ClearSafetyShutoffResponse) error {
	if conn.Username() == "" {
		t.logger.Printf("ClearSafetyShutoff(%s)\n", request.Hostname)
	} else {
		t.logger.Printf("ClearSafetyShutoff(%s): by %s\n",
			request.Hostname, conn.Username())
	}
	return t.herd.ClearSafetyShutoff(request.Hostname)
}
Ejemplo n.º 4
0
func (t *srpcType) DeleteUnreferencedObjects(conn *srpc.Conn,
	request imageserver.DeleteUnreferencedObjectsRequest,
	reply *imageserver.DeleteUnreferencedObjectsResponse) error {
	username := conn.Username()
	if username == "" {
		t.logger.Printf("DeleteUnreferencedObjects(%d%%, %s)\n",
			request.Percentage, format.FormatBytes(request.Bytes))
	} else {
		t.logger.Printf("DeleteUnreferencedObjects(%d%%, %s) by %s\n",
			request.Percentage, format.FormatBytes(request.Bytes), username)
	}
	return t.imageDataBase.DeleteUnreferencedObjects(request.Percentage,
		request.Bytes)
}
Ejemplo n.º 5
0
func (t *srpcType) MakeDirectory(conn *srpc.Conn,
	request imageserver.MakeDirectoryRequest,
	reply *imageserver.MakeDirectoryResponse) error {
	username := conn.Username()
	if err := t.checkMutability(); err != nil {
		return err
	}
	if username == "" {
		t.logger.Printf("MakeDirectory(%s)\n", request.DirectoryName)
	} else {
		t.logger.Printf("MakeDirectory(%s) by %s\n",
			request.DirectoryName, username)
	}
	return t.imageDataBase.MakeDirectory(request.DirectoryName, username)
}
Ejemplo n.º 6
0
func (t *srpcType) ChownDirectory(conn *srpc.Conn,
	request imageserver.ChangeOwnerRequest,
	reply *imageserver.ChangeOwnerResponse) error {
	username := conn.Username()
	if username == "" {
		return errors.New("no username: unauthenticated connection")
	}
	if request.OwnerGroup != "" {
		if _, err := user.LookupGroup(request.OwnerGroup); err != nil {
			return err
		}
	}
	t.logger.Printf("ChownDirectory(%s) to: \"%s\" by %s\n",
		request.DirectoryName, request.OwnerGroup, username)
	return t.imageDataBase.ChownDirectory(request.DirectoryName,
		request.OwnerGroup)
}
Ejemplo n.º 7
0
func (t *srpcType) DeleteImage(conn *srpc.Conn,
	request imageserver.DeleteImageRequest,
	reply *imageserver.DeleteImageResponse) error {
	username := conn.Username()
	if err := t.checkMutability(); err != nil {
		return err
	}
	if !t.imageDataBase.CheckImage(request.ImageName) {
		return errors.New("image does not exist")
	}
	if username == "" {
		t.logger.Printf("DeleteImage(%s)\n", request.ImageName)
	} else {
		t.logger.Printf("DeleteImage(%s) by %s\n", request.ImageName, username)
	}
	return t.imageDataBase.DeleteImage(request.ImageName, &username)
}