Implemented the provision / activate ont workflow

Change-Id: Ife684f41e54e176879332922ad86f517358f15e7
diff --git a/models/abstract/ChassisUtils.go b/models/abstract/ChassisUtils.go
index 4c41698..2377453 100644
--- a/models/abstract/ChassisUtils.go
+++ b/models/abstract/ChassisUtils.go
@@ -16,8 +16,6 @@
 
 package abstract
 
-import "errors"
-
 /*
 GenerateChassis - constructs a new AbstractOLT Chassis
 */
@@ -82,24 +80,3 @@
 /*
 NextPort pulls the first unMapped port in the abstract chassis so the next physical port can be mapped to it
 */
-func (chassis *Chassis) NextPort() (*Port, error) {
-	info := &chassis.AllocInfo
-
-	if info.outOfPorts {
-		return nil, errors.New("Abstract chassis out of ports")
-	}
-
-	nextPort := &chassis.Slots[info.slot].Ports[info.port]
-
-	info.port++
-	if info.port == MAX_PORTS {
-		info.port = 0
-		info.slot++
-		if info.slot == MAX_SLOTS {
-			info.slot = 0
-			info.outOfPorts = true
-		}
-	}
-
-	return nextPort, nil
-}
diff --git a/models/abstract/chassis.go b/models/abstract/chassis.go
index 52de90d..74a288c 100644
--- a/models/abstract/chassis.go
+++ b/models/abstract/chassis.go
@@ -16,6 +16,8 @@
 
 package abstract
 
+import "errors"
+
 const MAX_SLOTS int = 16
 const MAX_PORTS int = 16
 
@@ -34,3 +36,29 @@
 	port       int
 	outOfPorts bool
 }
+
+func (chassis *Chassis) NextPort() (*Port, error) {
+	info := &chassis.AllocInfo
+
+	if info.outOfPorts {
+		return nil, errors.New("Abstract chassis out of ports")
+	}
+
+	nextPort := &chassis.Slots[info.slot].Ports[info.port]
+
+	info.port++
+	if info.port == MAX_PORTS {
+		info.port = 0
+		info.slot++
+		if info.slot == MAX_SLOTS {
+			info.slot = 0
+			info.outOfPorts = true
+		}
+	}
+
+	return nextPort, nil
+}
+func (chassis *Chassis) ActivateONT(slotNumber int, portNumber int, ontNumber int, serialNumber string) error {
+	err := chassis.Slots[slotNumber-1].Ports[portNumber].provisionOnt(ontNumber, serialNumber)
+	return err
+}
diff --git a/models/abstract/port.go b/models/abstract/port.go
index c23249a..5dfa195 100644
--- a/models/abstract/port.go
+++ b/models/abstract/port.go
@@ -16,7 +16,11 @@
 
 package abstract
 
-import "gerrit.opencord.org/abstract-olt/models/physical"
+import (
+	"fmt"
+
+	"gerrit.opencord.org/abstract-olt/models/physical"
+)
 
 /*
 Port represents a single PON port on the OLT chassis
@@ -28,3 +32,26 @@
 	PhysPort *physical.PONPort
 	Parent   *Slot `json:"-"`
 }
+
+type UnprovisonedPortError struct {
+	oltNum  int
+	clli    string
+	portNum int
+}
+
+func (e *UnprovisonedPortError) Error() string {
+	return fmt.Sprintf("Port %d for olt %d on AbstractChasis  %s is not provisioned", e.portNum, e.oltNum, e.clli)
+}
+func (port *Port) provisionOnt(ontNumber int, serialNumber string) error {
+	if port.PhysPort == nil {
+		slot := port.Parent
+		chassis := slot.Parent
+		err := UnprovisonedPortError{oltNum: slot.Number, clli: chassis.CLLI, portNum: port.Number}
+		return &err
+	}
+
+	phyPort := port.PhysPort
+	ont := port.Onts[ontNumber-1]
+	phyPort.ActivateOnt(ontNumber, ont.Svlan, ont.Cvlan, serialNumber)
+	return nil
+}