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