-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from dell/feature/replication
CSM Replication Support For PowerScale
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package v11 | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/dell/goisilon/api" | ||
) | ||
|
||
const ( | ||
policiesPath = "/platform/11/sync/policies/" | ||
) | ||
|
||
// Policy contains the CloudIQ policy info. | ||
type Policy struct { | ||
Action string `json:"action,omitempty"` | ||
Id string `json:"id,omitempty"` | ||
Name string `json:"name,omitempty"` | ||
Enabled bool `json:"enabled,omitempty"` | ||
TargetPath string `json:"target_path,omitempty"` | ||
SourcePath string `json:"source_root_path,omitempty"` | ||
TargetHost string `json:"target_host,omitempty"` | ||
JobDelay int `json:"job_delay,omitempty"` | ||
Schedule string `json:"schedule,omitempty"` | ||
} | ||
|
||
type Policies struct { | ||
Policy []Policy `json:"policies,omitempty"` | ||
} | ||
|
||
// GetPolicyByName returns policy by name | ||
func GetPolicyByName( | ||
ctx context.Context, | ||
client api.Client, name string) (policy *Policy, err error) { | ||
p := &Policies{} | ||
err = client.Get(ctx, policiesPath, name, nil, nil, &p) | ||
if err != nil { | ||
return nil, err | ||
} else if len(p.Policy) == 0 { | ||
return nil, fmt.Errorf("successful code returned, but policy %s not found", name) | ||
} | ||
return &p.Policy[0], nil | ||
} | ||
|
||
func CreatePolicy(ctx context.Context, client api.Client, name string, sourcePath string, targetPath string, targetHost string, rpo int) error { | ||
resp := "" | ||
body := &Policy{ | ||
Action: "sync", | ||
Id: "", | ||
Name: name, | ||
Enabled: true, | ||
TargetPath: targetPath, | ||
SourcePath: sourcePath, | ||
TargetHost: targetHost, | ||
JobDelay: rpo, | ||
Schedule: "when-source-modified", | ||
} | ||
return client.Post(ctx, policiesPath, "", nil, nil, body, resp) | ||
} | ||
|
||
func DeletePolicy(ctx context.Context, client api.Client, name string) error { | ||
resp := "" | ||
return client.Delete(ctx, policiesPath, name, nil, nil, &resp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package goisilon | ||
|
||
import ( | ||
"context" | ||
apiv11 "github.com/dell/goisilon/api/v11" | ||
) | ||
|
||
// Policy is an Isilon Policy | ||
type Policy *apiv11.Policy | ||
|
||
// GetPolicyByName returns a policy with the provided ID. | ||
func (c *Client) GetPolicyByName(ctx context.Context, id string) (Policy, error) { | ||
return apiv11.GetPolicyByName(ctx,c.API,id) | ||
} | ||
|
||
func (c *Client) CreatePolicy(ctx context.Context, name string, rpo int, sourcePath string, targetPath string, targetHost string) error{ | ||
return apiv11.CreatePolicy(ctx,c.API,name,sourcePath,targetPath,targetHost,rpo) | ||
} | ||
|
||
func (c *Client) DeletePolicy(ctx context.Context, name string) error{ | ||
return apiv11.DeletePolicy(ctx,c.API,name) | ||
} |