seba-343 - added preprovision api

Change-Id: I5760e059154e2966ea2545b48306fce78cbe4daf
diff --git a/models/abstract/chassis.go b/models/abstract/chassis.go
index 2b3231b..929f247 100644
--- a/models/abstract/chassis.go
+++ b/models/abstract/chassis.go
@@ -63,6 +63,41 @@
 
 	return nextPort, nil
 }
+func (chassis *Chassis) PreProvisonONT(slotNumber int, portNumber int, ontNumber int, cTag uint32, sTag uint32, nasPortID string, circuitID string, techProfile string, speedProfile string) error {
+	if slotNumber > len(chassis.Slots) {
+		errorMsg := fmt.Sprintf("Invalid slot Number %d ", slotNumber)
+		return errors.New(errorMsg)
+	}
+	if portNumber > 16 {
+		errorMsg := fmt.Sprintf("Invalid port Number %d ", portNumber)
+		return errors.New(errorMsg)
+	}
+	if ontNumber > 64 {
+		errorMsg := fmt.Sprintf("Invalid ont Number %d ", ontNumber)
+		return errors.New(errorMsg)
+	}
+
+	err := chassis.Slots[slotNumber-1].Ports[portNumber-1].preProvisionOnt(ontNumber, cTag, sTag, nasPortID, circuitID, techProfile, speedProfile)
+	return err
+}
+func (chassis *Chassis) ActivateSerial(slotNumber int, portNumber int, ontNumber int, serialNumber string) error {
+	if slotNumber > len(chassis.Slots) {
+		errorMsg := fmt.Sprintf("Invalid slot Number %d ", slotNumber)
+		return errors.New(errorMsg)
+	}
+	if portNumber > 16 {
+		errorMsg := fmt.Sprintf("Invalid port Number %d ", portNumber)
+		return errors.New(errorMsg)
+	}
+	if ontNumber > 64 {
+		errorMsg := fmt.Sprintf("Invalid ont Number %d ", ontNumber)
+		return errors.New(errorMsg)
+	}
+
+	err := chassis.Slots[slotNumber-1].Ports[portNumber-1].activateSerial(ontNumber, serialNumber)
+	return err
+
+}
 func (chassis *Chassis) ActivateONTFull(slotNumber int, portNumber int, ontNumber int, serialNumber string, cTag uint32, sTag uint32, nasPortID string, circuitID string) error {
 	if slotNumber > len(chassis.Slots) {
 		errorMsg := fmt.Sprintf("Invalid slot Number %d ", slotNumber)
diff --git a/models/abstract/port.go b/models/abstract/port.go
index efb3054..da1e966 100644
--- a/models/abstract/port.go
+++ b/models/abstract/port.go
@@ -65,6 +65,30 @@
 	err := phyPort.ActivateOnt(ontNumber, ont.Svlan, ont.Cvlan, serialNumber, nasPortID, circuitID)
 	return err
 }
+func (port *Port) preProvisionOnt(ontNumber int, cTag uint32, sTag uint32, nasPortID string, circuitID string, techProfile string, speedProfile string) error {
+	slot := port.Parent
+
+	if port.PhysPort == nil {
+		chassis := slot.Parent
+		err := UnprovisonedPortError{oltNum: slot.Number, clli: chassis.CLLI, portNum: port.Number}
+		return &err
+	}
+	phyPort := port.PhysPort
+	err := phyPort.PreProvisionOnt(ontNumber, sTag, cTag, nasPortID, circuitID, techProfile, speedProfile)
+	return err
+}
+func (port *Port) activateSerial(ontNumber int, serialNumber string) error {
+	slot := port.Parent
+
+	if port.PhysPort == nil {
+		chassis := slot.Parent
+		err := UnprovisonedPortError{oltNum: slot.Number, clli: chassis.CLLI, portNum: port.Number}
+		return &err
+	}
+	phyPort := port.PhysPort
+	err := phyPort.ActivateSerial(ontNumber, serialNumber)
+	return err
+}
 func (port *Port) provisionOntFull(ontNumber int, serialNumber string, cTag uint32, sTag uint32, nasPortID string, circuitID string) error {
 	slot := port.Parent
 
diff --git a/models/physical/ont.go b/models/physical/ont.go
index 8c8949b..b262962 100644
--- a/models/physical/ont.go
+++ b/models/physical/ont.go
@@ -28,4 +28,6 @@
 	Active       bool     `json:",omitempty"`
 	NasPortID    string   `json:",omitempty"`
 	CircuitID    string   `json:",omitempty"`
+	TechProfile  string   `json:",omitempty"`
+	SpeedProfile string   `json:",omitempty"`
 }
diff --git a/models/physical/ponport.go b/models/physical/ponport.go
index 1064992..738d65e 100644
--- a/models/physical/ponport.go
+++ b/models/physical/ponport.go
@@ -65,6 +65,49 @@
 }
 
 /*
+PreProvisionOnt - passes ont information to chassis to make call to NEM to activate (whitelist) ont
+*/
+func (port *PONPort) PreProvisionOnt(number int, sVlan uint32, cVlan uint32, nasPortID string, circuitID string, techProfile string, speedProfile string) error {
+	slot := port.Parent
+	chassis := slot.Parent
+
+	if port.Onts[number-1].Active {
+		e := AllReadyActiveError{ontNumber: number, slotNum: slot.Number, ponportNum: port.Number, clli: chassis.CLLI}
+		return &e
+	}
+	ont := &port.Onts[number-1]
+	ont.Number = number
+	ont.Svlan = sVlan
+	ont.Cvlan = cVlan
+	ont.Parent = port
+	ont.NasPortID = nasPortID
+	ont.CircuitID = circuitID
+	ont.TechProfile = techProfile
+	ont.SpeedProfile = speedProfile
+	return nil
+}
+
+/*
+ActivateSerial - passes ont information to chassis to make call to NEM to activate (whitelist) ont assumes pre provisioned ont
+*/
+func (port *PONPort) ActivateSerial(number int, serialNumber string) error {
+	slot := port.Parent
+	chassis := slot.Parent
+
+	if port.Onts[number-1].Active {
+		e := AllReadyActiveError{ontNumber: number, slotNum: slot.Number, ponportNum: port.Number, clli: chassis.CLLI}
+		return &e
+	}
+	ont := port.Onts[number-1]
+	ont.SerialNumber = serialNumber
+	fmt.Println(ont)
+	port.Parent.Parent.provisionONT(ont)
+	port.Onts[number-1].Active = true
+	return nil
+
+}
+
+/*
 ActivateOnt - passes ont information to chassis to make call to NEM to activate (whitelist) ont
 */
 func (port *PONPort) ActivateOnt(number int, sVlan uint32, cVlan uint32, serialNumber string, nasPortID string, circuitID string) error {