Ejemplo n.º 1
0
func testDeleteVCH(v *validate.Validator, conf *config.VirtualContainerHostConfigSpec, t *testing.T) {
	d := &Dispatcher{
		session: v.Session,
		ctx:     v.Context,
		isVC:    v.Session.IsVC(),
		force:   false,
	}
	// failed to get vm FolderName, that will eventually cause panic in simulator to delete empty datastore file
	if err := d.DeleteVCH(conf); err != nil {
		t.Errorf("Failed to get VCH: %s", err)
		return
	}
	t.Logf("Successfully deleted VCH")
	// check images directory is removed
	_, err := d.lsFolder(v.Session.Datastore, "VIC")
	if err != nil {
		// FIXME: simulator didn't return FileNotFound error here
		//		if !types.IsFileNotFound(err) {
		//			t.Errorf("Failed to browse folder %s: %s", "VIC", errors.ErrorStack(err))
		//			return
		//		}
		t.Logf("Images Folder is not found")
	}

	// check appliance vm is deleted
	vm, err := d.findApplianceByID(conf)
	if vm != nil {
		t.Errorf("Should not found vm %s", vm.Reference())
	}
	// FIXME: simulator didn't return NotFoundError
	//	if err != nil {
	//		t.Errorf("Unexpected error to get appliance VM: %s", err)
	//	}
	// delete VM does not clean up resource pool after VM is removed, so resource pool could not be removed
}
Ejemplo n.º 2
0
// retrieves the uuid of the appliance vm to create a unique vsphere extension name
func (d *Dispatcher) GenerateExtensionName(conf *metadata.VirtualContainerHostConfigSpec) error {
	defer trace.End(trace.Begin(conf.ExtensionName))

	// must be called after appliance VM is created
	vm, err := d.findAppliance(conf)

	if err != nil {
		return errors.Errorf("Could not find appliance at extension creation time; failed with error: %s", err)
	}

	var o mo.VirtualMachine
	err = vm.Properties(d.ctx, vm.Reference(), []string{"config.uuid"}, &o)
	if err != nil {
		return errors.Errorf("Could not get VM UUID from appliance VM due to error: %s", err)
	}

	conf.ExtensionName = "com.vmware.vic." + o.Config.Uuid
	return nil
}