Skip to content

Commit

Permalink
Merge pull request #36 from surajsub/master
Browse files Browse the repository at this point in the history
Port Update / Detach Update 1
  • Loading branch information
surajsub authored Jun 2, 2020
2 parents e80e70f + 36e355c commit 3e66961
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions clients/instance/ibm-pi-network.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,18 @@ func (f *IBMPINetworkClient) DeletePort(networkid string, powerinstanceid string

//Attach Port to the PVM Instance

func (f *IBMPINetworkClient) AttachPort(powerinstanceid, network_id, port_id string, networkparams *p_cloud_networks.PcloudNetworksPortsPutParams) (*models.NetworkPort, error) {
func (f *IBMPINetworkClient) AttachPort(powerinstanceid, network_id, port_id, description, pvminstanceid string) (*models.NetworkPort, error) {

params := p_cloud_networks.NewPcloudNetworksPortsPutParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithNetworkID(network_id).WithPortID(port_id).WithBody(networkparams.Body)
var body = models.NetworkPortUpdate{}
body.Description = &description
body.PvmInstanceID = &pvminstanceid
log.Printf("Attaching the port with id [%s] that belongs to cloud instance [%s] and networkid [%s] to the instance with id [%s]", port_id, powerinstanceid, network_id, pvminstanceid)
params := p_cloud_networks.NewPcloudNetworksPortsPutParamsWithTimeout(f.session.Timeout).WithCloudInstanceID(powerinstanceid).WithNetworkID(network_id).WithPortID(port_id).WithBody(&body)
resp, err := f.session.Power.PCloudNetworks.PcloudNetworksPortsPut(params, ibmpisession.NewAuth(f.session, powerinstanceid))

if err != nil {
log.Printf("Failed to attach the port to the pvminstance")
return nil, fmt.Errorf("Failed to attach the port [%s] to the pvminstance [%s]", port_id, networkparams.Body.PvmInstanceID)
return nil, fmt.Errorf("Failed to attach the port [%s] to the pvminstance [%s]", port_id, pvminstanceid)
}

return resp.Payload, nil
Expand Down

0 comments on commit 3e66961

Please sign in to comment.