func virtualRouterCreate(client *contrail.Client, flagSet *flag.FlagSet) { if flagSet.NArg() < 1 { flagSet.Usage() os.Exit(2) } if len(virtualRouterCreateOpts.ipAddress) == 0 { fmt.Fprintf(os.Stderr, "The ip-address option must be specified") os.Exit(2) } matched, err := regexp.MatchString(config.IpAddressPattern, virtualRouterCreateOpts.ipAddress) if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(2) } if !matched { fmt.Fprintf(os.Stderr, "Invalid IP address specified: %s\n", virtualRouterCreateOpts.ipAddress) os.Exit(2) } name := flagSet.Args()[0] vrouter := new(types.VirtualRouter) vrouter.SetName(name) vrouter.SetVirtualRouterIpAddress(virtualRouterCreateOpts.ipAddress) client.Create(vrouter) }
func virtualRouterDelete(client *contrail.Client, flagSet *flag.FlagSet) { if flagSet.NArg() < 1 { flagSet.Usage() os.Exit(2) } name := flagSet.Args()[0] obj := new(types.VirtualRouter) fqn := append(obj.GetDefaultParent(), name) uuid, err := client.UuidByName("virtual-router", strings.Join(fqn, ":")) if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } err = client.DeleteByUuid("virtual-router", uuid) if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } }