I'm trying to use the InitiateFileTransferToGuest method to send a file to a VM. Unfortunately, I'm getting stuck. Here's the related code where VClient is the VimClient with an already successfull connection:
GuestOperationsManager VMOpsManager = new GuestOperationsManager(VClient, VClient.ServiceContent.GuestOperationsManager);
GuestFileManager VMFileManager = new GuestFileManager(VClient, VClient.ServiceContent.FileManager);
GuestAuthManager VMAuthManager = new GuestAuthManager(VClient, VClient.ServiceContent.AuthorizationManager);
NamePasswordAuthentication Auth = new NamePasswordAuthentication()
{
Username = "username",
Password = "password",
InteractiveSession = false
};
VMAuthManager.ValidateCredentialsInGuest(CurrentVM.MoRef, Auth);
System.IO.FileInfo FileToTransfer = new System.IO.FileInfo("C:\\userlist.txt");
GuestFileAttributes GFA = new GuestFileAttributes()
{
AccessTime = FileToTransfer.LastAccessTimeUtc,
ModificationTime = FileToTransfer.LastWriteTimeUtc
};
string TransferOutput = VMFileManager.InitiateFileTransferToGuest(CurrentVM.MoRef, Auth, "C:\\userlist.txt", GFA, FileToTransfer.Length, false);
First error shows up when getting to the ValidateCredentialsInGuest method. I get this message:
An unhandled exception of type 'VMware.Vim.VimException' occurred in VMware.Vim.dll Additional information: The request refers to an unexpected or unknown type.
If I remove that validation, I get the same error when trying to run InitiateFileTransferToGuest. I've been browsing the API documentation, and threads in VMware forums and a lot of places to be honest. The only pieces of code I've seen posted where it works were in Java and Perl, but the API implementation is a little different than C#. Any idea where to look?
Thank you!
I made it work after testing and making up stuff. I guessed the MoRef for both AuthManager and FileManager doing the following:
ManagedObjectReference MoRefFileManager = new ManagedObjectReference("guestOperationsFileManager");
GuestFileManager VMFileManager = new GuestFileManager(VClient, MoRefFileManager);
ManagedObjectReference MoRefAuthManager = new ManagedObjectReference("guestOperationsAuthManager");
GuestAuthManager VMAuthManager = new GuestAuthManager(VClient, MoRefAuthManager);
Now it's working, and I have no idea how.
Related
I am using REST API C# to develop a tool. I would like to get project info based on owner name.
Does anyone have some sample code on how it should works?
Below is my code but it's not working.
Request ProjRequest = new Request("Projects");
ProjRequest.Workspace = "/workspace/xxx";
ProjRequest.Fetch = new List<string>()
{"Name"};
ProjRequest.Query = new Query("Owner.UserName", Query.Operator.Equals, "user name");
ProjResult result = restApi.Query(ProjRequest);
That looks pretty close. I think you just need to change the type to be singular:
Request ProjRequest = new Request("Project");
If that is still not working, inspect the Errors collection on the response and see what's wrong...
I'm getting a Evernote.EDAM.Error.EDAMErrorCode.PERMISSION_DENIED error on createSharedNotebook when trying to share a business notebook.
AuthenticationResult busAuthResult = _userStore.authenticateToBusiness(authToken);
var bAuthToken = busAuthResult.AuthenticationToken;
var bNoteStoreUri = busAuthResult.NoteStoreUrl;
TTransport noteStoreTransport = new THttpClient(new Uri(bNoteStoreUri));
TProtocol noteStoreProtocol = new TBinaryProtocol(noteStoreTransport);
var noteStore = new NoteStore.Client(noteStoreProtocol);
var notebook = noteStore.getNotebook(bAuthToken, notebookGuid);
var sharedNotebook = new SharedNotebook();
sharedNotebook.Email = "test#test.com";
sharedNotebook.NotebookModifiable = true;
sharedNotebook.AllowPreview = true;
sharedNotebook.NotebookGuid = notebookGuid;
noteStore.createSharedNotebook(bAuthToken, sharedNotebook);
The account I'm using has access to share the notebook, so I can't figure out where this error is coming from. I haven't been able to find anything on sharing business notebooks, so any ideas or links would be greatly appreciated!
I think NotebookModifiable is deprecated. Instead, can you add privilege? After that, hopefully you would get another error message that tell you exactly what other parameters like recipientSettings you have to add.
Using Visual Studio, and AWS .NET V 3.0.
I'm trying to perform a real-time Predict operation, and to verify the basic setup works, I first perform a GetMLModel() which works and returns the endpoint (Somewhere in the documentation is was mentioned to use that result as the service endpoint, but it's the same that is listed in the console). Is has status "READY", so far so good.
The exception occurs below on the line below "Prediction P = RTP.Predict(Data)". Data contains a Dictionary with all the prediction values.
Error: Error making request with Error Code UnknownOperationException and Http Status Code BadRequest. No further error information was returned by the service.
public static APIResult GetRealTimePrediction(Dictionary<string, string> Data, string PayloadJSON = null) {
AmazonMachineLearningConfig MLConfig = new AmazonMachineLearningConfig();
MLConfig.RegionEndpoint = Amazon.RegionEndpoint.USEast1;
MLConfig.Validate();
AmazonMachineLearningClient MLClient = new AmazonMachineLearningClient("xxx", "xxx", MLConfig);
GetMLModelResponse MLMOdelResp = MLClient.GetMLModel("xxx"); // <-- WORKS
MLConfig.ServiceURL = MLMOdelResp.EndpointInfo.EndpointUrl;
Console.WriteLine(MLConfig.ServiceURL);
MLConfig.Validate();
Amazon.MachineLearning.Util.RealtimePredictor RTP = new Amazon.MachineLearning.Util.RealtimePredictor(MLClient, "xxx");
Prediction P = RTP.Predict(Data); // <----------------EXCEPTION HERE
}
(Obviously replace xxx with relevant values) :)
It turns out that this line:
MLConfig.ServiceURL = MLMOdelResp.EndpointInfo.EndpointUrl;
cases the MLConfig.RegionEndpoint to be reset. Even though the documentation indicates the RegionEndpoint can be determined from the ServiceURL (I'm pretty sure I read that), the RegionEndpoint needs to be set again before the RTP.Predict(Data) call.
Once I figured that out, I was able to reduce the code to just this, in case anyone else needs help. I guess adding too much information to the Configuration is NOT a good thing, as the AWS. NET library seems to figure all this out on its own.
public static APIResult GetRealTimePrediction(Dictionary<string, string> Data, string PayloadJSON = null) {
AmazonMachineLearningConfig MLConfig = new AmazonMachineLearningConfig();
MLConfig.RegionEndpoint = Amazon.RegionEndpoint.USEast1;
MLConfig.Validate(); // Just in case, not really needed
AmazonMachineLearningClient MLClient = new AmazonMachineLearningClient("xxx", "xxx", MLConfig);
Amazon.MachineLearning.Util.RealtimePredictor RTP = new Amazon.MachineLearning.Util.RealtimePredictor(MLClient, "xxx");
Prediction P = RTP.Predict(Data);
}
I'm new to Octokit.Net.
and I want to create issue in my program...
So I coded like this.
var github = new GitHubClient(new ProductHeaderValue("Hello"));
var i = new NewIssue("asdf");
i.Body = "asdf";
var issue = github.Issue.Create("JoyLeeSoft", "test", i);
When I call Create function, function always throws NotFoundException.
And the error message just "Not Found"
But, the repository is avaiable. https://github.com/JoyLeeSoft/test
How can I solve this?
Creating an issue means being properly authenticated first (as in Tests/Authentication/BasicAuthenticatorTests.cs)
If not authenticated, the default response of GitHub can be "repository not found".
My goal is to connect to a WMS Service and display a layer on my application's map using ESRI's ArcObject API for .NET.
Here is the part of my code I am struggling with:
...
String url = "some value";
String layerTitle = "another value";
...
PropertySet props = new PropertySet();
props.SetProperty("URL", url);
WMSConnectionName connectionName = new WMSConnectionName();
connectionName.ConnectionProperties = props;
WMSMapLayer mapLayer = new WMSMapLayer();
(mapLayer as IDataLayer).Connect(connectionName as IName);
IWMSGroupLayer groupLayer = (IWMSGroupLayer)mapLayer;
IWMSServiceDescription serviceDescription = groupLayer.WMSServiceDescription;
IWMSLayerDescription layerDescription = serviceDescription.get_LayerDescription(0);
groupLayer.CreateWMSLayer(layerDescription);
groupLayer.get_Layer(0).Visible = true;
ILayer layer = (ILayer)groupLayer;
layer.Name = "WxOverlays " + layerTitle;
layer.Visible = true;
At run time I encounter:
System.Runtime.InteropServices.COMException (0x8000FFFF): The supplied
command does not exist in the command pool at
ESRI.ArcGIS.GISClient.IWMSServiceDescription.get_LayerDescription(Int32
index)
A google search revealed that some similar methods in the ArcObject API throw the same exception because they are not supported in C#. Has anyone encountered this before? Anyone see a way around it? Unfortunately, I am stuck using C#, so using Java or something that may have better support from ESRI is out of the question.