示例#1
0
文件: create.go 项目: pulcy/quark
func (p *scalewayProvider) downloadAndCopyToInstance(url string, i providers.ClusterInstance, instancePath string) error {
	localPath, err := p.dm.Download(url)
	if err != nil {
		return maskAny(err)
	}
	if err := i.CopyTo(p.Logger, localPath, instancePath); err != nil {
		return maskAny(err)
	}
	return nil
}
示例#2
0
文件: reboot.go 项目: pulcy/quark
// Perform a reboot of the given instance
func (vp *scalewayProvider) RebootInstance(instance providers.ClusterInstance) error {
	if err := instance.Sync(vp.Logger); err != nil {
		return maskAny(err)
	}
	if err := vp.client.PostServerAction(instance.ID, "reboot"); err != nil {
		vp.Logger.Errorf("reboot failed: %#v", err)
		return maskAny(err)
	}
	return nil
}
示例#3
0
文件: create.go 项目: pulcy/quark
// bootstrapServer copies etcd & fleet into the instances and runs the scaleway bootstrap script.
// It then reboots the instances and waits until it is active again.
func (vp *scalewayProvider) bootstrapServer(instance providers.ClusterInstance, options providers.CreateInstanceOptions, machineID string) error {
	if err := vp.copyEtcd(instance); err != nil {
		vp.Logger.Errorf("copy etcd failed: %#v", err)
		return maskAny(err)
	}
	if err := vp.copyFleet(instance); err != nil {
		vp.Logger.Errorf("copy fleet failed: %#v", err)
		return maskAny(err)
	}

	// Bootstrap
	bootstrapOptions := struct {
		ScalewayProviderConfig
		providers.CreateInstanceOptions
		MachineID string
	}{
		ScalewayProviderConfig: vp.ScalewayProviderConfig,
		CreateInstanceOptions:  options,
		MachineID:              machineID,
	}
	bootstrap, err := templates.Render(bootstrapTemplate, bootstrapOptions)
	if err != nil {
		return maskAny(err)
	}
	vp.Logger.Infof("Running bootstrap on %s. This may take a while...", instance.Name)
	if err := instance.RunScript(vp.Logger, bootstrap, "/root/pulcy-bootstrap.sh"); err != nil {
		// Failed expected because of a reboot
		vp.Logger.Debugf("bootstrap failed (expected): %#v", err)
	}

	vp.Logger.Infof("Done running bootstrap on %s, rebooting...", instance.Name)
	if err := vp.client.PostServerAction(instance.ID, "reboot"); err != nil {
		vp.Logger.Errorf("reboot failed: %#v", err)
		return maskAny(err)
	}
	time.Sleep(time.Second * 5)
	if _, err := vp.waitUntilServerActive(instance.ID, false); err != nil {
		return maskAny(err)
	}

	vp.Logger.Infof("Created server %s %s\n", instance.ID, instance.Name)

	return nil
}
示例#4
0
文件: reboot.go 项目: pulcy/quark
// Perform a reboot of the given instance
func (vp *doProvider) RebootInstance(instance providers.ClusterInstance) error {
	if _, err := instance.Exec(vp.Logger, "sudo shutdown -r now"); err != nil {
		return maskAny(err)
	}
	return nil
}