Skip to content

Commit

Permalink
feat: Add publicip feature
Browse files Browse the repository at this point in the history
  • Loading branch information
David MICHENEAU committed Nov 21, 2023
1 parent 80e579b commit ece4415
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 40 deletions.
File renamed without changes.
7 changes: 7 additions & 0 deletions .changelog/3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:feature
`New publicip` - Add List, Create, Delete operations for publicip.
```

```release-note:dependency
deps: bumps cloudavenue-sdk-go from 1.5.5 to 1.5.6
```
51 changes: 14 additions & 37 deletions cmd/publicip.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func init() {

// ? Create command
publicipCmd.AddCommand(publicipCreateCmd)
publicipCreateCmd.PersistentFlags().String("name", "", "vdc name")
publicipCreateCmd.PersistentFlags().String("name", "", "edge gateway name")
if err := publicipCreateCmd.MarkPersistentFlagRequired("name"); err != nil {
log.Default().Println("Error from Flag name, is require.", err)
return
Expand Down Expand Up @@ -80,7 +80,7 @@ var publicipListCmd = &cobra.Command{
// deleteCmd represents the delete command
var publicipDelCmd = &cobra.Command{
Use: "delete",
Example: "publicip delete <name> [<name>] [<name>] ...",
Example: "publicip delete <ip> [<ip>] [<ip>] ...",
Short: "Delete publicip resource(s)",

Run: func(cmd *cobra.Command, args []string) {
Expand All @@ -89,12 +89,12 @@ var publicipDelCmd = &cobra.Command{
fmt.Println("delete publicip resource " + arg)
ip, err := c.V1.PublicIP.GetIP(arg)
if err != nil {
log.Default().Println("Error from ip", err)
log.Default().Println("Error from ip: ", err)
return
}
job, err := ip.Delete()
if err != nil {
log.Default().Println("Unable to delete ip", err)
log.Default().Println("Unable to delete ip: ", err)
return
}
err = job.Wait(15, 300)
Expand Down Expand Up @@ -125,45 +125,22 @@ var publicipCreateCmd = &cobra.Command{
return
}

// // Get EdgeGateway from name
// gw, err := c.V1.EdgeGateway.GetByName(gwName)
// if err != nil {
// log.Default().Println("EdgeGateway not found", err)
// return
// }

// Create the vdc
// Create a public ip
fmt.Println("create public ip resource")
fmt.Println("for EdgeGateway name: " + gwName)

// c.V1.EdgeGateway.

// _, err = c.V1.VDC.New(&v1.CAVVirtualDataCenter{Vdc: v1.CAVVirtualDataCenterVDC{
// Name: vdcName,
// ServiceClass: "STD",
// BillingModel: "PAYG",
// CPUAllocated: 22000,
// VcpuInMhz2: 2200,
// Description: "vdc created by cloudavenue-cli",
// MemoryAllocated: 30,
// DisponibilityClass: "ONE-ROOM",
// StorageBillingModel: "PAYG",
// StorageProfiles: []v1.VDCStrorageProfile{
// v1.VDCStrorageProfile{ //nolint
// Class: "gold",
// Limit: 500,
// Default: true,
// },
// },
// }})

job, err := c.V1.PublicIP.New(gwName)
if err != nil {
log.Default().Println("Error from vdc", err)
log.Default().Println("Unable to create public ip", err)
return
}

fmt.Println("vdc resource created successfully !")
fmt.Println("\nvdc resource list after creation:")
err = job.Wait(5, 300)
if err != nil {
log.Default().Println("Error during public ip creation !!", err)
return
}
fmt.Println("public ip resource created successfully !")
fmt.Println("\npublic ip resource list after creation:")
publicipListCmd.Run(cmd, []string{})

},
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21.3
require (
github.com/aws/aws-sdk-go v1.47.9
github.com/fbiville/markdown-table-formatter v0.3.0
github.com/orange-cloudavenue/cloudavenue-sdk-go v0.5.4-0.20231120154256-3c8c8c214b94
github.com/orange-cloudavenue/cloudavenue-sdk-go v0.5.6
github.com/spf13/cobra v1.8.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/orange-cloudavenue/cloudavenue-sdk-go v0.5.4-0.20231120154256-3c8c8c214b94 h1:6eVvqWBkrAT+7cPQImyACBdNPrEkYkm0A5FuUCQsTfw=
github.com/orange-cloudavenue/cloudavenue-sdk-go v0.5.4-0.20231120154256-3c8c8c214b94/go.mod h1:cWQdAHu+UlpulY0Vv4i+yPG17PUp8ZhK06VOR5Oq8iM=
github.com/orange-cloudavenue/cloudavenue-sdk-go v0.5.6 h1:S2miIutUXVRB4UTY0zOXa3xZujKLtOqLUCAOYzweoDw=
github.com/orange-cloudavenue/cloudavenue-sdk-go v0.5.6/go.mod h1:cWQdAHu+UlpulY0Vv4i+yPG17PUp8ZhK06VOR5Oq8iM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down

0 comments on commit ece4415

Please sign in to comment.