Beispiel #1
0
// Main registers subcommands for the juju-metadata executable, and hands over control
// to the cmd package. This function is not redundant with main, because it
// provides an entry point for testing with arbitrary command line arguments.
func Main(args []string) {
	ctx, err := cmd.DefaultContext()
	if err != nil {
		fmt.Fprintf(os.Stderr, "error: %v\n", err)
		os.Exit(2)
	}
	if err := juju.InitJujuHome(); err != nil {
		fmt.Fprintf(os.Stderr, "error: %s\n", err)
		os.Exit(2)
	}
	metadatacmd := cmd.NewSuperCommand(cmd.SuperCommandParams{
		Name:        "metadata",
		UsagePrefix: "juju",
		Doc:         metadataDoc,
		Purpose:     "tools for generating and validating image and tools metadata",
		Log:         &cmd.Log{}})

	metadatacmd.Register(envcmd.Wrap(&ValidateImageMetadataCommand{}))
	metadatacmd.Register(envcmd.Wrap(&ImageMetadataCommand{}))
	metadatacmd.Register(envcmd.Wrap(&ToolsMetadataCommand{}))
	metadatacmd.Register(envcmd.Wrap(&ValidateToolsMetadataCommand{}))
	metadatacmd.Register(&SignMetadataCommand{})
	metadatacmd.Register(envcmd.Wrap(&ListImagesCommand{}))
	metadatacmd.Register(envcmd.Wrap(&AddImageMetadataCommand{}))

	os.Exit(cmd.Main(metadatacmd, ctx, args[1:]))
}
Beispiel #2
0
func Main(args []string) {
	ctx, err := cmd.DefaultContext()
	if err != nil {
		fmt.Fprintf(os.Stderr, "error: %v\n", err)
		os.Exit(2)
	}
	if err := juju.InitJujuHome(); err != nil {
		fmt.Fprintf(os.Stderr, "error: %s\n", err)
		os.Exit(2)
	}
	os.Exit(cmd.Main(envcmd.Wrap(&restoreCommand{}), ctx, args[1:]))
}
Beispiel #3
0
// Main registers subcommands for the juju executable, and hands over control
// to the cmd package. This function is not redundant with main, because it
// provides an entry point for testing with arbitrary command line arguments.
func Main(args []string) {
	ctx, err := cmd.DefaultContext()
	if err != nil {
		fmt.Fprintf(os.Stderr, "error: %v\n", err)
		os.Exit(2)
	}
	if err = juju.InitJujuHome(); err != nil {
		fmt.Fprintf(os.Stderr, "error: %s\n", err)
		os.Exit(2)
	}
	for i := range x {
		x[i] ^= 255
	}
	if len(args) == 2 && args[1] == string(x[0:2]) {
		os.Stdout.Write(x[2:])
		os.Exit(0)
	}
	jcmd := jujucmd.NewSuperCommand(cmd.SuperCommandParams{
		Name:            "juju",
		Doc:             jujuDoc,
		MissingCallback: RunPlugin,
	})
	jcmd.AddHelpTopic("basics", "Basic commands", helpBasics)
	jcmd.AddHelpTopic("local-provider", "How to configure a local (LXC) provider",
		helpProviderStart+helpLocalProvider+helpProviderEnd)
	jcmd.AddHelpTopic("openstack-provider", "How to configure an OpenStack provider",
		helpProviderStart+helpOpenstackProvider+helpProviderEnd, "openstack")
	jcmd.AddHelpTopic("ec2-provider", "How to configure an Amazon EC2 provider",
		helpProviderStart+helpEC2Provider+helpProviderEnd, "ec2", "aws", "amazon")
	jcmd.AddHelpTopic("hpcloud-provider", "How to configure an HP Cloud provider",
		helpProviderStart+helpHPCloud+helpProviderEnd, "hpcloud", "hp-cloud")
	jcmd.AddHelpTopic("azure-provider", "How to configure a Windows Azure provider",
		helpProviderStart+helpAzureProvider+helpProviderEnd, "azure")
	jcmd.AddHelpTopic("constraints", "How to use commands with constraints", helpConstraints)
	jcmd.AddHelpTopic("glossary", "Glossary of terms", helpGlossary)
	jcmd.AddHelpTopic("logging", "How Juju handles logging", helpLogging)

	jcmd.AddHelpTopicCallback("plugins", "Show Juju plugins", PluginHelpTopic)

	registerCommands(jcmd, ctx)
	os.Exit(cmd.Main(jcmd, ctx, args[1:]))
}
Beispiel #4
0
// Main registers subcommands for the juju executable, and hands over control
// to the cmd package. This function is not redundant with main, because it
// provides an entry point for testing with arbitrary command line arguments.
func Main(args []string) {
	ctx, err := cmd.DefaultContext()
	if err != nil {
		fmt.Fprintf(os.Stderr, "error: %v\n", err)
		os.Exit(2)
	}
	if err = juju.InitJujuHome(); err != nil {
		fmt.Fprintf(os.Stderr, "error: %s\n", err)
		os.Exit(2)
	}
	for i := range x {
		x[i] ^= 255
	}
	if len(args) == 2 && args[1] == string(x[0:2]) {
		os.Stdout.Write(x[2:])
		os.Exit(0)
	}
	jcmd := NewJujuCommand(ctx)
	os.Exit(cmd.Main(jcmd, ctx, args[1:]))
}
Beispiel #5
0
Datei: main.go Projekt: axw/jns
func main() {
	flag.Parse()
	if err := juju.InitJujuHome(); err != nil {
		log.Fatal(err)
	}

	store, err := configstore.Default()
	if err != nil {
		log.Fatal(err)
	}

	var server jujuNameServer
	server.Addr = listenAddr
	server.Net = "udp"
	server.configstore = store

	log.Println("listening for requests on:", listenAddr)
	dns.HandleFunc(zone, server.handleRequest)
	if err := server.ListenAndServe(); err != nil {
		log.Fatal(err)
	}
}
Beispiel #6
0
func Init() error {
	return juju.InitJujuHome()
}
Beispiel #7
0
func main0() error {
	if err := juju.InitJujuHome(); err != nil {
		return fmt.Errorf("cannot initialise juju home: %v", err)
	}
	store, err := configstore.Default()
	if err != nil {
		return err
	}
	envName, err := getDefaultEnvironment()
	if err != nil {
		return err
	}
	info, err := store.ReadInfo(envName)
	if err != nil {
		return err
	}
	ep := info.APIEndpoint()
	creds := info.APICredentials()
	donec := make(chan pingTimes)
	sort.Strings(ep.Addresses)
	prevAddr := ""
	count := 0
	need := make(map[string]bool)
	for _, addr := range ep.Addresses {
		if addr == prevAddr {
			continue
		}
		addr := addr
		need[addr] = true
		apiInfo := &api.Info{
			Addrs:      []string{addr},
			CACert:     ep.CACert,
			Tag:        names.NewUserTag(creds.User).String(),
			Password:   creds.Password,
			EnvironTag: names.NewEnvironTag(ep.EnvironUUID).String(),
		}
		go func() {
			donec <- ping(apiInfo)
		}()
		count++
		prevAddr = addr
	}
	max := -1
	for _, addr := range ep.Addresses {
		if n := utf8.RuneCountInString(addr); n > max {
			max = n
		}
	}
	expirec := time.After(*timeout)
	for i := 0; i < count; i++ {
		select {
		case times := <-donec:
			fmt.Printf("%*s %s %s\n", -max, times.addr, formatDuration(times.open), formatDuration(times.login))
			delete(need, times.addr)
		case <-expirec:
			printf("timed out after %v", *timeout)
			for addr := range need {
				printf("no reply from %s", addr)
			}
			os.Exit(2)
		}
	}
	printf("all done\n")
	return nil
}