public RegisterHostRequest( long ownerId, string[] addresses, ILocation location, ICluster cluster, IImage image, IProgram program, IMachineType machineType, ManagedResource resource, HostStatus status = HostStatus.Pending, HostType type = HostType.Virtual) { Ensure.IsValidId(ownerId, nameof(ownerId)); Ensure.NotNull(cluster, nameof(cluster)); Ensure.NotNull(location, nameof(location)); Ensure.NotNull(image, nameof(image)); Ensure.NotNull(machineType, nameof(machineType)); OwnerId = ownerId; Addresses = addresses; LocationId = location.Id; EnvironmentId = cluster.EnvironmentId; ClusterId = cluster.Id; ImageId = image.Id; MachineType = new MachineTypeDescriptor { Id = machineType.Id, Name = machineType.Name }; Status = status; Resource = resource; Type = type; }
private void btn_Find_Click(object sender, EventArgs e) { if (rdo_Game.Checked) currMachineMaker = new GameMachineMaker(); else if (rdo_Business.Checked) currMachineMaker = new BusinessMachineMaker(); else if (rdo_Laptop.Checked) currMachineMaker = new LaptopMachineMaker(); else currMachineMaker = new MultimediaMachineMaker(); MachineSpecPrinter currSpecPrinter = new MachineSpecPrinter(currMachineMaker, listBox1); currSpecPrinter.printSpec(); }
public MachineSpecPrinter(IMachineType machineMaker, ListBox displayBox) { this.machineMaker = machineMaker; this.displayBox = displayBox; }
private async Task <RegisterHostRequest> GetRegistrationAsync( Instance instance, Cluster cluster, IImage image = null, ILocation location = null, IMachineType machineType = null) { Validate.NotNull(instance, nameof(instance)); // Ensure the instance is inside a VPC (no classic instances) if (instance.VpcId == null) { throw new ArgumentException("Must belong to a VPC", nameof(instance)); } #region Data Binding / Mappings if (location == null) { location = Locations.Get(aws, instance.Placement.AvailabilityZone); } if (image == null) { // "imageId": "ami-1647537c", image = await imageService.GetAsync(aws, instance.ImageId);; } if (machineType == null) { machineType = AwsInstanceType.Get(instance.InstanceType); } var network = await db.Networks.FindAsync(aws, instance.VpcId);; #endregion // instance.LaunchTime int addressCount = 1; if (instance.IpAddress != null) { addressCount++; } var addresses = new string[addressCount]; addresses[0] = instance.PrivateIpAddress; if (instance.IpAddress != null) { // the instance was assigned a public IP addresses[1] = instance.IpAddress; } var registerRequest = new RegisterHostRequest( addresses: addresses, cluster: cluster, image: image, machineType: machineType, program: null, location: location, status: instance.InstanceState.ToStatus(), ownerId: 1, resource: ManagedResource.Host(location, instance.InstanceId) ); #region Network Interfaces try { var nics = new RegisterNetworkInterfaceRequest[instance.NetworkInterfaces.Length]; for (var nicIndex = 0; nicIndex < nics.Length; nicIndex++) { var ec2Nic = instance.NetworkInterfaces[nicIndex]; nics[nicIndex] = new RegisterNetworkInterfaceRequest( mac: MacAddress.Parse(ec2Nic.MacAddress), subnetId: 0, // TODO: lookup subnet securityGroupIds: Array.Empty <long>(), // TODO: lookup security groupds resource: ManagedResource.NetworkInterface(location, ec2Nic.NetworkInterfaceId) ); } registerRequest.NetworkInterfaces = nics; } catch { } #endregion #region Volumes try { var volumes = new RegisterVolumeRequest[instance.BlockDeviceMappings.Length]; for (var volumeIndex = 0; volumeIndex < volumes.Length; volumeIndex++) { var device = instance.BlockDeviceMappings[volumeIndex]; if (device.Ebs == null) { continue; } var volumeSize = device.Ebs.VolumeSize is int ebsSize ? ByteSize.FromGiB(ebsSize) : ByteSize.Zero; volumes[volumeIndex] = new RegisterVolumeRequest( ownerId: 1, size: volumeSize, resource: ManagedResource.Volume(location, device.Ebs.VolumeId) ); } registerRequest.Volumes = volumes; } catch { } #endregion return(registerRequest); }