Beispiel #1
0
func cmdRm(c *cli.Context) {
	if len(c.Args()) == 0 {
		cli.ShowCommandHelp(c, "rm")
		fatal("You must specify a machine name")
	}

	force := c.Bool("force")
	store := getStore(c)

	for _, hostName := range c.Args() {
		h, err := loadHost(store, hostName)
		if err != nil {
			fatalf("Error removing host %q: %s", hostName, err)
		}
		if err := h.Driver.Remove(); err != nil {
			if !force {
				log.Errorf("Provider error removing machine %q: %s", hostName, err)
				continue
			}
		}

		if err := store.Remove(hostName); err != nil {
			log.Errorf("Error removing machine %q from store: %s", hostName, err)
		} else {
			log.Infof("Successfully removed %s", hostName)
		}
	}
}
func (d *Driver) Remove() error {
	s, err := d.GetState()
	if err != nil {
		if err == ErrMachineNotExist {
			log.Infof("machine does not exist, assuming it has been removed already")
			return nil
		}
		return err
	}
	if s == state.Running {
		if err := d.Stop(); err != nil {
			return err
		}
	}

	if err := d.removeDiskImage(); err != nil {
		return err
	}

	if d.NFSShare {
		log.Infof("Remove NFS share folder must be root. Please insert root password.")
		if _, err := nfsexports.Remove("", d.nfsExportIdentifier()); err != nil {
			log.Errorf("failed removing nfs share: %s", err.Error())
		}

		if err := nfsexports.ReloadDaemon(); err != nil {
			log.Errorf("failed reload nfs daemon: %s", err.Error())
		}
	}
	return nil
}
// SubmitDeploymentJobs api call to deployment jobs
func (c *ICSPClient) SubmitDeploymentJobs(dj DeploymentJobs) (jt *JobTask, err error) {
	log.Info("Applying OS Build plan for ICSP")
	var (
		uri  = "/rest/os-deployment-jobs"
		juri ODSUri
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	jt = jt.NewJobTask(c)
	jt.Reset()
	data, err := c.RestAPICall(rest.POST, uri, dj)
	if err != nil {
		jt.IsDone = true
		log.Errorf("Error submitting new build request: %s", err)
		return jt, err
	}

	log.Debugf("Response submit new os build plan job %s", data)
	if err := json.Unmarshal([]byte(data), &juri); err != nil {
		jt.IsDone = true
		jt.JobURI = juri
		log.Errorf("Error with task un-marshal: %s", err)
		return jt, err
	}
	jt.JobURI = juri

	return jt, err
}
func (c *I3SClient) UpdateGoldenImage(goldenImage GoldenImage) error {
	log.Infof("Initializing update of golden image for %s.", goldenImage.Name)
	var (
		uri = goldenImage.URI.String()
		t   *Task
	)

	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, goldenImage)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.PUT, uri, goldenImage)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting update golden image request: %s", err)
		return err
	}

	log.Debugf("Response update Golden Image %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	err = t.Wait()
	if err != nil {
		return err
	}

	return nil
}
func (c *OVClient) UpdateProfileTemplate(serverProfileTemplate ServerProfile) error {
	log.Infof("Initializing update of server profile template for %s.", serverProfileTemplate.Name)
	var (
		uri = serverProfileTemplate.URI.String()
		t   *Task
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewProfileTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, serverProfileTemplate)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.PUT, uri, serverProfileTemplate)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting update server profile template request: %s", err)
		return err
	}

	log.Debugf("Response update ServerProfileTemplate %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	err = t.Wait()
	if err != nil {
		return err
	}

	return nil
}
Beispiel #6
0
// submit new profile template
func (c *OVClient) SubmitDeleteProfile(p ServerProfile) (t *Task, err error) {
	var (
		uri = p.URI.String()
	// 	task = rest_api(:oneview, :post, '/rest/server-profiles', { 'body' => new_template_profile })
	)
	t = t.NewProfileTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, p)
	log.Debugf("task -> %+v", t)
	if uri == "" {
		log.Warn("Unable to post delete, no uri found.")
		t.TaskIsDone = true
		return t, err
	}
	data, err := c.RestAPICall(rest.DELETE, uri, nil)
	if err != nil {
		log.Errorf("Error submitting new profile request: %s", err)
		t.TaskIsDone = true
		return t, err
	}

	log.Debugf("Response delete profile %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return t, err
	}

	return t, err
}
func (c *I3SClient) CreatePlanScript(planScript PlanScript) error {
	log.Infof("Initializing creation of plan script for %s.", planScript.Name)
	var (
		uri                 = "/rest/plan-scripts"
		attemptedPlanScript *PlanScript
	)

	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	data, err := c.RestAPICall(rest.POST, uri, planScript)
	if err != nil {
		log.Errorf("Error submitting new plan script request: %s", err)
		return err
	}

	log.Debugf("Response New Plan Script %s", data)
	if err := json.Unmarshal([]byte(data), &attemptedPlanScript); err != nil {
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	if attemptedPlanScript.URI == "" {
		return fmt.Errorf("PlanScript not succesfully created")
	}

	return nil
}
func (c *OVClient) CreateEnclosureGroup(eGroup EnclosureGroup) error {
	log.Infof("Initializing creation of enclosure group for %s.", eGroup.Name)
	var (
		uri = "/rest/enclosure-groups"
		t   *Task
	)

	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewProfileTask(c)
	t.ResetTask()
	data, err := c.RestAPICall(rest.POST, uri, eGroup)
	if err != nil {
		log.Errorf("Error submitting new enclosure group request: %s", err)
		return err
	}

	log.Debugf("Response New EnclosureGroup %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	return nil
}
Beispiel #9
0
// IsActive provides a single function for determining if a host is active
// based on both the url and if the host is stopped.
func isActive(h *host.Host) (bool, error) {
	currentState, err := h.Driver.GetState()

	if err != nil {
		log.Errorf("error getting state for host %s: %s", h.Name, err)
		return false, err
	}

	url, err := h.GetURL()

	if err != nil {
		if err == drivers.ErrHostIsNotRunning {
			url = ""
		} else {
			log.Errorf("error getting URL for host %s: %s", h.Name, err)
			return false, err
		}
	}

	dockerHost := os.Getenv("DOCKER_HOST")

	notStopped := currentState != state.Stopped
	correctURL := url == dockerHost

	isActive := notStopped && correctURL

	return isActive, nil
}
Beispiel #10
0
func (c *OVClient) CreateFCNetwork(fcNet FCNetwork) error {
	log.Infof("Initializing creation of fc network for %s.", fcNet.Name)
	var (
		uri = "/rest/fc-networks"
		t   *Task
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewProfileTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, fcNet)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.POST, uri, fcNet)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting new fc network request: %s", err)
		return err
	}

	log.Debugf("Response New fcNetwork %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	err = t.Wait()
	if err != nil {
		return err
	}

	return nil
}
Beispiel #11
0
func attemptGetHostState(h *host.Host, stateQueryChan chan<- HostListItem) {
	currentState, err := h.Driver.GetState()
	if err != nil {
		log.Errorf("error getting state for host %s: %s", h.Name, err)
	}

	url, err := h.GetURL()
	if err != nil {
		if err == drivers.ErrHostIsNotRunning {
			url = ""
		} else {
			log.Errorf("error getting URL for host %s: %s", h.Name, err)
		}
	}

	active, err := isActive(h)
	if err != nil {
		log.Errorf("error determining if host is active for host %s: %s",
			h.Name, err)
	}

	stateQueryChan <- HostListItem{
		Name:         h.Name,
		Active:       active,
		DriverName:   h.Driver.DriverName(),
		State:        currentState,
		URL:          url,
		SwarmOptions: h.HostOptions.SwarmOptions,
	}
}
func (c *I3SClient) CreateArtifactsBundle(artifactsBundle InputArtifactsBundle) error {
	log.Infof("Initializing creation of artifactsBundle for %s.", artifactsBundle.Name)
	var (
		uri = "/rest/artifact-bundles"
		t   *Task
	)

	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, artifactsBundle)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.POST, uri, artifactsBundle)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting new artifacts bundle request: %s", err)
		return err
	}

	log.Debugf("Response New ArtifactsBundle %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	err = t.Wait()
	if err != nil {
		return err
	}

	return nil
}
Beispiel #13
0
func cmdRm(c CommandLine) error {
	if len(c.Args()) == 0 {
		c.ShowHelp()
		return errors.New("You must specify a machine name")
	}

	force := c.Bool("force")
	store := getStore(c)

	for _, hostName := range c.Args() {
		h, err := loadHost(store, hostName)
		if err != nil {
			return fmt.Errorf("Error removing host %q: %s", hostName, err)
		}

		if err := h.Driver.Remove(); err != nil {
			if !force {
				log.Errorf("Provider error removing machine %q: %s", hostName, err)
				continue
			}
		}

		if err := store.Remove(hostName); err != nil {
			log.Errorf("Error removing machine %q from store: %s", hostName, err)
		} else {
			log.Infof("Successfully removed %s", hostName)
		}
	}

	return nil
}
func (c *I3SClient) CreateDeploymentPlan(deploymentPlan DeploymentPlan) error {
	log.Infof("Initializing creation of deploymentPlan for %s.", deploymentPlan.Name)
	var (
		uri = "/rest/deployment-plans"
		t   *Task
	)

	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, deploymentPlan)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.POST, uri, deploymentPlan)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting new deployment plan request: %s", err)
		return err
	}

	log.Debugf("Response New DeploymentPlan %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	err = t.Wait()
	if err != nil {
		return err
	}

	return nil
}
// SubmitNewServer submit new profile template
func (c *ICSPClient) SubmitNewServer(sc ServerCreate) (jt *JobTask, err error) {
	log.Infof("Initializing creation of server for ICSP, %s.", sc.IPAddress)
	var (
		uri = "/rest/os-deployment-servers"
		// uri  = "/rest/os-deployment-ilos" //TODO: implement hidden api for server deploy that works in Houston
		juri ODSUri
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())
	// c.SetAuthHeaderOptions(c.GetAuthHeaderMapNoVer()) //TODO: only needed when using os-deployment-ilos

	jt = jt.NewJobTask(c)
	jt.Reset()
	data, err := c.RestAPICall(rest.POST, uri, sc)
	if err != nil {
		jt.IsDone = true
		log.Errorf("Error submitting new server request: %s", err)
		return jt, err
	}

	log.Debugf("Response submit new server %s", data)
	if err := json.Unmarshal([]byte(data), &juri); err != nil {
		jt.IsDone = true
		jt.JobURI = juri
		log.Errorf("Error with task un-marshal: %s", err)
		return jt, err
	}
	jt.JobURI = juri

	return jt, err
}
func (c *OVClient) UpdateEnclosureGroup(enclosureGroup EnclosureGroup) error {
	log.Infof("Initializing update of enclosure group for %s.", enclosureGroup.Name)
	var (
		uri = enclosureGroup.URI.String()
		t   *Task
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewProfileTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, enclosureGroup)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.PUT, uri, enclosureGroup)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting update enclosure group request: %s", err)
		return err
	}

	log.Debugf("Response update EnclosureGroup %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	return nil
}
Beispiel #17
0
// SubmitNewProfile - submit new profile template
func (c *OVClient) SubmitNewProfile(p ServerProfile) (t *Task, err error) {
	log.Infof("Initializing creation of server profile for %s.", p.Name)
	var (
		uri = "/rest/server-profiles"
	// 	task = rest_api(:oneview, :post, '/rest/server-profiles', { 'body' => new_template_profile })
	)
	t = t.NewProfileTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, p)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.POST, uri, p)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting new profile request: %s", err)
		return t, err
	}

	log.Debugf("Response NewProfile %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return t, err
	}

	return t, err
}
Beispiel #18
0
// Submit desired power state
func (pt *PowerTask) SubmitPowerState(s PowerState) {
	if err := pt.GetCurrentPowerState(); err != nil {
		pt.TaskIsDone = true
		log.Errorf("Error getting current power state: %s", err)
		return
	}
	if s != pt.State {
		log.Infof("Powering %s server %s for %s.", s, pt.Blade.Name, pt.Blade.SerialNumber)
		var (
			body = PowerRequest{PowerState: s.String(), PowerControl: P_PRESSANDHOLD.String()}
			uri  = strings.Join([]string{pt.Blade.URI.String(),
				"/powerState"}, "")
		)
		log.Debugf("REST : %s \n %+v\n", uri, body)
		log.Debugf("pt -> %+v", pt)
		data, err := pt.Blade.Client.RestAPICall(rest.PUT, uri, body)
		if err != nil {
			pt.TaskIsDone = true
			log.Errorf("Error with power state request: %s", err)
			return
		}

		log.Debugf("SubmitPowerState %s", data)
		if err := json.Unmarshal([]byte(data), &pt); err != nil {
			pt.TaskIsDone = true
			log.Errorf("Error with power state un-marshal: %s", err)
			return
		}
	} else {
		log.Infof("Desired Power State already set -> %s", pt.State)
		pt.TaskIsDone = true
	}

	return
}
func (c *OVClient) CreateStorageVolume(sVol StorageVolumeV3) error {
	log.Infof("Initializing creation of storage volume for %s.", sVol.Name)
	var (
		uri = "/rest/storage-volumes"
		t   *Task
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	t = t.NewProfileTask(c)
	t.ResetTask()
	log.Debugf("REST : %s \n %+v\n", uri, sVol)
	log.Debugf("task -> %+v", t)
	data, err := c.RestAPICall(rest.POST, uri, sVol)
	if err != nil {
		t.TaskIsDone = true
		log.Errorf("Error submitting new storage volume request: %s", err)
		return err
	}

	log.Debugf("Response New StorageVolume %s", data)
	if err := json.Unmarshal([]byte(data), &t); err != nil {
		t.TaskIsDone = true
		log.Errorf("Error with task un-marshal: %s", err)
		return err
	}

	err = t.Wait()
	if err != nil {
		return err
	}

	return nil
}
func (d *Driver) importVdi(vdi *xsclient.VDI, filename string, timeout time.Duration) error {
	f, err := os.Open(filename)
	if err != nil {
		log.Errorf("Unable to open disk image '%s': %v", filename, err)
		return err
	}

	// Get file length
	fi, err := f.Stat()
	if err != nil {
		log.Errorf("Unable to stat disk image '%s': %v", filename, err)
		return err
	}

	task, err := vdi.Client.CreateTask()
	if err != nil {
		return fmt.Errorf("Unable to create task: %v", err)
	}
	urlStr := fmt.Sprintf("https://%s/import_raw_vdi?vdi=%s&session_id=%s&task_id=%s",
		vdi.Client.Host, vdi.Ref, vdi.Client.Session.(string), task.Ref)

	// Define a new http Transport which allows self-signed certs
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}

	req, err := http.NewRequest("PUT", urlStr, f)
	if err != nil {
		return err
	}
	req.ContentLength = fi.Size()

	resp, err := tr.RoundTrip(req)
	if err != nil {
		log.Errorf("Unable to upload VDI: %v", err)
		return err
	}
	defer resp.Body.Close()

	if resp.StatusCode != 200 {
		msg, _ := ioutil.ReadAll(resp.Body)
		err = fmt.Errorf("xenserver reply %s: %v", resp.Status, string(msg))
		log.Errorf("Unable to upload VDI: %v", err)
		return err
	}

	log.Infof("Waiting Upload VDI task(%v) to complete...", task.Ref)
	if err = d.waitTask(task, timeout); err != nil {
		return err
	}
	return nil
}
Beispiel #21
0
func (d *Driver) Remove() error {
	log.Infof("%s | Remove instance %s ...", d.MachineName, d.InstanceId)

	if d.InstanceId == "" {
		return fmt.Errorf("%s | Unknown instance id", d.MachineName)
	}

	s, err := d.GetState()
	if err == nil && s == state.Running {
		if err := d.Stop(); err != nil {
			log.Errorf("%s | Unable to removed the instance %s: %s", d.MachineName, d.InstanceId, err)
		}
	}

	instance, err := d.getInstance()
	if err != nil {
		log.Errorf("%s | Unable to describe the instance %s: %s", d.MachineName, d.InstanceId, err)
	} else {
		// Check and release EIP if exists
		if len(instance.EipAddress.AllocationId) != 0 {

			allocationId := instance.EipAddress.AllocationId

			err = d.getClient().UnassociateEipAddress(allocationId, instance.InstanceId)
			if err != nil {
				log.Errorf("%s | Failed to unassociate EIP address from instance %s: %v", d.MachineName, d.InstanceId, err)
			}
			err = d.getClient().WaitForEip(instance.RegionId, allocationId, ecs.EipStatusAvailable, 0)
			if err != nil {
				log.Errorf("%s | Failed to wait EIP %s available: %v", d.MachineName, allocationId, err)
			}
			err = d.getClient().ReleaseEipAddress(allocationId)
			if err != nil {
				log.Errorf("%s | Failed to release EIP address: %v", d.MachineName, err)
			}
		}
		log.Debugf("%s | instance.VpcAttributes: %++v\n", d.MachineName, instance.VpcAttributes)

		vpcId := instance.VpcAttributes.VpcId
		if vpcId != "" {
			// Remove route entry firstly
			d.removeRouteEntry(vpcId, instance.RegionId, instance.InstanceId)
		}
	}

	log.Infof("%s | Deleting instance: %s", d.MachineName, d.InstanceId)
	if err := d.getClient().DeleteInstance(d.InstanceId); err != nil {
		return fmt.Errorf("%s | Unable to delete instance %s: %s", d.MachineName, d.InstanceId, err)
	}
	return nil
}
// SaveServer save Server, submit new profile template
func (c *ICSPClient) SaveServer(s Server) (o Server, err error) {
	log.Infof("Saving server attributes for %s.", s.Name)
	var (
		uri = s.URI
	)
	// refresh login
	c.RefreshLogin()
	c.SetAuthHeaderOptions(c.GetAuthHeaderMap())

	log.Debugf("name -> %s, description -> %s", s.Name, s.Description)
	log.Debugf("CustomAttributes -> %+v", s.CustomAttributes)

	sc := s.Clone()

	log.Debugf("options -> %+v", c.Option)
	log.Debugf("REST : %s \n %+v\n", uri, sc)
	data, err := c.RestAPICall(rest.PUT, uri.String(), sc)
	if err != nil {
		log.Errorf("Error submitting new server request: %s", err)
		return o, err
	}
	if err := json.Unmarshal([]byte(data), &o); err != nil {
		return o, err
	}

	return o, err
}
func (c *I3SClient) DeletePlanScript(name string) error {
	var (
		planScript PlanScript
		err        error
		uri        string
	)

	planScript, err = c.GetPlanScriptByName(name)
	if err != nil {
		return err
	}
	if planScript.Name != "" {
		log.Debugf("REST : %s \n %+v\n", planScript.URI, planScript)
		uri = planScript.URI.String()
		if uri == "" {
			log.Warn("Unable to post delete, no uri found.")
			return err
		}
		_, err := c.RestAPICall(rest.DELETE, uri, nil)
		if err != nil {
			log.Errorf("Error submitting delete plan script request: %s", err)
			return err
		}
	} else {
		log.Infof("Plan script could not be found to delete, %s, skipping delete ...", name)
	}
	return nil
}
// UnMarshall json to data
func (tc *TestConfig) UnMarshallTestingConfig(json_data []byte) {
	tc.Cases = []TestCases{}
	if err := json.Unmarshal(json_data, &tc); err != nil {
		log.Errorf("Error with un-marshalling test config data: %s", err)
		os.Exit(1)
	}
}
func (dj DeploymentJobs) NewDeploymentJobs(bp []OSDBuildPlan, bpdata *OSDPersonalityDataV2, servers []Server) DeploymentJobs {
	var bpURI []string
	var sd []OSDPersonalizeServerDataV2

	for _, plan := range bp {
		bpURI = append(bpURI, plan.URI.String())
	}

	for _, s := range servers {
		var pd OSDPersonalizeServerDataV2
		if s.URI.IsNil() {
			log.Errorf("Unable to create new server deployment with nil server refrence.")
		}
		pd = OSDPersonalizeServerDataV2{
			ServerURI: s.URI.String(),
		}
		if bpdata != nil {
			pd.PersonalityData = bpdata
		}
		sd = append(sd, pd)
	}

	return DeploymentJobs{
		OsbpUris:   bpURI,
		ServerData: sd,
	}
}
Beispiel #26
0
func (d *Driver) Start() error {
	if err := d.getClient().StartInstance(d.InstanceId); err != nil {
		log.Errorf("%s | Failed to start instance %s: %v", d.MachineName, d.InstanceId, err)
		return err
	}

	// Wait for running
	err := d.getClient().WaitForInstance(d.InstanceId, ecs.Running, timeout)

	if err != nil {
		log.Errorf("%s | Failed to wait instance %s running: %v", d.MachineName, d.InstanceId, err)
		return err
	}

	return nil
}
Beispiel #27
0
// get a test driver for acceptance testing
func getTestDriverA(env string) (*OVTest, *OVClient) {
	// os.Setenv("DEBUG", "true")  // remove comment to debug logs
	var ot *OVTest
	var tc *testconfig.TestConfig
	ot = &OVTest{Tc: tc.NewTestConfig(), Env: env}
	ot.GetEnvironment(env)
	ot.Tc.GetTestingConfiguration(os.Getenv("ONEVIEW_TEST_DATA"))
	ot.Client = &OVClient{
		rest.Client{
			User:     os.Getenv("ONEVIEW_OV_USER"),
			Password: os.Getenv("ONEVIEW_OV_PASSWORD"),
			Domain:   os.Getenv("ONEVIEW_OV_DOMAIN"),
			Endpoint: os.Getenv("ONEVIEW_OV_ENDPOINT"),
			// ConfigDir:
			SSLVerify: false,
			APIKey:    "none",
		},
	}
	err := ot.Client.RefreshVersion()
	if err != nil {
		log.Errorf("Problem with getting api version refreshed : %+v", err)
	}
	// fmt.Println("Setting up test with getTestDriverA")
	return ot, ot.Client
}
Beispiel #28
0
func (d *Driver) Stop() error {
	if err := d.getClient().StopInstance(d.InstanceId, false); err != nil {
		log.Errorf("%s | Failed to stop instance %s: %v", d.MachineName, d.InstanceId, err)
		return err
	}

	// Wait for stopped
	err := d.getClient().WaitForInstance(d.InstanceId, ecs.Stopped, timeout)

	if err != nil {
		log.Errorf("%s | Failed to wait instance %s stopped: %v", d.MachineName, d.InstanceId, err)
		return err
	}

	return nil
}
// workstationDataFilePaths returns a list of paths that are eligible
// to contain data files we may want such as vmnet NAT configuration files.
func workstationDataFilePaths() []string {
	leasesPath, err := workstationDhcpLeasesPathRegistry()
	if err != nil {
		log.Errorf("Error getting DHCP leases path: %s", err)
	}

	if leasesPath != "" {
		leasesPath = filepath.Dir(leasesPath)
	}

	paths := make([]string, 0, 5)
	if os.Getenv("VMWARE_DATA") != "" {
		paths = append(paths, os.Getenv("VMWARE_DATA"))
	}

	if leasesPath != "" {
		paths = append(paths, leasesPath)
	}

	if os.Getenv("ProgramData") != "" {
		paths = append(paths,
			filepath.Join(os.Getenv("ProgramData"), "/VMware"))
	}

	if os.Getenv("ALLUSERSPROFILE") != "" {
		paths = append(paths,
			filepath.Join(os.Getenv("ALLUSERSPROFILE"), "/Application Data/VMware"))
	}

	return paths
}
// workstationProgramFilesPaths returns a list of paths that are eligible
// to contain program files we may want just as vmware.exe.
func workstationProgramFilePaths() []string {
	path, err := workstationVMwareRoot()
	if err != nil {
		log.Errorf("Error finding VMware root: %s", err)
	}

	paths := make([]string, 0, 5)
	if os.Getenv("VMWARE_HOME") != "" {
		paths = append(paths, os.Getenv("VMWARE_HOME"))
	}

	if path != "" {
		paths = append(paths, path)
	}

	if os.Getenv("ProgramFiles(x86)") != "" {
		paths = append(paths,
			filepath.Join(os.Getenv("ProgramFiles(x86)"), "/VMware/VMware Workstation"))
	}

	if os.Getenv("ProgramFiles") != "" {
		paths = append(paths,
			filepath.Join(os.Getenv("ProgramFiles"), "/VMware/VMware Workstation"))
	}

	return paths
}