-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ports list command implementation - PowerVS #1084
Conversation
|
✅ Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Welcome @Niharika0306! |
Hi @Niharika0306. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
fe6ae4f
to
4dbc352
Compare
4dbc352
to
aadb731
Compare
aadb731
to
630d931
Compare
/ok-to-test |
log.Info("Listing PowerVS ports", "service-instance-id", options.GlobalOptions.ServiceInstanceID, "network", network) | ||
|
||
auth := iam.GetIAMAuth() | ||
accountID, _ := utils.GetAccountID(ctx, auth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we handle the error here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
e64c85c
to
692fa89
Compare
b879221
to
2aa3995
Compare
/lgtm |
Example: ` | ||
# List ports in PowerVS Network | ||
export IBMCLOUD_API_KEY=<api-key> | ||
capibmadm powervs port list --service-instance-id <service-instance-id> --zone <zone> --network <network ID or name>`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capibmadm powervs port list --service-instance-id <service-instance-id> --zone <zone> --network <network ID or name>`, | |
capibmadm powervs port list --service-instance-id <service-instance-id> --zone <zone> --network <network-name/network-id>`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
#### Example: | ||
```shell | ||
export IBMCLOUD_API_KEY=<api-key> | ||
capibmadm powervs port list --service-instance-id <service-instance-id> --zone <zone> --network <network> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capibmadm powervs port list --service-instance-id <service-instance-id> --zone <zone> --network <network> | |
capibmadm powervs port list --service-instance-id <service-instance-id> --zone <zone> --network <network-name/network-id> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
16d598b
to
8fdebd3
Compare
8fdebd3
to
39d0ea3
Compare
/lgtm |
networks, err := networkClient.GetAll() | ||
if err != nil { | ||
return fmt.Errorf("failed to get the networks, err: %v", err) | ||
} | ||
|
||
var netID string | ||
|
||
for _, net := range networks.Networks { | ||
if *net.Name == network || *net.NetworkID == network { | ||
netID = *net.NetworkID | ||
break | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to perform this heavy operation? If I am not wrong just Get() on the network would return you 404
if does not exist.
@Prajyot-Parab
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Get call works even with name
|
||
var network string | ||
|
||
cmd.Flags().StringVar(&network, "network", "", "Network ID or Name(preference will be given to the ID over Name)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO there is no point of preference here if you can use the Get API to validate the network. Even the port list works with id
or name
.
return fmt.Errorf("not able to find network: \"%s\" by ID or name in the network list", network) | ||
} | ||
|
||
portListResp, err := networkClient.GetAllPorts(netID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works with both id and name, hence suggest you to use network
directly here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a snippet of GetAllPorts
func, seems it expects WithNetworkID(id)
@yussufsh am i missing anything here?
// Get All Ports on a Network
func (f *IBMPINetworkClient) GetAllPorts(id string) (*models.NetworkPorts, error) {
params := p_cloud_networks.NewPcloudNetworksPortsGetallParams().
WithContext(f.ctx).WithTimeout(helpers.PIGetTimeOut).
WithCloudInstanceID(f.cloudInstanceID).WithNetworkID(id)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried running the curl command with network name as well. It works for network port object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# network_id=ocp-net
# curl -X GET https://syd.power-iaas.cloud.ibm.com/pcloud/v1/cloud-instances/${CLOUD_INSTANCE_ID}/networks/${network_id}/ports -H 'Authorization: Bearer <token>' -H 'CRN:<crn>' -H 'Content-Type: application/json'
{"ports":[{"description":"","href":"/pcloud/v1/cloud-instances/<snipped>/networks/2c24ec46-96d2-4dd9-a3f0-f1f96c7e4342/ports/644863e1-2f97-4339-8ec1-3378490a0cf1","ipAddress":"192.168.200.156","macAddress":"fa:19:9e:27:fb:20","portID":"644863e1-2f97-4339-8ec1-3378490a0cf1","pvmInstance":{"href":"/pcloud/v1/cloud-instances/<snipped>/pvm-instances/b687cd71-313d-41df-bfa5-b5f04c5e4575","pvmInstanceID":"b687cd71-313d-41df-bfa5-b5f04c5e4575"},"status":"DOWN"}]}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yussufsh this ain't working via code, am I on right track here?
prajyotparab@Prajyots-MacBook-Pro capibmadm % ./capibmadm powervs port list --service-instance-id 3229a94c-af54-4212-bf60-6202b6fd0a07 --zone osa21 --network capi-test --debug
Listing PowerVS ports service-instance-id="3229a94c-af54-4212-bf60-6202b6fd0a07" network="capi-test"
GET /pcloud/v1/cloud-instances/3229a94c-af54-4212-bf60-6202b6fd0a07/networks/capi-test/ports HTTP/1.1
Host: osa.power-iaas.cloud.ibm.com
User-Agent: Go-http-client/1.1
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Crn: crn:v1:bluemix:public:power-iaas:osa21:a/c265c8cefda241ca9c107adcbbacaa84:3229a94c-af54-4212-bf60-6202b6fd0a07::
Accept-Encoding: gzip
HTTP/2.0 500 Internal Server Error
Content-Length: 448
Cf-Cache-Status: DYNAMIC
Cf-Ray: 797483d70c1c855b-BOM
Content-Type: application/json
Date: Fri, 10 Feb 2023 11:30:51 GMT
Server: cloudflare
Strict-Transport-Security: max-age=15724800; includeSubDomains
{"description":"unable to get network 9906818c-4ad1-4cd9-b6ca-bba776f2a22d: unable to get network for 9906818c-4ad1-4cd9-b6ca-bba776f2a22d: Resource not found: [GET https://192.168.40.140:9696/v2.0/networks/9906818c-4ad1-4cd9-b6ca-bba776f2a22d], error message: {\"NeutronError\": {\"type\": \"NetworkNotFound\", \"message\": \"Network 9906818c-4ad1-4cd9-b6ca-bba776f2a22d could not be found.\", \"detail\": \"\"}}","error":"internal server error"}
Error: failed to Get all Network Ports for Network capi-test: [GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}/ports][500] pcloudNetworksPortsGetallInternalServerError &{Code:0 Description:unable to get network 9906818c-4ad1-4cd9-b6ca-bba776f2a22d: unable to get network for 9906818c-4ad1-4cd9-b6ca-bba776f2a22d: Resource not found: [GET https://192.168.40.140:9696/v2.0/networks/9906818c-4ad1-4cd9-b6ca-bba776f2a22d], error message: {"NeutronError": {"type": "NetworkNotFound", "message": "Network 9906818c-4ad1-4cd9-b6ca-bba776f2a22d could not be found.", "detail": ""}} Error:internal server error Message:}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per @yussufsh's comments, the GetAllPorts command works with network name too. Hence removed the GetAllNetworks call ( and passing network argument directly to portList call) and just running the get network with id/name to check if network exists and capturing the error.
$ ./capibmadm powervs port list --service-instance-id "b9db6009-30fc-4718-98cb-16ba6fd37b82" --zone mon01 --network rdr-acm-spoke2-411-mon01-pub-net
Listing PowerVS ports service-instance-id="b9db6009-30fc-4718-98cb-16ba6fd37b82" network="rdr-acm-spoke2-411-mon01-pub-net"
DESCRIPTION EXTERNAL IP IP ADDRESS MAC ADDRESS PORT ID STATUS
169.54.110.91 192.168.164.91 fa:d4:c3:31:24:20 19712105-d5be-4e97-9fc1-d9f49300ddf9 ACTIVE
$ ./capibmadm powervs port list --service-instance-id "b9db6009-30fc-4718-98cb-16ba6fd37b82" --zone mon01 --network Temp
Listing PowerVS ports service-instance-id="b9db6009-30fc-4718-98cb-16ba6fd37b82" network="Temp"
Error: failed to perform Get Network Operation for Network id Temp with error [GET /pcloud/v1/cloud-instances/{cloud_instance_id}/networks/{network_id}][404] pcloudNetworksGetNotFound &{Code:0 Description:item not found: unable to get network, subnet, and possibly public network cidr for network Temp on cloud instance 914b05caac05408694e562586a65478b Error:item not found Message:}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. @Prajyot-Parab makes sense?
39d0ea3
to
eecccd3
Compare
eecccd3
to
0f787eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
PTAL @Karthik-K-N |
0f787eb
to
a3969a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mkumatag, Niharika0306, Prajyot-Parab The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it:
This PR is for listing ports from PowerVC
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
/area provider/ibmcloud
Release note: