Skip to content
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

register vmware source functionality #2

Open
wants to merge 15 commits into
base: development
Choose a base branch
from
Open

Conversation

anvesh-cohesity
Copy link
Contributor

No description provided.

cohesity/resource_cohesity_source_vmware.go Show resolved Hide resolved
cohesity/resource_cohesity_source_vmware.go Show resolved Hide resolved
cohesity/resource_cohesity_source_vmware.go Outdated Show resolved Hide resolved
cohesity/resource_cohesity_source_vmware.go Show resolved Hide resolved
cohesity/resource_cohesity_source_vmware.go Outdated Show resolved Hide resolved
cohesity/resource_cohesity_source_vmware.go Outdated Show resolved Hide resolved
@pyashish
Copy link
Contributor

LGTM

@pyashish
Copy link
Contributor

@ggCohesity can you review this please ?

@ggCohesity
Copy link

ggCohesity commented Dec 18, 2019 via email

Copy link
Contributor

@pyashish pyashish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need some changes.

cohesity/resource_cohesity_job_vmware.go Outdated Show resolved Hide resolved
cohesity/resource_cohesity_job_vmware.go Outdated Show resolved Hide resolved
cohesity/resource_cohesity_job_vmware.go Show resolved Hide resolved
cohesity/resource_cohesity_job_vmware.go Show resolved Hide resolved
Copy link
Contributor

@pyashish pyashish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questions.

return nil
}

func resourceCohesityJobRunUpdate(resourceData *schema.ResourceData, configMetaData interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update only means increasing snapshot retention right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, for now we are supporting only start and stop the run

return nil
}

func resourceCohesityJobRunDelete(resourceData *schema.ResourceData, configMetaData interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be cancel job run ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the cancel is based on the state user provides, its is done in either create/update function, the delete or terraform destroy wouldn't delete/stop the run

Description: `Specifies the time to wait in minutes for the protection job run
to complete the run or stop the run`,
},
"timestamp": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are we populating this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is given by the user, in the configuration the user has to use an existing terraform function timestamp()

}
//start or stop the job run and wait for completion or operation timeout
if resourceData.Get("state").(string) == "start" {
if len(response) == 0 || (response[0].BackupRun.Status != models.StatusBackupRun_KACCEPTED && response[0].BackupRun.Status != models.StatusBackupRun_KRUNNING) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reduce line length. Go doesn't have any ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed this in the later commit

requestParams.RunType = models.RunTypeRunProtectionJobParam_KSYSTEM
}
err = client.ProtectionJobs().CreateRunProtectionJob(jobID, &requestParams)
time.Sleep(30 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wait here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is the situation I faced, for a newly created protection job without any runs, when we trigger a run and try to get the runs for that job with get runs call, this return empty. It takes time, (race condition). I will reduce the wait time to 2-5 secs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sounds good.

}
}
for timeout > 0 {
log.Printf("[INFO] Wait for protection job (%s) run completion", jobName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a global/user configurable ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its user configurable, the operation_timeout argument can be used to configure this

}
}

func jobStartStopUtil(resourceData *schema.ResourceData, configMetaData interface{}) (*int64, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are we stopping the run ?

Copy link
Contributor Author

@anvesh-cohesity anvesh-cohesity Jan 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in create and update functions, based on the state the user provides, we start or stop the run

return nil, errors.New("Failed to authenticate with Cohesity")
}

timeout := resourceData.Get("operation_timeout").(int) * WaitTimeToSeconds
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this declared ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WaitTimeToSeconds is there in config.go

Description: `Specifies the time of the protection job run.
Should be in the format YYYY-MM-DD HH:MM Area/Location`,
},
"vm_names": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just make sure we have handled duplicate names scenario.

ForceNew: true,
Description: "Specifies the environment where the protected source exists",
},
"operation_timeout": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is with assumption that restore would complete within 2 hours ? can you check with Magneto team once ?

case "VMware":
environment = models.EnvironmentGetRestoreTasks_KVMWARE
case "HyperV":
environment = models.EnvironmentGetRestoreTasks_KHYPERV
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its better to have separate restores for VMWare and HyperV ? since we'll have different parameter set for each.

cohesity/resource_cohesity_restore_vm.go Outdated Show resolved Hide resolved
cohesity/resource_cohesity_restore_vm.go Outdated Show resolved Hide resolved
[]int64{protectionJobID}, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
if err != nil {
log.Printf(err.Error())
return nil, fmt.Errorf("Error in getting the snapshot object for vm %s", vmName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Getting snapshot information for 1 VM fails, then all the VMs fail? In actual product I think 1 VM is skipped no ?

cohesity/resource_cohesity_restore_vm.go Outdated Show resolved Hide resolved
for _, snapshotObjectVersion := range snapshotObject.Versions {
backupDateTime := strings.Split(time.Unix((*snapshotObjectVersion.
StartedTimeUsecs)/epochTimestampToSeconds, 0).In(location).String(), " ")
if backupDateTime[0]+" "+backupDateTime[1][:5] == userDateTime[0]+" "+userDateTime[1] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about scenario where some vms dont have a snapshot in the backuptimestamp, and some do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we fail the complete restore operation

cohesity/resource_cohesity_restore_vm.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants