Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "dhcp-sync", Short: "dhcp-sync command", Long: `dhcp-sync tool is a tool populating the dhcpd.conf file from the PowerVS network and restart the dhcpd service.`, GroupID: "dhcp", PreRunE: func(cmd *cobra.Command, args []string) error { if pkg.Options.WorkspaceID == "" { return fmt.Errorf("--workspace-id is required") } return nil }, RunE: func(cmd *cobra.Command, args []string) error { go doEvery(2*time.Minute, syncDHCPD) watcher, err := fsnotify.NewWatcher() if err != nil { klog.Fatalf("cannot create a new fsNotify watcher: %v", err) } defer watcher.Close() done := make(chan bool) go func() { for { select { case event, ok := <-watcher.Events: if !ok { return } klog.V(2).Infof("received an fsWatcher event: %v", event) if event.Op&fsnotify.Write == fsnotify.Write { klog.V(2).Infof("%s has been modified, proceeding to restart dhcpd service", event.Name) exitcode, out, err := utils.RunCMD("systemctl", "restart", "dhcpd") if exitcode != 0 { klog.Errorf("failed to restart the dhcpd service, exitcode: %d, stdout: %s, err: %s", exitcode, out, err) } } case err, ok := <-watcher.Errors: if !ok { return } klog.Errorf("received an fsWatcher error: %v", err) } } }() err = watcher.Add(file) if err != nil { klog.Fatalf("cannot sync DHCP server: %v", err) } <-done return nil }, }
Functions ¶
This section is empty.
Types ¶
type InterfaceMTUOption ¶ added in v0.1.4
type InterfaceMTUOption string
func (InterfaceMTUOption) IndentedString ¶ added in v0.1.4
func (io InterfaceMTUOption) IndentedString(prefix string) string
IndentedString implements the method of the same name in the Statement interface
type RoutersOption ¶
func (RoutersOption) IndentedString ¶
func (ro RoutersOption) IndentedString(prefix string) string
IndentedString implements the method of the same name in the Statement interface
Click to show internal directories.
Click to hide internal directories.