github.com/mheon/docker@v0.11.2-0.20150922122814-44f47903a831/daemon/daemon_windows.go (about)

     1  package daemon
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"syscall"
     7  
     8  	"github.com/docker/docker/daemon/graphdriver"
     9  	// register the windows graph driver
    10  	_ "github.com/docker/docker/daemon/graphdriver/windows"
    11  	"github.com/docker/docker/pkg/parsers"
    12  	"github.com/docker/docker/runconfig"
    13  	"github.com/docker/libnetwork"
    14  )
    15  
    16  const (
    17  	defaultVirtualSwitch = "Virtual Switch"
    18  	platformSupported    = true
    19  )
    20  
    21  func parseSecurityOpt(container *Container, config *runconfig.HostConfig) error {
    22  	return nil
    23  }
    24  
    25  func setupInitLayer(initLayer string) error {
    26  	return nil
    27  }
    28  
    29  func checkKernel() error {
    30  	return nil
    31  }
    32  
    33  // adaptContainerSettings is called during container creation to modify any
    34  // settings necessary in the HostConfig structure.
    35  func (daemon *Daemon) adaptContainerSettings(hostConfig *runconfig.HostConfig, adjustCPUShares bool) {
    36  }
    37  
    38  // verifyPlatformContainerSettings performs platform-specific validation of the
    39  // hostconfig and config structures.
    40  func verifyPlatformContainerSettings(daemon *Daemon, hostConfig *runconfig.HostConfig, config *runconfig.Config) ([]string, error) {
    41  	return nil, nil
    42  }
    43  
    44  // checkConfigOptions checks for mutually incompatible config options
    45  func checkConfigOptions(config *Config) error {
    46  	return nil
    47  }
    48  
    49  // checkSystem validates platform-specific requirements
    50  func checkSystem() error {
    51  	var dwVersion uint32
    52  
    53  	// TODO Windows. May need at some point to ensure have elevation and
    54  	// possibly LocalSystem.
    55  
    56  	// Validate the OS version. Note that docker.exe must be manifested for this
    57  	// call to return the correct version.
    58  	dwVersion, err := syscall.GetVersion()
    59  	if err != nil {
    60  		return fmt.Errorf("Failed to call GetVersion()")
    61  	}
    62  	if int(dwVersion&0xFF) < 10 {
    63  		return fmt.Errorf("This version of Windows does not support the docker daemon")
    64  	}
    65  
    66  	return nil
    67  }
    68  
    69  // configureKernelSecuritySupport configures and validate security support for the kernel
    70  func configureKernelSecuritySupport(config *Config, driverName string) error {
    71  	return nil
    72  }
    73  
    74  func migrateIfDownlevel(driver graphdriver.Driver, root string) error {
    75  	return nil
    76  }
    77  
    78  func configureSysInit(config *Config) (string, error) {
    79  	// TODO Windows.
    80  	return os.Getenv("TEMP"), nil
    81  }
    82  
    83  func isBridgeNetworkDisabled(config *Config) bool {
    84  	return false
    85  }
    86  
    87  func initNetworkController(config *Config) (libnetwork.NetworkController, error) {
    88  	// Set the name of the virtual switch if not specified by -b on daemon start
    89  	if config.Bridge.VirtualSwitchName == "" {
    90  		config.Bridge.VirtualSwitchName = defaultVirtualSwitch
    91  	}
    92  	return nil, nil
    93  }
    94  
    95  // registerLinks sets up links between containers and writes the
    96  // configuration out for persistence.
    97  func (daemon *Daemon) registerLinks(container *Container, hostConfig *runconfig.HostConfig) error {
    98  	// TODO Windows. Factored out for network modes. There may be more
    99  	// refactoring required here.
   100  
   101  	if hostConfig == nil || hostConfig.Links == nil {
   102  		return nil
   103  	}
   104  
   105  	for _, l := range hostConfig.Links {
   106  		name, alias, err := parsers.ParseLink(l)
   107  		if err != nil {
   108  			return err
   109  		}
   110  		child, err := daemon.Get(name)
   111  		if err != nil {
   112  			//An error from daemon.Get() means this name could not be found
   113  			return fmt.Errorf("Could not get container for %s", name)
   114  		}
   115  		if err := daemon.registerLink(container, child, alias); err != nil {
   116  			return err
   117  		}
   118  	}
   119  
   120  	// After we load all the links into the daemon
   121  	// set them to nil on the hostconfig
   122  	hostConfig.Links = nil
   123  	if err := container.writeHostConfig(); err != nil {
   124  		return err
   125  	}
   126  	return nil
   127  }
   128  
   129  func (daemon *Daemon) newBaseContainer(id string) Container {
   130  	return Container{
   131  		CommonContainer: CommonContainer{
   132  			ID:           id,
   133  			State:        NewState(),
   134  			execCommands: newExecStore(),
   135  			root:         daemon.containerRoot(id),
   136  		},
   137  	}
   138  }