@@ -2,25 +2,33 @@ package proxmox
22
33import (
44 "context"
5+ "crypto/tls"
56 "fmt"
7+ "net/http"
68
7- "github.com/sp-yduck/proxmox/pkg/service"
8- // "github.com/sp-yduck/proxmox/pkg/service/node/vm"
9+ "github.com/sp-yduck/proxmox-go/rest"
910 v1 "k8s.io/api/core/v1"
1011 cloudprovider "k8s.io/cloud-provider"
1112 "k8s.io/klog/v2"
1213)
1314
1415type instance struct {
15- compute * service. Service
16+ compute * rest. RESTClient
1617}
1718
1819func newInstances (config proxmoxConfig ) (cloudprovider.InstancesV2 , error ) {
19- svc , err := service .NewServiceWithLogin (config .URL , config .User , config .Password )
20+ base := & http.Client {
21+ Transport : & http.Transport {
22+ TLSClientConfig : & tls.Config {
23+ InsecureSkipVerify : true ,
24+ },
25+ },
26+ }
27+ client , err := rest .NewRESTClient (config .URL , rest .WithUserPassword (config .User , config .Password ), rest .WithClient (base ))
2028 if err != nil {
2129 return nil , err
2230 }
23- return & instance {compute : svc }, nil
31+ return & instance {compute : client }, nil
2432}
2533
2634func (i * instance ) InstanceExists (ctc context.Context , node * v1.Node ) (bool , error ) {
@@ -35,7 +43,7 @@ func (i *instance) InstanceShutdown(ctx context.Context, node *v1.Node) (bool, e
3543
3644func (i * instance ) InstanceMetadata (ctx context.Context , node * v1.Node ) (* cloudprovider.InstanceMetadata , error ) {
3745 providerID := fmt .Sprintf ("%s://%s" , ProviderName , node .Status .NodeInfo .SystemUUID )
38- klog .Infof ("initializing node %s with providerID=%s" , node .Name , providerID )
46+ klog .Infof ("getting metadata for node %s ( providerID=%s) " , node .Name , providerID )
3947 return & cloudprovider.InstanceMetadata {
4048 ProviderID : providerID ,
4149 NodeAddresses : []v1.NodeAddress {},
0 commit comments