public ScenePrivate.CreateClusterData SpawnCube(ShapeDefinition definition) { Vector position = new Vector(definition.p.x, definition.p.y, definition.p.z); ScenePrivate.CreateClusterData createData = null; ClusterResource cube = cubes[definition.c][definition.s]; createData = (ScenePrivate.CreateClusterData)WaitFor(ScenePrivate.CreateCluster, cube, position, Quaternion.Identity, Vector.Zero); return(createData); }
public PSClusterResource(ClusterResource clusterResource) { if (clusterResource == null) { return; } Id = clusterResource.Id; Name = clusterResource.Name; Location = clusterResource.Location; Tags = clusterResource.Tags; Properties = new PSClusterResourceProperties(clusterResource.Properties); }
public ScenePrivate.CreateClusterData SpawnRamp(ShapeDefinition definition) { Vector location = new Vector(definition.p.x, definition.p.y, definition.p.z); Vector eulerRotation = new Vector(definition.r.x, definition.r.y, definition.r.z); Quaternion rotation = Quaternion.FromEulerAngles(eulerRotation); ScenePrivate.CreateClusterData createData = null; ClusterResource ramp = ramps[definition.c][definition.s]; createData = (ScenePrivate.CreateClusterData)WaitFor(ScenePrivate.CreateCluster, ramp, location, rotation, Vector.Zero); return(createData); }
public override void ExecuteCmdlet() { if (!ParameterSetName.Equals(NameParameterSet, StringComparison.Ordinal)) { ResourceIdentifier resourceIdentifier = null; if (ParameterSetName.Equals(ResourceIdParameterSet)) { resourceIdentifier = new ResourceIdentifier(ResourceId); } else if (ParameterSetName.Equals(ObjectParameterSet)) { resourceIdentifier = new ResourceIdentifier(InputObject.Id); } ResourceGroupName = resourceIdentifier.ResourceGroupName; ClusterName = resourceIdentifier.ResourceName; } if (!string.IsNullOrEmpty(ResourceGroupName) && !string.IsNullOrEmpty(ClusterName)) { ClusterResource clusterResource = CosmosDBManagementClient.CassandraClusters.GetWithHttpMessagesAsync(ResourceGroupName, ClusterName).GetAwaiter().GetResult().Body; WriteObject(new PSClusterResource(clusterResource)); } else if (!string.IsNullOrEmpty(ResourceGroupName)) { IEnumerable <ClusterResource> clusterResources = CosmosDBManagementClient.CassandraClusters.ListByResourceGroupWithHttpMessagesAsync(ResourceGroupName).GetAwaiter().GetResult().Body; foreach (ClusterResource clusterResource in clusterResources) { WriteObject(new PSClusterResource(clusterResource)); } } else { IEnumerable <ClusterResource> clusterResources = CosmosDBManagementClient.CassandraClusters.ListBySubscriptionWithHttpMessagesAsync().GetAwaiter().GetResult().Body; foreach (ClusterResource clusterResource in clusterResources) { WriteObject(new PSClusterResource(clusterResource)); } } return; }
/// <summary> /// Updates some of the properties of a managed Cassandra cluster. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='clusterName'> /// Managed Cassandra cluster name. /// </param> /// <param name='body'> /// Parameters to provide for specifying the managed Cassandra cluster. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ClusterResource> BeginUpdateAsync(this ICassandraClustersOperations operations, string resourceGroupName, string clusterName, ClusterResource body, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, clusterName, body, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Updates some of the properties of a managed Cassandra cluster. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='clusterName'> /// Managed Cassandra cluster name. /// </param> /// <param name='body'> /// Parameters to provide for specifying the managed Cassandra cluster. /// </param> public static ClusterResource BeginUpdate(this ICassandraClustersOperations operations, string resourceGroupName, string clusterName, ClusterResource body) { return(operations.BeginUpdateAsync(resourceGroupName, clusterName, body).GetAwaiter().GetResult()); }
private void DispenseObject(ClusterResource clusterResource) { if ((MaxObjectCount > 0) && (dispensedObjects.Count >= MaxObjectCount)) { DestroyOldestObject(); } Vector rotWithVariance = RotationOffset; if (hasRotationVariance) { rotWithVariance += new Vector(RotationVariance.X * RandomNegOneToOne(), RotationVariance.Y * RandomNegOneToOne(), RotationVariance.Z * RandomNegOneToOne()); } Quaternion rotation = Quaternion.FromEulerAngles(Mathf.RadiansPerDegree * rotWithVariance); Quaternion objectRotation = ObjectPrivate.Rotation; Vector position = PositionOffset; if (hasPositionVariance) { position += new Vector(PositionVariance.X * RandomNegOneToOne(), PositionVariance.Y * RandomNegOneToOne(), PositionVariance.Z * RandomNegOneToOne()); } Vector velocity = InitialLinearVelocity; if (hasLinearVelocityVariance) { velocity += new Vector(LinearVelocityVariance.X * RandomNegOneToOne(), LinearVelocityVariance.Y * RandomNegOneToOne(), LinearVelocityVariance.Z * RandomNegOneToOne()); } if (InheritMotion && (dispenserRigidBody != null)) { velocity += dispenserRigidBody.GetLinearVelocity(); } try { ScenePrivate.CreateClusterData dispensedObject = (ScenePrivate.CreateClusterData)WaitFor(ScenePrivate.CreateCluster, clusterResource, ObjectPrivate.Position + position.Rotate(objectRotation), ObjectPrivate.Rotation * rotation, velocity.Rotate(objectRotation)); if (hasInitialAngularVelocity) { RigidBodyComponent rb; if (dispensedObject.ClusterReference.GetObjectPrivates().FirstOrDefault().TryGetFirstComponent(out rb)) { if (rb.GetMotionType() != RigidBodyMotionType.MotionTypeStatic) { Vector angularVel = InitialAngularVelocity; if (hasAngularVelocityVariance) { angularVel += new Vector(AngularVelocityVariance.X * RandomNegOneToOne(), AngularVelocityVariance.Y * RandomNegOneToOne(), AngularVelocityVariance.Z * RandomNegOneToOne()); } if (InheritMotion && (dispenserRigidBody != null)) { angularVel += dispenserRigidBody.GetAngularVelocity(); } rb.SetAngularVelocity(angularVel); } } } dispensedObjects.AddLast(dispensedObject); } catch (ThrottleException) { // Throttled Log.Write(LogLevel.Warning, "DispenseObject throttle hit. No object created."); } }
public override void ExecuteCmdlet() { ClusterResource clusterResource = null; try { clusterResource = CosmosDBManagementClient.CassandraClusters.GetWithHttpMessagesAsync(ResourceGroupName, ClusterName).GetAwaiter().GetResult().Body; } catch (CloudException e) { if (e.Response.StatusCode != System.Net.HttpStatusCode.NotFound) { throw; } } if (clusterResource != null) { throw new ConflictingResourceException(message: string.Format(ExceptionMessage.Conflict, ClusterName)); } if (InitialCassandraAdminPassword == null && ExternalGossipCertificate == null) { throw new ArgumentException("At least one out of the InitialCassandraAdminPassword or ExternalGossipCertificates is required."); } if (InitialCassandraAdminPassword != null && ExternalGossipCertificate != null) { throw new ArgumentException("Only one out of the InitialCassandraAdminPassword or ExternalGossipCertificates has to be specified."); } IList <SeedNode> ExternalSeedNodesList = new List <SeedNode>(); if (ExternalSeedNode != null) { ExternalSeedNodesList = base.PopulateExternalSeedNodes(ExternalSeedNode); } IList <Certificate> ClientCertificateList = new List <Certificate>(); if (ClientCertificate != null) { ClientCertificateList = base.PopulateCertificates(ClientCertificate); } IList <Certificate> ExternalGossipCertificateList = new List <Certificate>(); if (ExternalGossipCertificate != null) { ExternalGossipCertificateList = base.PopulateCertificates(ExternalGossipCertificate); } Dictionary <string, string> tagsDict = new Dictionary <string, string>(); if (Tag != null) { tagsDict = base.PopulateTags(Tag); } ClusterResource ClusterCreateParameters = new ClusterResource { Properties = new ClusterResourceProperties { RepairEnabled = RepairEnabled, CassandraVersion = CassandraVersion, ExternalSeedNodes = ExternalSeedNodesList, ClientCertificates = ClientCertificateList, ClusterNameOverride = ClusterNameOverride, RestoreFromBackupId = RestoreFromBackupId, HoursBetweenBackups = TimeBetweenBackupInHours, AuthenticationMethod = AuthenticationMethod, ExternalGossipCertificates = ExternalGossipCertificateList, DelegatedManagementSubnetId = DelegatedManagementSubnetId, InitialCassandraAdminPassword = InitialCassandraAdminPassword, }, Location = Location, Tags = tagsDict }; if (ShouldProcess(ClusterName, "Creating a new Managed Cassandra Cluster")) { ClusterResource clusterResourceResult = CosmosDBManagementClient.CassandraClusters.CreateUpdateWithHttpMessagesAsync(ResourceGroupName, ClusterName, ClusterCreateParameters).GetAwaiter().GetResult().Body; WriteObject(new PSClusterResource(clusterResourceResult)); } return; }
public override void ExecuteCmdlet() { if (!ParameterSetName.Equals(NameParameterSet, StringComparison.Ordinal)) { ResourceIdentifier resourceIdentifier = null; if (ParameterSetName.Equals(ResourceIdParameterSet)) { resourceIdentifier = new ResourceIdentifier(ResourceId); } else if (ParameterSetName.Equals(ObjectParameterSet)) { resourceIdentifier = new ResourceIdentifier(InputObject.Id); } ResourceGroupName = resourceIdentifier.ResourceGroupName; ClusterName = resourceIdentifier.ResourceName; } ClusterResource clusterResource = null; try { clusterResource = CosmosDBManagementClient.CassandraClusters.GetWithHttpMessagesAsync(ResourceGroupName, ClusterName).GetAwaiter().GetResult().Body; } catch (CloudException e) { if (e.Response.StatusCode != System.Net.HttpStatusCode.NotFound) { throw; } else { throw new ResourceNotFoundException(message: string.Format(ExceptionMessage.NotFound, ClusterName), innerException: e); } } IList <SeedNode> ExternalSeedNodesList; if (ExternalSeedNode != null) { ExternalSeedNodesList = base.PopulateExternalSeedNodes(ExternalSeedNode); } else { ExternalSeedNodesList = clusterResource.Properties.ExternalSeedNodes; } IList <Certificate> ClientCertificateList; if (ClientCertificate != null) { ClientCertificateList = base.PopulateCertificates(ClientCertificate); } else { ClientCertificateList = clusterResource.Properties.ClientCertificates; } IList <Certificate> ExternalGossipCertificateList; if (ExternalGossipCertificate != null) { ExternalGossipCertificateList = base.PopulateCertificates(ExternalGossipCertificate); } else { ExternalGossipCertificateList = clusterResource.Properties.ExternalGossipCertificates; } IDictionary <string, string> tagsDict; if (Tag != null) { tagsDict = base.PopulateTags(Tag); } else { tagsDict = clusterResource.Tags; } ClusterResource ClusterUpdateParameters = new ClusterResource { Properties = new ClusterResourceProperties { ExternalSeedNodes = ExternalSeedNodesList, ClientCertificates = ClientCertificateList, ExternalGossipCertificates = ExternalGossipCertificateList, ProvisioningState = clusterResource.Properties.ProvisioningState, RestoreFromBackupId = clusterResource.Properties.RestoreFromBackupId, ClusterNameOverride = clusterResource.Properties.ClusterNameOverride, RepairEnabled = RepairEnabled ?? clusterResource.Properties.RepairEnabled, CassandraVersion = CassandraVersion ?? clusterResource.Properties.CassandraVersion, DelegatedManagementSubnetId = clusterResource.Properties.DelegatedManagementSubnetId, InitialCassandraAdminPassword = clusterResource.Properties.InitialCassandraAdminPassword, HoursBetweenBackups = TimeBetweenBackupInHours ?? clusterResource.Properties.HoursBetweenBackups, AuthenticationMethod = AuthenticationMethod ?? clusterResource.Properties.AuthenticationMethod, }, Location = clusterResource.Location, Tags = tagsDict }; if (ShouldProcess(ClusterName, "Updating Managed Cassandra Cluster.")) { ClusterResource clusterResourceResult = CosmosDBManagementClient.CassandraClusters.CreateUpdateWithHttpMessagesAsync(ResourceGroupName, ClusterName, ClusterUpdateParameters).GetAwaiter().GetResult().Body; WriteObject(new PSClusterResource(clusterResourceResult)); } return; }
public void ManagedCassandraCRUDTests() { var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; var handler2 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType())) { // Create client CosmosDBManagementClient cosmosDBManagementClient = CosmosDBTestUtilities.GetCosmosDBClient(context, handler); ResourceManagementClient resourcesClient = CosmosDBTestUtilities.GetResourceManagementClient(context, handler2); string resourceGroupName = CosmosDBTestUtilities.CreateResourceGroup(resourcesClient); try { string clusterName = TestUtilities.GenerateName("managedcluster"); string dcName = TestUtilities.GenerateName("managedDC"); this.output.WriteLine($"Creating cluster {clusterName} in resource group {resourceGroupName}."); string subnetId = CreateVirtualNetwork(resourcesClient, resourceGroupName); this.output.WriteLine($"Created subnet {subnetId}."); var clusterProperties = new ClusterResourceProperties { DelegatedManagementSubnetId = subnetId, InitialCassandraAdminPassword = "******", ExternalSeedNodes = new List <SeedNode> { new SeedNode { IpAddress = "10.0.1.1" } } }; var clusterPutResource = new ClusterResource { Location = "East US 2", Properties = clusterProperties }; this.output.WriteLine($"Cluster create request body:"); this.output.WriteLine(JsonConvert.SerializeObject(clusterPutResource, Formatting.Indented)); ClusterResource clusterResource = cosmosDBManagementClient.CassandraClusters .CreateUpdateWithHttpMessagesAsync(resourceGroupName: resourceGroupName, clusterName: clusterName, body: clusterPutResource).GetAwaiter().GetResult().Body; this.output.WriteLine($"Cluster create response:"); this.output.WriteLine(JsonConvert.SerializeObject(clusterResource, Formatting.Indented)); Assert.Equal(subnetId, clusterResource.Properties.DelegatedManagementSubnetId); Assert.Null(clusterResource.Properties.InitialCassandraAdminPassword); Assert.Equal("Cassandra", clusterResource.Properties.AuthenticationMethod); Assert.Equal("Succeeded", clusterResource.Properties.ProvisioningState); Assert.NotNull(clusterResource.Properties.ExternalSeedNodes); Assert.Equal(1, clusterResource.Properties.ExternalSeedNodes.Count); Assert.Equal("10.0.1.1", clusterResource.Properties.ExternalSeedNodes[0].IpAddress); clusterPutResource.Properties.ExternalSeedNodes = new List <SeedNode> { new SeedNode { IpAddress = "192.168.12.1" } }; this.output.WriteLine(""); this.output.WriteLine("Updating cluster. Put body:"); this.output.WriteLine(JsonConvert.SerializeObject(clusterPutResource, Formatting.Indented)); ClusterResource clusterResource2 = cosmosDBManagementClient.CassandraClusters .CreateUpdateWithHttpMessagesAsync(resourceGroupName: resourceGroupName, clusterName: clusterName, body: clusterPutResource).GetAwaiter().GetResult().Body; this.output.WriteLine("Response:"); this.output.WriteLine(JsonConvert.SerializeObject(clusterResource2, Formatting.Indented)); Assert.Equal(clusterName, clusterResource2.Name); Assert.Equal("East US 2", clusterResource2.Location); Assert.Equal(subnetId, clusterResource2.Properties.DelegatedManagementSubnetId); Assert.Null(clusterResource2.Properties.InitialCassandraAdminPassword); Assert.Equal("Cassandra", clusterResource2.Properties.AuthenticationMethod); Assert.Null(clusterResource2.Properties.CassandraVersion); Assert.Equal("Succeeded", clusterResource2.Properties.ProvisioningState); Assert.NotNull(clusterResource2.Properties.ExternalSeedNodes); Assert.NotEmpty(clusterResource2.Properties.ExternalSeedNodes); DataCenterResource dataCenterPutResource = new DataCenterResource { Properties = new DataCenterResourceProperties { DataCenterLocation = "East US 2", DelegatedSubnetId = subnetId, NodeCount = 3, } }; this.output.WriteLine($"Creating data center {dcName}. Put request:"); this.output.WriteLine(JsonConvert.SerializeObject(dataCenterPutResource, Formatting.Indented)); DataCenterResource dcResource = cosmosDBManagementClient.CassandraDataCenters .CreateUpdateWithHttpMessagesAsync(resourceGroupName, clusterName, dcName, dataCenterPutResource).GetAwaiter().GetResult().Body; this.output.WriteLine("Response:"); this.output.WriteLine(JsonConvert.SerializeObject(dcResource, Formatting.Indented)); Assert.Equal("East US 2", dcResource.Properties.DataCenterLocation); Assert.Equal(subnetId, dcResource.Properties.DelegatedSubnetId); Assert.Equal(3, dcResource.Properties.NodeCount); Assert.Equal(3, dcResource.Properties.SeedNodes.Count); this.output.WriteLine($"Deleting data center {dcName}."); cosmosDBManagementClient.CassandraDataCenters .DeleteWithHttpMessagesAsync(resourceGroupName, clusterName, dcName).GetAwaiter().GetResult(); this.output.WriteLine($"Deleting cluster {clusterName}."); cosmosDBManagementClient.CassandraClusters .DeleteWithHttpMessagesAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); this.output.WriteLine("Deleting deployment of vnets."); cosmosDBManagementClient.CassandraClusters .DeleteWithHttpMessagesAsync(resourceGroupName, clusterName).GetAwaiter().GetResult(); } finally { this.output.WriteLine("Deleting resource group."); resourcesClient.Deployments.Delete(resourceGroupName, ManagedCassandraResourcesOperationsTests.VnetDeploymentName); resourcesClient.ResourceGroups.Delete(resourceGroupName); } } }
public async Task ManagedCassandraCRUDTests() { using (var context = MockContext.Start(this.GetType())) { var location = this.fixture.Location; fixture.Init(context); var clusterClient = this.fixture.CosmosDBManagementClient.CassandraClusters; var dcClient = this.fixture.CosmosDBManagementClient.CassandraDataCenters; string clusterName = TestUtilities.GenerateName("managedcluster"); string dcName = TestUtilities.GenerateName("managedDC"); this.output.WriteLine($"Creating cluster {clusterName} in resource group {this.fixture.ResourceGroupName}."); string subnetId = CreateVirtualNetwork(location); this.output.WriteLine($"Created subnet {subnetId}."); var clusterProperties = new ClusterResourceProperties { DelegatedManagementSubnetId = subnetId, InitialCassandraAdminPassword = "******", ExternalSeedNodes = new List <SeedNode> { new SeedNode { IpAddress = "10.0.1.1" } } }; var clusterPutResource = new ClusterResource { Location = location, Properties = clusterProperties }; this.output.WriteLine($"Cluster create request body:"); this.output.WriteLine(JsonConvert.SerializeObject(clusterPutResource, Formatting.Indented)); ClusterResource clusterResource = (await clusterClient .CreateUpdateWithHttpMessagesAsync(resourceGroupName: this.fixture.ResourceGroupName, clusterName: clusterName, body: clusterPutResource)).Body; this.output.WriteLine($"Cluster create response:"); this.output.WriteLine(JsonConvert.SerializeObject(clusterResource, Formatting.Indented)); Assert.Equal(subnetId, clusterResource.Properties.DelegatedManagementSubnetId); Assert.Null(clusterResource.Properties.InitialCassandraAdminPassword); Assert.Equal("Cassandra", clusterResource.Properties.AuthenticationMethod); Assert.Equal("Succeeded", clusterResource.Properties.ProvisioningState); Assert.NotNull(clusterResource.Properties.ExternalSeedNodes); Assert.Equal(1, clusterResource.Properties.ExternalSeedNodes.Count); Assert.Equal("10.0.1.1", clusterResource.Properties.ExternalSeedNodes[0].IpAddress); clusterPutResource.Properties.ExternalSeedNodes = new List <SeedNode> { new SeedNode { IpAddress = "192.168.12.1" } }; this.output.WriteLine(""); this.output.WriteLine("Updating cluster. Put body:"); this.output.WriteLine(JsonConvert.SerializeObject(clusterPutResource, Formatting.Indented)); ClusterResource clusterResource2 = (await clusterClient .CreateUpdateWithHttpMessagesAsync(resourceGroupName: this.fixture.ResourceGroupName, clusterName: clusterName, body: clusterPutResource)).Body; this.output.WriteLine("Response:"); this.output.WriteLine(JsonConvert.SerializeObject(clusterResource2, Formatting.Indented)); Assert.Equal(clusterName, clusterResource2.Name); Assert.Equal(location.ToLower(), clusterResource2.Location.ToLower()); Assert.Equal(subnetId, clusterResource2.Properties.DelegatedManagementSubnetId); Assert.Null(clusterResource2.Properties.InitialCassandraAdminPassword); Assert.Equal("Cassandra", clusterResource2.Properties.AuthenticationMethod); Assert.Equal("3.11", clusterResource2.Properties.CassandraVersion); Assert.Equal("Succeeded", clusterResource2.Properties.ProvisioningState); Assert.NotNull(clusterResource2.Properties.ExternalSeedNodes); Assert.NotEmpty(clusterResource2.Properties.ExternalSeedNodes); Assert.False(clusterResource2.Properties.Deallocated); DataCenterResource dataCenterPutResource = new DataCenterResource { Properties = new DataCenterResourceProperties { DataCenterLocation = location, DelegatedSubnetId = subnetId, NodeCount = 3 } }; this.output.WriteLine($"Creating data center {dcName}. Put request:"); this.output.WriteLine(JsonConvert.SerializeObject(dataCenterPutResource, Formatting.Indented)); DataCenterResource dcResource = (await dcClient .CreateUpdateWithHttpMessagesAsync(this.fixture.ResourceGroupName, clusterName, dcName, dataCenterPutResource)).Body; this.output.WriteLine("Response:"); this.output.WriteLine(JsonConvert.SerializeObject(dcResource, Formatting.Indented)); Assert.Equal(location.ToLower(), dcResource.Properties.DataCenterLocation.ToLower()); Assert.Equal(subnetId, dcResource.Properties.DelegatedSubnetId); Assert.Equal(3, dcResource.Properties.NodeCount); Assert.Equal(3, dcResource.Properties.SeedNodes.Count); await clusterClient.DeallocateWithHttpMessagesAsync(this.fixture.ResourceGroupName, clusterName); ClusterResource clusterResource3 = await clusterClient.GetAsync(this.fixture.ResourceGroupName, clusterName); Assert.True(clusterResource3.Properties.Deallocated); await clusterClient.StartWithHttpMessagesAsync(this.fixture.ResourceGroupName, clusterName); ClusterResource clusterResource4 = await clusterClient.GetAsync(this.fixture.ResourceGroupName, clusterName); Assert.False(clusterResource4.Properties.Deallocated); this.output.WriteLine($"Deleting data center {dcName}."); await dcClient.DeleteWithHttpMessagesAsync(this.fixture.ResourceGroupName, clusterName, dcName); this.output.WriteLine($"Deleting cluster {clusterName}."); await clusterClient.DeleteWithHttpMessagesAsync(this.fixture.ResourceGroupName, clusterName); } }