[VOL-5479] ipaddress change for OLT

Change-Id: I2626d18930e08cebb96b3bddb2989bf9e9c6afc5
Signed-off-by: Akash Reddy Kankanala <akash.kankanala@radisys.com>
diff --git a/VERSION b/VERSION
index 3c3b474..97ba4c9 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.11.14
+1.11.15
diff --git a/internal/pkg/commands/devices.go b/internal/pkg/commands/devices.go
index 7ce777a..f2521cc 100644
--- a/internal/pkg/commands/devices.go
+++ b/internal/pkg/commands/devices.go
@@ -258,6 +258,15 @@
 	ListOutputOptions
 }
 
+type DeviceUpdate struct {
+	ListOutputOptions
+	Args struct {
+		Id          string `positional-arg-name:"DEVICE_ID" required:"yes"`
+		AddressType string `positional-arg-name:"ADDRESS_TYPE" required:"yes" choice:"IPV4" choice:"IPV6" choice:"HOST_AND_PORT"`
+		Address     string `positional-arg-name:"HOST_AND_PORT" required:"yes"`
+	} `positional-args:"yes"`
+}
+
 type DeviceCreate struct {
 	DeviceType  string `short:"t" required:"true" long:"devicetype" description:"Device type"`
 	MACAddress  string `short:"m" long:"macaddress" default:"" description:"MAC Address"`
@@ -699,6 +708,7 @@
 	EnableOnuSerialNumber  EnableOnuSerialNumber  `command:"enable_onu_serial"`
 	Flows                  DeviceFlowList         `command:"flows"`
 	Groups                 DeviceFlowGroupList    `command:"groups"`
+	Update                 DeviceUpdate           `command:"update"`
 	Port                   struct {
 		List    DevicePortList    `command:"list"`
 		Enable  DevicePortEnable  `command:"enable"`
@@ -3432,3 +3442,35 @@
 	fmt.Printf("Enabled ONU serial '%s' on OLT '%s'\n", options.Args.SerialNumber, options.Args.OltDeviceId)
 	return nil
 }
+
+func (options *DeviceUpdate) Execute(args []string) error {
+	conn, err := NewConnection()
+	if err != nil {
+		return err
+	}
+	defer conn.Close()
+	client := voltha.NewVolthaServiceClient(conn)
+	ctx, cancel := context.WithTimeout(context.Background(), GlobalConfig.Current().Grpc.Timeout)
+	defer cancel()
+	var deviceConfig voltha.UpdateDevice
+	switch options.Args.AddressType {
+	case "IPV4":
+		deviceConfig.Id = options.Args.Id
+		deviceConfig.Address = &voltha.UpdateDevice_Ipv4Address{Ipv4Address: options.Args.Address}
+	case "IPV6":
+		deviceConfig.Id = options.Args.Id
+		deviceConfig.Address = &voltha.UpdateDevice_Ipv6Address{Ipv6Address: options.Args.Address}
+	case "HOST_AND_PORT":
+		deviceConfig.Id = options.Args.Id
+		deviceConfig.Address = &voltha.UpdateDevice_HostAndPort{HostAndPort: options.Args.Address}
+	default:
+		return fmt.Errorf("invalid address type %s, supported types are IPV4, IPV6, HOST_AND_PORT", options.Args.AddressType)
+	}
+	_, err = client.UpdateDevice(ctx, &deviceConfig)
+	if err != nil {
+		Error.Printf("Error updating device Id %s,err=%s\n", options.Args.Id, ErrorToString(err))
+		return err
+	}
+	return nil
+
+}