Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2017 the original author or authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package main |
| 18 | |
| 19 | import ( |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 20 | "context" |
| 21 | "flag" |
| 22 | "fmt" |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 23 | "log" |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 24 | "runtime/debug" |
donNewtonAlpha | b3279ea | 2018-09-18 15:55:32 -0400 | [diff] [blame] | 25 | "strings" |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 26 | |
| 27 | "gerrit.opencord.org/abstract-olt/api" |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 28 | "google.golang.org/grpc" |
| 29 | "google.golang.org/grpc/credentials" |
| 30 | ) |
| 31 | |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 32 | func main() { |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 33 | /* COMMAND FLAGS */ |
donNewtonAlpha | b3279ea | 2018-09-18 15:55:32 -0400 | [diff] [blame] | 34 | echo := flag.Bool("e", false, "echo") |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 35 | create := flag.Bool("c", false, "create?") |
donNewtonAlpha | 57aa2ff | 2018-10-01 16:45:32 -0400 | [diff] [blame] | 36 | update := flag.Bool("u", false, "update?") |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 37 | addOlt := flag.Bool("s", false, "addOlt?") |
| 38 | provOnt := flag.Bool("o", false, "provisionOnt?") |
Don Newton | 281e025 | 2018-10-22 14:38:50 -0400 | [diff] [blame] | 39 | provOntFull := flag.Bool("f", false, "provsionOntFull?") |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 40 | deleteOnt := flag.Bool("d", false, "deleteOnt") |
Don Newton | 281e025 | 2018-10-22 14:38:50 -0400 | [diff] [blame] | 41 | output := flag.Bool("output", false, "dump output") |
Don Newton | e973d34 | 2018-10-26 16:44:12 -0400 | [diff] [blame] | 42 | reflow := flag.Bool("reflow", false, "reflow provisioning tosca") |
donNewtonAlpha | 27ad20c | 2018-10-30 16:18:42 -0400 | [diff] [blame] | 43 | fullInventory := flag.Bool("full_inventory", false, "pull full inventory json") |
| 44 | inventory := flag.Bool("inventory", false, "pull json inventory for a specific clli") |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 45 | /* END COMMAND FLAGS */ |
| 46 | |
| 47 | /* CREATE CHASSIS FLAGS */ |
donNewtonAlpha | 57aa2ff | 2018-10-01 16:45:32 -0400 | [diff] [blame] | 48 | xosUser := flag.String("xos_user", "", "xos_user") |
| 49 | xosPassword := flag.String("xos_password", "", "xos_password") |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 50 | xosAddress := flag.String("xos_address", "", "xos address") |
| 51 | xosPort := flag.Uint("xos_port", 0, "xos port") |
| 52 | rack := flag.Uint("rack", 1, "rack number for chassis") |
| 53 | shelf := flag.Uint("shelf", 1, "shelf number for chassis") |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 54 | /* END CREATE CHASSIS FLAGS */ |
| 55 | |
| 56 | /* ADD OLT FLAGS */ |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 57 | oltAddress := flag.String("olt_address", "", "ip address for olt chassis") |
| 58 | oltPort := flag.Uint("olt_port", 0, "listen port for olt chassis") |
| 59 | name := flag.String("name", "", "friendly name for olt chassis") |
| 60 | driver := flag.String("driver", "", "driver to use with olt chassis") |
| 61 | oltType := flag.String("type", "", "olt chassis type") |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 62 | /* END ADD OLT FLAGS */ |
| 63 | |
| 64 | /* PROVISION / DELETE ONT FLAGS */ |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 65 | slot := flag.Uint("slot", 1, "slot number 1-16 to provision ont to") |
| 66 | port := flag.Uint("port", 1, "port number 1-16 to provision ont to") |
| 67 | ont := flag.Uint("ont", 1, "ont number 1-64") |
| 68 | serial := flag.String("serial", "", "serial number of ont") |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 69 | /* END PROVISION / DELETE ONT FLAGS */ |
| 70 | |
Don Newton | 281e025 | 2018-10-22 14:38:50 -0400 | [diff] [blame] | 71 | /*PROVISION ONT FULL EXTRA FLAGS*/ |
| 72 | stag := flag.Uint("stag", 0, "s-tag for ont") |
| 73 | ctag := flag.Uint("ctag", 0, "c-tag for ont") |
| 74 | nasPort := flag.String("nas_port", "", "NasPortID for ont") |
| 75 | circuitID := flag.String("circuit_id", "", "CircuitID for ont") |
| 76 | /*END PROVISION ONT FULL EXTRA FLAGS*/ |
| 77 | |
| 78 | /* ECHO FLAGS */ |
| 79 | message := flag.String("message", "ping", "message to be echoed back") |
| 80 | /*END ECHO FLAGS*/ |
| 81 | |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 82 | /*GENERIC FLAGS */ |
| 83 | clli := flag.String("clli", "", "clli of abstract chassis") |
donNewtonAlpha | b3279ea | 2018-09-18 15:55:32 -0400 | [diff] [blame] | 84 | useSsl := flag.Bool("ssl", false, "use ssl") |
| 85 | useAuth := flag.Bool("auth", false, "use auth") |
| 86 | crtFile := flag.String("cert", "cert/server.crt", "Public cert for server to establish tls session") |
| 87 | serverAddressPort := flag.String("server", "localhost:7777", "address and port of AbstractOLT server") |
| 88 | fqdn := flag.String("fqdn", "", "FQDN of the service to match what is in server.crt") |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 89 | /*GENERIC FLAGS */ |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 90 | |
| 91 | flag.Parse() |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 92 | |
donNewtonAlpha | b3279ea | 2018-09-18 15:55:32 -0400 | [diff] [blame] | 93 | if *useSsl { |
| 94 | if *fqdn == "" { |
| 95 | fqdn = &(strings.Split(*serverAddressPort, ":")[0]) |
| 96 | fmt.Printf("using %s as the FQDN for the AbstractOLT server", *fqdn) |
| 97 | } |
| 98 | } |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 99 | |
donNewtonAlpha | 27ad20c | 2018-10-30 16:18:42 -0400 | [diff] [blame] | 100 | cmdFlags := []*bool{echo, addOlt, update, create, provOnt, provOntFull, deleteOnt, output, reflow, fullInventory, inventory} |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 101 | cmdCount := 0 |
| 102 | for _, flag := range cmdFlags { |
| 103 | if *flag { |
| 104 | cmdCount++ |
| 105 | } |
| 106 | } |
| 107 | if cmdCount > 1 { |
| 108 | fmt.Println("CMD You can only call one method at a time") |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 109 | usage() |
| 110 | return |
| 111 | } |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 112 | if cmdCount < 1 { |
| 113 | fmt.Println("CMD You didn't specify an operation to perform") |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 114 | usage() |
| 115 | return |
| 116 | } |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 117 | |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 118 | var conn *grpc.ClientConn |
donNewtonAlpha | b3279ea | 2018-09-18 15:55:32 -0400 | [diff] [blame] | 119 | var err error |
| 120 | |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 121 | // Setup the login/pass |
| 122 | auth := Authentication{ |
| 123 | Login: "john", |
| 124 | Password: "doe", |
| 125 | } |
donNewtonAlpha | b3279ea | 2018-09-18 15:55:32 -0400 | [diff] [blame] | 126 | if *useSsl && *useAuth { |
| 127 | |
| 128 | creds, err := credentials.NewClientTLSFromFile(*crtFile, *fqdn) |
| 129 | conn, err = grpc.Dial(*serverAddressPort, grpc.WithTransportCredentials(creds), grpc.WithPerRPCCredentials(&auth)) |
| 130 | if err != nil { |
| 131 | log.Fatalf("could not load tls cert: %s", err) |
| 132 | } |
| 133 | } else if *useSsl { |
| 134 | creds, err := credentials.NewClientTLSFromFile("cert/server.crt", *fqdn) |
| 135 | conn, err = grpc.Dial(*serverAddressPort, grpc.WithTransportCredentials(creds)) |
| 136 | if err != nil { |
| 137 | log.Fatalf("could not load tls cert: %s", err) |
| 138 | } |
| 139 | } else if *useAuth { |
| 140 | conn, err = grpc.Dial(*serverAddressPort, grpc.WithInsecure(), grpc.WithPerRPCCredentials(&auth)) |
| 141 | } else { |
| 142 | conn, err = grpc.Dial(*serverAddressPort, grpc.WithInsecure()) |
| 143 | } |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 144 | if err != nil { |
| 145 | log.Fatalf("did not connect: %s", err) |
| 146 | } |
| 147 | defer conn.Close() |
| 148 | |
| 149 | c := api.NewAbstractOLTClient(conn) |
| 150 | if *create { |
donNewtonAlpha | 57aa2ff | 2018-10-01 16:45:32 -0400 | [diff] [blame] | 151 | createChassis(c, clli, xosUser, xosPassword, xosAddress, xosPort, rack, shelf) |
| 152 | } else if *update { |
| 153 | updateXOSUserPassword(c, clli, xosUser, xosPassword) |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 154 | } else if *addOlt { |
| 155 | addOltChassis(c, clli, oltAddress, oltPort, name, driver, oltType) |
| 156 | } else if *provOnt { |
| 157 | provisionONT(c, clli, slot, port, ont, serial) |
Don Newton | 281e025 | 2018-10-22 14:38:50 -0400 | [diff] [blame] | 158 | } else if *provOntFull { |
| 159 | provisionONTFull(c, clli, slot, port, ont, serial, stag, ctag, nasPort, circuitID) |
donNewtonAlpha | b3279ea | 2018-09-18 15:55:32 -0400 | [diff] [blame] | 160 | } else if *echo { |
| 161 | ping(c, *message) |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 162 | } else if *output { |
| 163 | Output(c) |
| 164 | } else if *deleteOnt { |
| 165 | deleteONT(c, clli, slot, port, ont, serial) |
Don Newton | e973d34 | 2018-10-26 16:44:12 -0400 | [diff] [blame] | 166 | } else if *reflow { |
| 167 | reflowTosca(c) |
donNewtonAlpha | 27ad20c | 2018-10-30 16:18:42 -0400 | [diff] [blame] | 168 | } else if *fullInventory { |
| 169 | getFullInventory(c) |
| 170 | } else if *inventory { |
| 171 | getInventory(c, clli) |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 172 | } |
| 173 | |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 174 | } |
| 175 | |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 176 | // Authentication holds the login/password |
| 177 | type Authentication struct { |
| 178 | Login string |
| 179 | Password string |
| 180 | } |
| 181 | |
| 182 | // GetRequestMetadata gets the current request metadata |
| 183 | func (a *Authentication) GetRequestMetadata(context.Context, ...string) (map[string]string, error) { |
| 184 | return map[string]string{ |
| 185 | "login": a.Login, |
| 186 | "password": a.Password, |
| 187 | }, nil |
| 188 | } |
| 189 | |
| 190 | // RequireTransportSecurity indicates whether the credentials requires transport security |
| 191 | func (a *Authentication) RequireTransportSecurity() bool { |
| 192 | return true |
| 193 | } |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 194 | func Output(c api.AbstractOLTClient) error { |
| 195 | response, err := c.Output(context.Background(), &api.OutputMessage{Something: "wtf"}) |
| 196 | if err != nil { |
| 197 | fmt.Printf("Error when calling Echo: %s", err) |
| 198 | return err |
| 199 | } |
| 200 | log.Printf("Response from server: %v", response.GetSuccess()) |
| 201 | |
| 202 | return nil |
| 203 | } |
| 204 | |
donNewtonAlpha | b3279ea | 2018-09-18 15:55:32 -0400 | [diff] [blame] | 205 | func ping(c api.AbstractOLTClient, message string) error { |
| 206 | response, err := c.Echo(context.Background(), &api.EchoMessage{Ping: message}) |
| 207 | if err != nil { |
| 208 | fmt.Printf("Error when calling Echo: %s", err) |
| 209 | return err |
| 210 | } |
| 211 | log.Printf("Response from server: %s", response.GetPong()) |
| 212 | return nil |
| 213 | } |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 214 | |
donNewtonAlpha | 57aa2ff | 2018-10-01 16:45:32 -0400 | [diff] [blame] | 215 | func createChassis(c api.AbstractOLTClient, clli *string, xosUser *string, xosPassword *string, xosAddress *string, xosPort *uint, rack *uint, shelf *uint) error { |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 216 | fmt.Println("Calling Create Chassis") |
| 217 | fmt.Println("clli", *clli) |
donNewtonAlpha | 57aa2ff | 2018-10-01 16:45:32 -0400 | [diff] [blame] | 218 | fmt.Println("xos_user", *xosUser) |
| 219 | fmt.Println("xos_password", *xosPassword) |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 220 | fmt.Println("xos_address", *xosAddress) |
| 221 | fmt.Println("xos_port", *xosPort) |
| 222 | fmt.Println("rack", *rack) |
| 223 | fmt.Println("shelf", *shelf) |
donNewtonAlpha | 57aa2ff | 2018-10-01 16:45:32 -0400 | [diff] [blame] | 224 | response, err := c.CreateChassis(context.Background(), &api.AddChassisMessage{CLLI: *clli, XOSUser: *xosUser, XOSPassword: *xosPassword, |
| 225 | XOSIP: *xosAddress, XOSPort: int32(*xosPort), Rack: int32(*rack), Shelf: int32(*shelf)}) |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 226 | if err != nil { |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 227 | fmt.Printf("Error when calling CreateChassis: %s", err) |
| 228 | return err |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 229 | } |
| 230 | log.Printf("Response from server: %s", response.GetDeviceID()) |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 231 | return nil |
| 232 | } |
donNewtonAlpha | 57aa2ff | 2018-10-01 16:45:32 -0400 | [diff] [blame] | 233 | func updateXOSUserPassword(c api.AbstractOLTClient, clli *string, xosUser *string, xosPassword *string) error { |
| 234 | fmt.Println("Calling Update XOS USER/PASSWORD") |
| 235 | fmt.Println("clli", *clli) |
| 236 | fmt.Println("xos_user", *xosUser) |
| 237 | fmt.Println("xos_password", *xosPassword) |
| 238 | response, err := c.ChangeXOSUserPassword(context.Background(), &api.ChangeXOSUserPasswordMessage{CLLI: *clli, XOSUser: *xosUser, XOSPassword: *xosPassword}) |
| 239 | if err != nil { |
| 240 | fmt.Printf("Error when calling UpdateXOSUserPassword: %s", err) |
| 241 | return err |
| 242 | } |
donNewtonAlpha | b146639 | 2018-10-02 10:42:05 -0400 | [diff] [blame] | 243 | log.Printf("Response from server: %t", response.GetSuccess()) |
donNewtonAlpha | 57aa2ff | 2018-10-01 16:45:32 -0400 | [diff] [blame] | 244 | return nil |
| 245 | } |
| 246 | |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 247 | func addOltChassis(c api.AbstractOLTClient, clli *string, oltAddress *string, oltPort *uint, name *string, driver *string, oltType *string) error { |
| 248 | fmt.Println("clli", *clli) |
| 249 | fmt.Println("olt_address", *oltAddress) |
| 250 | fmt.Println("olt_port", *oltPort) |
| 251 | fmt.Println("name", *name) |
| 252 | fmt.Println("driver", *driver) |
| 253 | fmt.Println("type", *oltType) |
| 254 | var driverType api.AddOLTChassisMessage_OltDriver |
| 255 | var chassisType api.AddOLTChassisMessage_OltType |
| 256 | switch *oltType { |
| 257 | case "edgecore": |
| 258 | chassisType = api.AddOLTChassisMessage_edgecore |
| 259 | } |
| 260 | switch *driver { |
| 261 | case "openolt": |
| 262 | driverType = api.AddOLTChassisMessage_openoltDriver |
| 263 | |
| 264 | } |
| 265 | |
| 266 | res, err := c.CreateOLTChassis(context.Background(), &api.AddOLTChassisMessage{CLLI: *clli, SlotIP: *oltAddress, SlotPort: uint32(*oltPort), Hostname: *name, Type: chassisType, Driver: driverType}) |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 267 | if err != nil { |
| 268 | debug.PrintStack() |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 269 | fmt.Printf("Error when calling CreateOLTChassis: %s", err) |
| 270 | return err |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 271 | } |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 272 | log.Printf("Response from server: %s", res.GetDeviceID()) |
| 273 | return nil |
| 274 | } |
| 275 | func provisionONT(c api.AbstractOLTClient, clli *string, slot *uint, port *uint, ont *uint, serial *string) error { |
| 276 | fmt.Println("clli", *clli) |
| 277 | fmt.Println("slot", *slot) |
| 278 | fmt.Println("port", *port) |
| 279 | fmt.Println("ont", *ont) |
| 280 | fmt.Println("serial", *serial) |
| 281 | res, err := c.ProvisionOnt(context.Background(), &api.AddOntMessage{CLLI: *clli, SlotNumber: int32(*slot), PortNumber: int32(*port), OntNumber: int32(*ont), SerialNumber: *serial}) |
| 282 | if err != nil { |
| 283 | debug.PrintStack() |
| 284 | fmt.Printf("Error when calling ProvsionOnt %s", err) |
| 285 | return err |
| 286 | } |
| 287 | log.Printf("Response from server: %t", res.GetSuccess()) |
| 288 | return nil |
Don Newton | 281e025 | 2018-10-22 14:38:50 -0400 | [diff] [blame] | 289 | } |
| 290 | func provisionONTFull(c api.AbstractOLTClient, clli *string, slot *uint, port *uint, ont *uint, serial *string, stag *uint, ctag *uint, nasPort *string, circuitID *string) error { |
| 291 | fmt.Println("clli", *clli) |
| 292 | fmt.Println("slot", *slot) |
| 293 | fmt.Println("port", *port) |
| 294 | fmt.Println("ont", *ont) |
| 295 | fmt.Println("serial", *serial) |
| 296 | fmt.Println("stag", *stag) |
| 297 | fmt.Println("ctag", *ctag) |
| 298 | fmt.Println("nasPort", *nasPort) |
| 299 | fmt.Println("circuitID", *circuitID) |
| 300 | res, err := c.ProvisionOntFull(context.Background(), &api.AddOntFullMessage{CLLI: *clli, SlotNumber: int32(*slot), PortNumber: int32(*port), OntNumber: int32(*ont), SerialNumber: *serial, STag: uint32(*stag), CTag: uint32(*ctag), NasPortID: *nasPort, CircuitID: *circuitID}) |
| 301 | if err != nil { |
| 302 | debug.PrintStack() |
| 303 | fmt.Printf("Error when calling ProvsionOnt %s", err) |
| 304 | return err |
| 305 | } |
| 306 | log.Printf("Response from server: %t", res.GetSuccess()) |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 307 | return nil |
| 308 | } |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 309 | func deleteONT(c api.AbstractOLTClient, clli *string, slot *uint, port *uint, ont *uint, serial *string) error { |
| 310 | fmt.Println("clli", *clli) |
| 311 | fmt.Println("slot", *slot) |
| 312 | fmt.Println("port", *port) |
| 313 | fmt.Println("ont", *ont) |
| 314 | fmt.Println("serial", *serial) |
| 315 | res, err := c.DeleteOnt(context.Background(), &api.DeleteOntMessage{CLLI: *clli, SlotNumber: int32(*slot), PortNumber: int32(*port), OntNumber: int32(*ont), SerialNumber: *serial}) |
| 316 | if err != nil { |
| 317 | debug.PrintStack() |
| 318 | fmt.Printf("Error when calling ProvsionOnt %s", err) |
| 319 | return err |
| 320 | } |
| 321 | log.Printf("Response from server: %t", res.GetSuccess()) |
| 322 | return nil |
| 323 | } |
Don Newton | e973d34 | 2018-10-26 16:44:12 -0400 | [diff] [blame] | 324 | func reflowTosca(c api.AbstractOLTClient) error { |
| 325 | res, err := c.Reflow(context.Background(), &api.ReflowMessage{}) |
| 326 | if err != nil { |
| 327 | debug.PrintStack() |
| 328 | fmt.Printf("Error when calling Reflow %s", err) |
| 329 | return err |
| 330 | } |
| 331 | log.Printf("Response from server: %t", res.GetSuccess()) |
| 332 | return nil |
| 333 | } |
donNewtonAlpha | 27ad20c | 2018-10-30 16:18:42 -0400 | [diff] [blame] | 334 | func getFullInventory(c api.AbstractOLTClient) error { |
| 335 | res, err := c.GetFullInventory(context.Background(), &api.FullInventoryMessage{}) |
| 336 | if err != nil { |
| 337 | debug.PrintStack() |
| 338 | fmt.Printf("Error when calling Reflow %s", err) |
| 339 | return err |
| 340 | } |
| 341 | log.Println(res.GetJsonDump()) |
| 342 | return nil |
| 343 | } |
| 344 | func getInventory(c api.AbstractOLTClient, clli *string) error { |
| 345 | res, err := c.GetInventory(context.Background(), &api.InventoryMessage{Clli: *clli}) |
| 346 | if err != nil { |
| 347 | debug.PrintStack() |
| 348 | fmt.Printf("Error when calling Reflow %s", err) |
| 349 | return err |
| 350 | } |
| 351 | log.Println(res.GetJsonDump()) |
| 352 | return nil |
| 353 | } |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 354 | |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 355 | func usage() { |
| 356 | var output = ` |
donNewtonAlpha | b3279ea | 2018-09-18 15:55:32 -0400 | [diff] [blame] | 357 | Usage ./client -server=[serverAddress:port] -[methodFlag] params |
| 358 | ./client -ssl -fqdn=FQDN_OF_ABSTRACT_OLT_SERVER.CRT -cert PATH_TO_SERVER.CRT -server=[serverAddress:port] -[methodFlag] params : use ssl |
| 359 | ./client -auth -server=[serverAddress:port] -[methodFlag] params : Authenticate session |
| 360 | |
| 361 | methodFlags: |
| 362 | -e echo # used to test connectivity to server NOOP |
| 363 | params: |
| 364 | -message string to be echoed back from the server |
| 365 | e.g. ./client -server=localhost:7777 -e -message MESSAGE_TO_BE_ECHOED |
Don Newton | 0766ec2 | 2018-11-06 15:18:05 -0500 | [diff] [blame] | 366 | |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 367 | -c create chassis |
| 368 | params: |
| 369 | -clli CLLI_NAME |
donNewtonAlpha | 57aa2ff | 2018-10-01 16:45:32 -0400 | [diff] [blame] | 370 | -xos_user XOS_USER |
| 371 | -xos_password XOS_PASSWORD |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 372 | -xos_address XOS_TOSCA_IP |
| 373 | -xos_port XOS_TOSCA_LISTEN_PORT |
| 374 | -rack [optional default 1] |
| 375 | -shelf [optional default 1] |
donNewtonAlpha | 57aa2ff | 2018-10-01 16:45:32 -0400 | [diff] [blame] | 376 | e.g. ./client -server=localhost:7777 -c -clli MY_CLLI -xos_user foundry -xos_password password -xos_address 192.168.0.1 -xos_port 30007 -rack 1 -shelf 1 |
Don Newton | 0766ec2 | 2018-11-06 15:18:05 -0500 | [diff] [blame] | 377 | |
donNewtonAlpha | 57aa2ff | 2018-10-01 16:45:32 -0400 | [diff] [blame] | 378 | -u update xos user/password |
| 379 | -clli CLLI_NAME |
| 380 | -xos_user XOS_USER |
| 381 | -xos_password XOS_PASSWORD |
| 382 | e.g. ./client -server=localhost:7777 -u -clli MY_CLLI -xos_user NEW_USER -xos_password NEW_PASSWORD |
Don Newton | 0766ec2 | 2018-11-06 15:18:05 -0500 | [diff] [blame] | 383 | |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 384 | -s add physical olt chassis to chassis |
| 385 | params: |
| 386 | -clli CLLI_NAME - identifies abstract chassis to assign olt chassis to |
| 387 | -olt_address - OLT_CHASSIS_IP_ADDRESS |
| 388 | -olt_port - OLT_CHASSIS_LISTEN_PORT |
| 389 | -name - OLT_NAME internal human readable name to identify OLT_CHASSIS |
| 390 | -driver [openolt,asfvolt16,adtran,tibits] - used to tell XOS which driver should be used to manange chassis |
| 391 | -type [edgecore,adtran,tibit] - used to tell AbstractOLT how many ports are available on olt chassis |
donNewtonAlpha | b3279ea | 2018-09-18 15:55:32 -0400 | [diff] [blame] | 392 | e.g. ./client -server abstractOltHost:7777 -s -clli MY_CLLI -olt_address 192.168.1.100 -olt_port=9191 -name=slot1 -driver=openolt -type=adtran |
Don Newton | 0766ec2 | 2018-11-06 15:18:05 -0500 | [diff] [blame] | 393 | |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 394 | -o provision ont - adds ont to whitelist in XOS on a specific port on a specific olt chassis based on abstract -> phyisical mapping |
| 395 | params: |
| 396 | -clli CLLI_NAME |
| 397 | -slot SLOT_NUMBER [1-16] |
| 398 | -port OLT_PORT_NUMBER [1-16] |
| 399 | -ont ONT_NUMBER [1-64] |
| 400 | -serial ONT_SERIAL_NUM |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 401 | e.g. ./client -server=localhost:7777 -o -clli=MY_CLLI -slot=1 -port=1 -ont=22 -serial=aer900jasdf |
Don Newton | 0766ec2 | 2018-11-06 15:18:05 -0500 | [diff] [blame] | 402 | |
Don Newton | 281e025 | 2018-10-22 14:38:50 -0400 | [diff] [blame] | 403 | -f provision ont full - same as -o above but allows explicit set of s/c vlans , NasPortID and CircuitID |
| 404 | params: |
| 405 | -clli CLLI_NAME |
| 406 | -slot SLOT_NUMBER [1-16] |
| 407 | -port OLT_PORT_NUMBER [1-16] |
| 408 | -ont ONT_NUMBER [1-64] |
| 409 | -serial ONT_SERIAL_NUM |
| 410 | -stag S_TAG |
| 411 | -ctag C_TAG |
| 412 | -nas_port NAS_PORT_ID |
| 413 | -circuit_id CIRCUIT_ID |
| 414 | e.g. ./client -server=localhost:7777 -f -clli=MY_CLLI -slot=1 -port=1 -ont=22 -serial=aer900jasdf -stag=33 -ctag=104 -nas_port="pon 1/1/1/3:1.1" -circuit_id="CLLI 1/1/1/13:1.1" |
Don Newton | 0766ec2 | 2018-11-06 15:18:05 -0500 | [diff] [blame] | 415 | |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 416 | -d delete ont - removes ont from service |
| 417 | params: |
| 418 | -clli CLLI_NAME |
| 419 | -slot SLOT_NUMBER [1-16] |
| 420 | -port OLT_PORT_NUMBER [1-16] |
| 421 | -ont ONT_NUMBER [1-64] |
| 422 | -serial ONT_SERIAL_NUM |
| 423 | e.g. ./client -server=localhost:7777 -d -clli=MY_CLLI -slot=1 -port=1 -ont=22 -serial=aer900jasdf |
Don Newton | 0766ec2 | 2018-11-06 15:18:05 -0500 | [diff] [blame] | 424 | |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 425 | -output (TEMPORARY) causes AbstractOLT to serialize all chassis to JSON file in $WorkingDirectory/backups |
| 426 | e.g. ./client -server=localhost:7777 -output |
Don Newton | 0766ec2 | 2018-11-06 15:18:05 -0500 | [diff] [blame] | 427 | |
Don Newton | e973d34 | 2018-10-26 16:44:12 -0400 | [diff] [blame] | 428 | -reflow causes tosca to be repushed to xos |
| 429 | e.g. ./client -server=localhost:7777 -reflow |
Don Newton | 0766ec2 | 2018-11-06 15:18:05 -0500 | [diff] [blame] | 430 | |
| 431 | -inventory - returns a json document that describes currently provisioned equipment for a specific clli |
| 432 | params: |
| 433 | -clli CLLI_NAME |
| 434 | e.g. ./client -inventory -clli=ATLEDGEVOLT1 |
| 435 | |
| 436 | -full_inventory - returns a json document that describes all currently provisioned pods |
| 437 | e.g. ./client -full_inventory |
| 438 | |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 439 | ` |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 440 | |
| 441 | fmt.Println(output) |
Author Name | a594e63 | 2018-08-10 11:33:58 -0400 | [diff] [blame] | 442 | } |