I am totally new to proxmox VE and i want to create a Vitual Machine inside proxmox using C# console application.
I have search a lot and i only found an API program which has all the functionality but i don't know how to use it. https://github.com/EnterpriseVE/eve2pve-api-dotnet
Can someone help me how to create and delete a vm in proxmox using this API in detail or anyone have any different approach to do this
Usage:
var client = new Client("10.92.90.91");
if (client.Login("root", "password"))
{
var vm = client.Nodes["pve1"].Qemu[100];
//config vm
var config = vm.Config.VmConfig();
Console.WriteLine(Client.ObjectToJson(config.Response));
//create snapshot
var response = vm.Snapshot.Snapshot("pippo2311");
//update snapshot description
vm.Snapshot["pippo2311"].Config.UpdateSnapshotConfig("descr");
//delete snapshot
vm.Snapshot["pippo2311"].Delsnapshot();
//list of snapshot
foreach (var snapshot in vm.Snapshot.SnapshotList().Response.data)
{
Console.WriteLine(Client.ObjectToJson(snapshot));
Console.WriteLine(snapshot.name);
}
client.ResponseType = "png";
var dataImg = client.Nodes["pve1"].Rrd.Rrd("cpu", "day").Response;
Console.WriteLine("<img src=\"{dataImg}\" \>");
}
Get the project from github
Compile the project
Add reference to the project's dll
Use it just like the example above
Related
I am now updating an integration program written for Dynamics 2015 in order to support Dynamics 365. At the moment it uses the Microsoft.Xrm.Client dll methods to create an organization service context. Is there an equivalent to Microsoft.Xrm.Tooling as Microsoft.Xrm.Client seems unsupported.
var getCRMOrgService = CreateCRMOrgService(logger);
var client = CreatePosPerfectConnection(logger);
if (getCRMOrgService != null)
{
using (var ctx = new DataContext(new CrmOrganizationServiceContext(getCRMOrgService)))
{
ctx.TryAccessCache(cache => cache.Mode = OrganizationServiceCacheMode.Disabled);
/******Rest of the code******/
Here I require to change the CreateCRMOrgService and CrmOrganizationServiceContext Methods to the ones supported by Microsoft.Xrm.Tooling alone
It looks like you'll want to switch to CrmServiceClient, which is in the Microsoft.Xrm.Tooling.Connector namespace.
To get the NuGet package:
In your project, right click on the References node and select Manage NuGet Packages. Under Browse search for "xrm tooling". Install Microsoft.CrmSdk.XrmTooling.CoreAssembly and you should be good to go.
Then create a CrmServiceClient via a connection string
var svc = new CrmServiceClient(connectionString);
Then for the context (query provider) do something like this (please note this is untested code):
private List<Entity> getRecords()
{
using (var context = new Microsoft.Xrm.Sdk.Client.OrganizationServiceContext(svc))
{
var result = from e in organizationServiceContext.CreateQuery("new_entity")
where e.GetAttributeValue<string>("new_field") == "my value"
select e;
return result.Take(100).ToList();
}
}
I'm using next code to push Tag to Git repository
#addin "Cake.Git"
using LibGit2Sharp;
var solutionFolder = "./";
var versionTag = "someTag";
Task("Default")
.Does(() =>
{
var remoteRepository = EnvironmentVariable("bamboo_planRepository_repositoryUrl");
var repositoryRevision = EnvironmentVariable("bamboo_planRepository_revision");
var absolutePath = MakeAbsolute(Directory(solutionFolder));
var repoName = "central";
//LibGit2Sharp add remote
using (var repo = new Repository(absolutePath.FullPath))
{
repo.Network.Remotes.Add(repoName, remoteRepository);
}
GitTag(solutionFolder, versionTag, repositoryRevision);
GitPushRef(solutionFolder, gitUser, gitPassword, repoName, versionTag);
}
});
Stuck into the next issue: because our bamboo configured to use SSH protocol, and Cake.Git(LibGit2Sharp) currently doesn't support it receiving next error
Error: unsupported URL protocol
Thanks
I would suspect the issue is to due using shallow clones, which are enabled by default.
Shallow clones allows Bamboo to perform clones with i.e. history truncated to a specified number of revisions.
This should increase the speed of the initial code checkouts, however if your build depends on the full repository history, we recommend that you do not use this option.
GIT operations in general need the full repo to work reliably.
A little bit hacky but it works, will update answer when will find better approach.
Done based on the How to tag a git repo in a bamboo build.
Cake.Git currently doesn't support adding repository but under the hood using LibGit2Sharp so just added LibGit2Sharp namespace to the code.
Core issue is that Cake.Git(LibGit2Sharp) doesn't support SSH yet (Issue on GitHub Is it possible to use Cake.Git with SSH), as workaraound calling git push through cmd How to execute cmd
command
#addin "Cake.Git"
using LibGit2Sharp;
var solutionFolder = "./";
var versionTag = "someTag";
var remoteRepository = EnvironmentVariable("bamboo_planRepository_repositoryUrl");
var repositoryRevision = EnvironmentVariable("bamboo_planRepository_revision");
Task("Default")
.Does(() =>
{
var absolutePath = MakeAbsolute(Directory(solutionFolder));
var repoName = "central";
//LibGit2Sharp add remote
using (var repo = new Repository(absolutePath.FullPath))
{
repo.Network.Remotes.Add(repoName, remoteRepository);
}
GitTag(solutionFolder, versionTag, repositoryRevision);
Cmd($"git push {repoName} {versionTag}");
}
});
private void Cmd(params object[] parameters)
{
if (parameters.Any())
{
var args = new ProcessArgumentBuilder()
.Append(#"/c");
foreach (var param in parameters)
args.Append($"{param}");
StartProcess("cmd", new ProcessSettings { Arguments = args });
}
}
Using NotificationHubClient I can get all registered devices using GetAllRegistrationsAsync(). But if I do not use the registration model but the installation model instead, how can I get all installations? There are methods to retrieve a specific installation but none to get everything.
You're correct, as of July 2016 there's no way to get all installations for a hub. In the future, the product team is planning to add this feature to the installations model, but it will work in a different way. Instead of making it a runtime operation, you'll provide your storage connection string and you'll get a blob with everything associated with the hub.
Sorry for visiting an old thread... but in theory you could use the GetAllRegistrationsAsyc to get all the installations. I guess this will return everything without an installation id as well, but you could just ignore those if you choose.
Could look something like this
var allRegistrations = await _hub.GetAllRegistrationsAsync(0);
var continuationToken = allRegistrations.ContinuationToken;
var registrationDescriptionsList = new List<RegistrationDescription>(allRegistrations);
while (!string.IsNullOrWhiteSpace(continuationToken))
{
var otherRegistrations = await _hub.GetAllRegistrationsAsync(continuationToken, 0);
registrationDescriptionsList.AddRange(otherRegistrations);
continuationToken = otherRegistrations.ContinuationToken;
}
// Put into DeviceInstallation object
var deviceInstallationList = new List<DeviceInstallation>();
foreach (var registration in registrationDescriptionsList)
{
var deviceInstallation = new DeviceInstallation();
var tags = registration.Tags;
foreach(var tag in tags)
{
if (tag.Contains("InstallationId:"))
{
deviceInstallation.InstallationId = new Guid(tag.Substring(tag.IndexOf(":")+1));
}
}
deviceInstallation.PushHandle = registration.PnsHandle;
deviceInstallation.Tags = new List<string>(registration.Tags);
deviceInstallationList.Add(deviceInstallation);
}
I am not suggesting this to be the cleanest chunk of code written, but it does the trick for us. We only use this for debugging type purposes anyways
We need to update Global and Current Navigation Settings for the site.
Below is our code
var publishingWeb = PublishingWeb.GetPublishingWeb(this.CC, subWeb);
// WebNavigationSettings
var webNavigationSettings = new WebNavigationSettings(this.CC, subWeb);
webNavigationSettings.GlobalNavigation.Source = StandardNavigationSource.PortalProvider;
webNavigationSettings.CurrentNavigation.Source = StandardNavigationSource.PortalProvider;
// CSOM don't have: publishingWeb.Navigation.GlobalIncludeSubSites.
subWeb.AllProperties["__GlobalIncludeSubSites"] = "True"; //TODO: Verify why it is not working.
subWeb.AllProperties["__GlobalIncludePages"] = "True"; //TODO: Verify why it is not working.
subWeb.Update();
webNavigationSettings.Update(tSession);
CC.Load(subWeb, WEB_INCLUDES);
// Apply the load
CC.ExecuteQuery();
As we are using CSOM, we did not have
publishingWeb.Navigation.GlobalIncludeSubSites
.
So we tried to set using AllProperties to set GlobalIncludeSubSites and GlobalIncludePages.
But those properties are not getting set.
Is there any way to fix this problem.
I went throught article http://discoveringsharepoint.wordpress.com/2013/03/19/programmatically-set-navigation-settings-in-sharepoint-2013/
But it uses namespace : Microsoft.SharePoint.Publishing.Navigation
But our's namespace is : Microsoft.SharePoint.Client.Publishing.Navigation
As we are doing from client server object model.
Is there any way to solve this ?
Thanks
In SharePoint 2013 was introduced a new Microsoft.SharePoint.Client.Publishing and Microsoft.SharePoint.Client.Publishing.Navigation namespaces in CSOM API. But unfortunately it is not supported to modify navigation settings using WebNavigationSettings class since properties are exposes as a read-only.
You could utilize the following approach for that purpose. ClientPortalNavigation.cs represents a CSOM counterpart for SSOM PortalNavigation Class.
The following example demonstrates how to utilize that class and update Navigation settings:
using (var ctx = new ClientContext(webUri))
{
var navigation = new ClientPortalNavigation(ctx.Web);
navigation.CurrentIncludePages = true;
navigation.GlobalIncludePages = false;
navigation.SaveChanges();
}
ClientPortalNavigation.cs is compatible with SharePoint 2010/2013
CSOM APIs.
References
Access and Manipulate Navigation Settings via SharePoint Client Object Model
ClientPortalNavigation.cs
Here is the code which I have written to access the Projects and the team, but it shows some error. I want to access the project and then the Source Code present in the Source Control Explorer in the Project/Team.
Uri _serverUri = new Uri("MyURI");
string _teamProjectName = "MyProject";
TfsTeamProjectCollection collection =
TfsTeamProjectCollectionFactory.GetTeamProjectCollection(_serverUri);
// Retrieve the project URI. Needed to enumerate teams.
var css4 = collection.GetService<ICommonStructureService>();
ProjectInfo projectInfo = css4.GetProjectFromName(_teamProjectName);
// Retrieve a list of all teams on the project.
TfsTeamService teamService = collection.GetService<TfsTeamService>();
var allTeams = teamService.QueryTeams(projectInfo.Uri);
allTeams.ToList().ForEach
(
allteams => { Console.WriteLine(allteams); });
The error which it shows is "The type or namespace 'Core' does not exist in the namespace Microsoft.TeamFoundation.Server
I also want to access the source control, so if anyone can help me with both of my issues.