Exemple #1
0
        public void NicCreate()
        {
            Configure();
            nic = new Nic {
                Properties = new NicProperties {
                    Lan = 1
                }
            };

            nic = nicApi.Create(datacenter.Id, server.Id, nic);

            DoWait(nic.Request);


            bool isBusy = true;

            while (isBusy == true)
            {
                var temp = dcApi.FindById(datacenter.Id);
                if (temp.Metadata.State != "BUSY")
                {
                    isBusy = false;
                }
                Thread.Sleep(5000);
            }


            Assert.IsNotNull(nic);
        }
        private void lstNics_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ClearControls();
            if (lstNics.SelectedItem == null)
            {
                return;
            }

            Nic nic = (Nic)lstNics.SelectedItem;

            grpInfo.Header = nic.Description;
            lblID.Content  = nic.Id;
            lblNetworkInterfaceType.Content = nic.NetworkInterfaceType;
            lblOperationalStatus.Content    = nic.OperationalStatus;
            lblOperationalStatus.Foreground = Brushes.White;
            if (lblOperationalStatus.Content.ToString().ToUpper() == "DOWN")
            {
                lblOperationalStatus.Background = Brushes.Tomato;
                grpInfo.Background = Brushes.MistyRose;
            }
            else
            {
                lblOperationalStatus.Background = Brushes.ForestGreen;
                grpInfo.Background = Brushes.Honeydew;
            }
            lblSpeed.Content = nic.Speed + " Mb";
            lblMac.Content   = nic.MacAddress;
            lblIP4.Content   = nic.IPv4Info;
            lblIP6.Content   = nic.iPv6Info;
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the Interface class using the specified
        /// parameters.
        /// </summary>
        /// <param name="nic">The network interface card (NIC) this interface
        /// represents.</param>
        /// <param name="name">A unique name (such as eth0) for identifing the
        /// interface.</param>
        /// <param name="cidrIpAddress">The IPv4 address to associate with this
        /// interface in CIDR notation.</param>
        /// <param name="gateway">The IPv4 address of the default gateway to
        /// configure this interface with.</param>
        /// <exception cref="ArgumentNullException">Thrown if any of the arguments
        /// is null.</exception>
        public Interface(Nic nic, string name, string cidrIpAddress,
                         string gateway = null)
        {
            var t = IpAddress.ParseCIDRNotation(cidrIpAddress);

            Init(nic, name, t.Item1, t.Item2, gateway != null ?
                 new IpAddress(gateway) : null);
        }
Exemple #4
0
 public frmMain()
 {
     InitializeComponent();
     Nic.LoadNIC();              //Load all Nic's
     SetupForm(rbNames.Enabled); //Fill in everything needed
     timer1.Interval = 500;      //Intervall CheckHosts is called
     timer1.Tick    += new EventHandler(timer1_Tick);
 }
Exemple #5
0
        /// <summary>
        ///     Method to check if entered nic has correct format
        /// </summary>
        /// <returns></returns>
        public bool IsNicValid()
        {
            if (Nic.Length != 10)
            {
                return(false);
            }
            int n;

            return(int.TryParse(Nic.Substring(0, 9), out n) && (Nic.Substring(9).ToUpper() == "V" || Nic.Substring(9).ToUpper() == "X"));
        }
        public frmMain()
        {
            InitializeComponent();

            this.Icon      = Properties.Resources.Icons_Land_Vista_Hardware_Devices_Ethernet_Cable;
            btnStart.Image = Properties.Resources.Sekkyumu_Developpers_Play.ToBitmap();
            btnStop.Image  = Properties.Resources.Sekkyumu_Developpers_Stop.ToBitmap();
            pBHelp.Image   = Properties.Resources.Fatcow_Farm_Fresh_Information.ToBitmap();
            Nic.LoadNIC();              //Load all Nic's
            SetupForm(rbNames.Enabled); //Fill in everything needed
            timer1.Interval = 500;      //Intervall CheckHosts is called
            timer1.Tick    += new EventHandler(timer1_Tick);
        }
Exemple #7
0
 /// <summary>
 /// Initializes the interface.
 /// </summary>
 /// <param name="nic">The network interface card (NIC) this interface
 /// represents.</param>
 /// <param name="name">A unique name (such as eth0) for identifing the
 /// interface.</param>
 /// <param name="ipAddress">The IPv4 address to associate with this
 /// interface.</param>
 /// <param name="netmask">The subnetmask to assign to this interface.</param>
 /// <param name="gateway">The IPv4 address of the default gateway to
 /// configure this interface with.</param>
 void Init(Nic nic, string name, IpAddress ipAddress, IpAddress netmask,
           IpAddress gateway)
 {
     nic.ThrowIfNull("nic");
     name.ThrowIfNull("name");
     ipAddress.ThrowIfNull("ipAddress");
     netmask.ThrowIfNull("netmask");
     Nic            = nic;
     Name           = name;
     IpAddress      = ipAddress;
     Netmask        = netmask;
     Gateway        = gateway;
     Nic.Interrupt += OnInterrupt;
 }
Exemple #8
0
        public static String[] GetDnsServer()
        {
            ArrayList Servers = new ArrayList();

            foreach (NetworkInterface Nic in NetworkInterface.GetAllNetworkInterfaces())
            {
                if (Nic.OperationalStatus == OperationalStatus.Up & Nic.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
                {
                    IPInterfaceProperties NicProperties = Nic.GetIPProperties();
                    foreach (IPAddress DnsAddress in NicProperties.DnsAddresses)
                    {
                        Servers.Add(DnsAddress.ToString());
                    }
                }
            }
            return((string[])Servers.ToArray(typeof(string)));
        }
        bool Start()
        {
            try {
                ipManager.Start();
                routingManager.Start();

                for (int i = 0; i < nicRefs.Length; i++)
                {
                    NicDeviceContract /*.Imp*/ imp = (nicRefs[i]).Acquire();
                    Nic.CreateAndRegister(imp, String.Format("/dev/nic{0}", i));
                }

                return(true);
            }
            catch (Exception ex) {
                Dbg("An exception occurred during service startup: " + ex.Message);
                return(false);
            }
        }
        public void NicCreate()
        {
            Configure();
            nic = new Nic { Properties = new NicProperties { Lan = 1 } };

            nic = nicApi.Create(datacenter.Id, server.Id, nic);

            DoWait(nic.Request);

            bool isBusy = true;

            while (isBusy == true)
            {
                var temp = dcApi.FindById(datacenter.Id);
                if (temp.Metadata.State != "BUSY") isBusy = false;
                Thread.Sleep(5000);
            }

            Assert.IsNotNull(nic);
        }
Exemple #11
0
        public static async Task <ServicesResponse> CreateNic(string vMId, string networkId, Adapter adapter)
        {
            ServicesResponse vNicProfilesResponse = await ApiService.GetRequest(adapter, typeof(OvirtVNics.VnicProfiles), $"ovirt-engine/api/networks/{networkId}/vnicprofiles");

            if (!vNicProfilesResponse.isSuccess || vNicProfilesResponse.resultObject == null)
            {
                return(vNicProfilesResponse);
            }
            OvirtVNics.VnicProfiles vNics = (OvirtVNics.VnicProfiles)vNicProfilesResponse.resultObject;
            string vNicProfileId          = vNics.VnicProfile[0].Id;
            Nic    newNic = new Nic
            {
                Name         = "vmnic",
                Interface    = "virtio",
                Vnic_profile = new Vnic_profile
                {
                    Id = vNicProfileId
                }
            };
            ServicesResponse vNicResponse = await ApiService.PostRequest <Nic>(adapter, newNic, $"ovirt-engine/api/vms/{vMId}/nics");

            vNicResponse.resultObject = (Nic)vNicResponse.resultObject;
            return(vNicResponse);
        }
 /// <summary>
 /// Attach a nic This will attach a pre-existing nic to a lan.
 /// </summary>
 /// <param name="datacenterId"></param> 
 /// <param name="lanId"></param> 
 /// <param name="nic">Nic to be attached</param> 
 /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param> 
 /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n	- depth=0: only direct properties are included. Children (servers etc.) are not included\n	- depth=1: direct properties and children references are included\n	- depth=2: direct properties and children properties are included\n	- depth=3: direct properties and children properties and children&#39;s children are included\n	- depth=... and so on</param> 
 /// <returns>Nic</returns>
 public Nic AttachNic(string datacenterId, string lanId, Nic nic, bool? parameter = null, int? depth = null)
 {
     ApiResponse<Nic> response = AttachNicWithHttpInfo(datacenterId, lanId, nic, parameter, depth);
     return response.Data;
 }
Exemple #13
0
		internal Hardware(Nic owner) : base(owner)
		{
		}
Exemple #14
0
		internal InternetProtocol(Nic owner) : base(owner)
		{
		}
Exemple #15
0
		protected FunctionBase(Nic owner) : base(owner)
		{
		}
Exemple #16
0
		internal Functions(Nic owner) : base(owner)
		{
		}
 public Nic AttachNic(string datacenterId, string serverId, Nic nic)
 {
     ApiResponse<Nic> response = AttachNicWithHttpInfo(datacenterId, serverId, nic);
     response.Data.Request = response.Headers["Location"];
     return response.Data;
 }
Exemple #18
0
        private void Configure()
        {
            Configuration = new Configuration
            {
                Username = "******",
                Password = "******",
            };

            dcApi     = new DataCenterApi(configuration);
            serverApi = new ServerApi(configuration);
            nicApi    = new NetworkInterfacesApi(configuration);
            lbApi     = new LoadBalancerApi(configuration);
            fwApi     = new FirewallRuleApi(configuration);

            //Create a datacenter.
            if (datacenter == null)
            {
                datacenter = new Datacenter
                {
                    Properties = new DatacenterProperties
                    {
                        Name        = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(),
                        Description = "Unit test for .Net SDK PB REST V2",
                        Location    = "us/lasdev"
                    }
                };

                datacenter = dcApi.Create(datacenter);
            }

            if (server == null)
            {
                server = new Server
                {
                    Properties = new ServerProperties
                    {
                        Name  = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(),
                        Cores = 1,
                        Ram   = 256
                    }
                };

                server = serverApi.Create(datacenter.Id, server);
                DoWait(server.Request);
            }

            if (nic == null)
            {
                nic = new Nic {
                    Properties = new NicProperties {
                        Lan = 1
                    }
                };

                nic = nicApi.Create(datacenter.Id, server.Id, nic);

                DoWait(nic.Request);
            }

            bool isBusy = true;

            while (isBusy == true)
            {
                var temp = dcApi.FindById(datacenter.Id);
                if (temp.Metadata.State != "BUSY")
                {
                    isBusy = false;
                }
                Thread.Sleep(5000);
            }
        }
Exemple #19
0
		internal LinkLayer(Nic owner) : base(owner)
		{
		}
Exemple #20
0
		internal RenewFunction(Nic owner) : base(owner)
		{
		}
Exemple #21
0
		internal DnsExtension(Nic owner) : base(owner)
		{
		}
Exemple #22
0
        protected override void BeginProcessing()
        {
            try
            {
                var dcApi              = new DataCenterApi(Utilities.Configuration);
                var serverApi          = new ServerApi(Utilities.Configuration);
                var volumeApi          = new VolumeApi(Utilities.Configuration);
                var attachedVolumesApi = new AttachedVolumesApi(Utilities.Configuration);

                var datacenter = dcApi.FindById(DataCenterId, depth: 5);

                var server = new Server
                {
                    Properties = new ServerProperties
                    {
                        Name      = this.Name,
                        Cores     = this.Cores,
                        Ram       = (int)(this.Ram / 1024 / 1024),
                        CpuFamily = this.CpuFamily
                    }
                };

                var newServer = serverApi.Create(this.DataCenterId, server);

                WriteVerbose("Creating the server...");

                Utilities.DoWait(newServer.Request);

                if (!string.IsNullOrEmpty(this.AvailabilityZone))
                {
                    server.Properties.AvailabilityZone = this.AvailabilityZone;
                }

                if (!string.IsNullOrEmpty(this.BootVolume))
                {
                    server.Properties.BootVolume = new ResourceReference {
                        Id = this.BootVolume
                    };
                }

                if (!string.IsNullOrEmpty(this.BootCDRom))
                {
                    server.Properties.BootCdrom = new ResourceReference {
                        Id = this.BootCDRom
                    };
                }

                long size = Size;
                size = size == 0 ? 21474836480 : Size;

                var volume = new Volume
                {
                    Properties = new VolumeProperties
                    {
                        Size = (int)(size / 1024 / 1024 / 1024),
                        Type = (string.IsNullOrEmpty(DiskType) ? "HDD" : DiskType),
                        Name = Name,
                    }
                };

                if (!string.IsNullOrEmpty(ImageId))
                {
                    volume.Properties.Image = ImageId;
                }

                if (!string.IsNullOrEmpty(ImageAlias))
                {
                    volume.Properties.ImageAlias = ImageAlias;
                }

                if (!string.IsNullOrEmpty(SshKey))
                {
                    volume.Properties.SshKeys = new List <string> {
                        SshKey
                    };
                }

                if (!string.IsNullOrEmpty(Password))
                {
                    volume.Properties.ImagePassword = Password;
                }

                WriteVerbose("Creating the volume...");
                volume = volumeApi.Create(this.DataCenterId, volume);

                Utilities.DoWait(volume.Request);

                var attachedVol = attachedVolumesApi.AttachVolume(DataCenterId, newServer.Id, new Volume {
                    Id = volume.Id
                });



                if (this.PublicIp)
                {
                    var nic = new Nic
                    {
                        Properties = new NicProperties
                        {
                            Lan = 1,
                        }
                    };
                    var nicApi = new NetworkInterfacesApi(Utilities.Configuration);

                    if (this.StaticIp)
                    {
                        var ipblockApi = new IPBlocksApi(Utilities.Configuration);

                        var ipblock = new IpBlock
                        {
                            Properties = new IpBlockProperties
                            {
                                Location = datacenter.Properties.Location,
                                Size     = 1
                            }
                        };
                        WriteVerbose("Creating the static IP address...");
                        ipblock = ipblockApi.Create(ipblock);


                        Utilities.DoWait(ipblock.Request);
                        nic.Properties.Ips = ipblock.Properties.Ips;
                    }

                    WriteVerbose("Creating the nic...");
                    nic = nicApi.Create(DataCenterId, newServer.Id, nic);

                    Utilities.DoWait(nic.Request);
                }

                server = serverApi.FindById(datacenter.Id, newServer.Id, depth: 5);

                datacenter = dcApi.FindById(DataCenterId, depth: 5);

                server = serverApi.FindById(datacenter.Id, newServer.Id, depth: 5);


                WriteObject(server);
            }
            catch (Exception ex)
            {
                WriteError(new ErrorRecord(ex, "", ErrorCategory.NotSpecified, null));
            }
        }
        static void Main(string[] args)
        {
            var configuration = new Configuration
            {
                Username = "******",
                Password = "******",
            };
            var dcApi              = new DataCenterApi(configuration);
            var serverApi          = new ServerApi(configuration);
            var volumeApi          = new VolumeApi(configuration);
            var attachedVolumesApi = new AttachedVolumesApi(configuration);
            var nicApi             = new NetworkInterfacesApi(configuration);


            // CreateDataCenterRequest.
            // The only required field is DataCenterName.
            // If location parameter is left empty data center will be created in the default region of the customer
            var datacenter = new Datacenter
            {
                Properties = new DatacenterProperties
                {
                    Name        = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(),
                    Description = "Unit test for .Net SDK PB REST V2",
                    Location    = "us/lasdev"
                }
            };

            // Response will contain Id of a newly created data center.
            datacenter = dcApi.Create(datacenter);

            // CreateServer.
            // DataCenterId: Defines the data center wherein the server is to be created.
            // AvailabilityZone: Selects the zone in which the server is going to be created (AUTO, ZONE_1, ZONE_2).
            // Cores: Number of cores to be assigned to the specified server. Required field.
            // InternetAccess: Set to TRUE to connect the server to the Internet via the specified LAN ID.
            // OsType: Sets the OS type of the server.
            // Ram: Number of RAM memory (in MiB) to be assigned to the server.
            var server = new Server
            {
                Properties = new ServerProperties
                {
                    Name  = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(),
                    Cores = 1,
                    Ram   = 256
                }
            };

            // response will contain Id of a newly created server.
            server = serverApi.Create(datacenter.Id, server);

            // UpdateServer
            // ServerId: Id of the server to be updated.
            // ServerName: Renames target virtual server
            // Cores: Updates the amount of cores of the target virtual server
            // Ram: Updates the RAM memory (in MiB) of the target virtual server. The minimum RAM size is 256 MiB
            server = serverApi.PartialUpdate(datacenter.Id, server.Id, new ServerProperties {
                Name = server.Properties.Name + " -Updated"
            });


            // CreateVolume
            // DataCenterId: Defines the data center wherein the storage is to be created. If left empty, the storage will be created in a new data center
            // Size: Storage size (in GiB). Required Field.
            // Type: SSD or HDD disk type, Required Field
            var volume = new Volume
            {
                Properties = new VolumeProperties
                {
                    Size    = 4,
                    Image   = "fbaae2b2-c899-11e5-aa10-52540005ab80",
                    Type    = "HDD",
                    Name    = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(),
                    SshKeys = new System.Collections.Generic.List <string> {
                        "hQGOEJeFL91EG3+l9TtRbWNjzhDVHeLuL3NWee6bekA="
                    }
                }
            };

            // Response will contain Id of a newly created volume.
            volume = volumeApi.Create(datacenter.Id, volume);

            // AttachVolume
            // ServerId: Identifier of the target virtual storage. Required field.
            // StorageId: Identifier of the virtual storage to be connected. Required field.
            // BusType: Bus type to which the storage will be connected
            attachedVolumesApi.AttachVolume(datacenter.Id, server.Id, new Volume {
                Id = volume.Id
            });

            attachedVolumesApi.DetachVolume(datacenter.Id, server.Id, volume.Id);

            // Fetches list of all Data Centers
            var dcs = dcApi.FindAll(depth: 5);

            // Fetches list of all Servers
            var servers = serverApi.FindAll(datacenter.Id, depth: 5);

            // Fetches list of all Volumes
            var volumes = volumeApi.FindAll(datacenter.Id, depth: 5);

            // CreateNicRequest
            // Identifier of the target virtual server. Required field.
            // Nic: Names the NIC
            // Toggles usage of ProfitBricks DHCP
            // Lan
            var nic = new Nic {
                Properties = new NicProperties {
                    Lan = 1, Dhcp = true, Name = "Nic name"
                }
            };

            nic = nicApi.Create(datacenter.Id, server.Id, nic);
        }
Exemple #24
0
 /// <summary>
 /// Hands down the specified data to the data-link layer implementation of the NIC.
 /// </summary>
 /// <param name="destination">The phyical destination address.</param>
 /// <param name="data">The data to send as the frame's payload.</param>
 /// <param name="type">The type of the data.</param>
 public void Output(MacAddress destination, byte[] data, EtherType type =
                    EtherType.IPv4)
 {
     Nic.Output(destination, data, type);
 }
        private void Configure()
        {
            Configuration = new Configuration
            {
                Username = "******",
                Password = "******",

            };

            dcApi = new DataCenterApi(configuration);
            serverApi = new ServerApi(configuration);
            nicApi = new NetworkInterfacesApi(configuration);
            lbApi = new LoadBalancerApi(configuration);
            fwApi = new FirewallRuleApi(configuration);

            //Create a datacenter.
            if (datacenter == null)
            {
                datacenter = new Datacenter
                {
                    Properties = new DatacenterProperties
                    {
                        Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(),
                        Description = "Unit test for .Net SDK PB REST V2",
                        Location = "us/lasdev"
                    }
                };

                datacenter = dcApi.Create(datacenter);
            }

            if (server == null)
            {
                server = new Server
                {
                    Properties = new ServerProperties
                    {
                        Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(),
                        Cores = 1,
                        Ram = 256
                    }
                };

                server = serverApi.Create(datacenter.Id, server);
                DoWait(server.Request);
            }

            if (nic == null)
            {
                nic = new Nic { Properties = new NicProperties { Lan = 1 } };

                nic = nicApi.Create(datacenter.Id, server.Id, nic);

                DoWait(nic.Request);
            }

            bool isBusy = true;
            while (isBusy == true)
            {
                var temp = dcApi.FindById(datacenter.Id);
                if (temp.Metadata.State != "BUSY") isBusy = false;
                Thread.Sleep(5000);
            }
        }
Exemple #26
0
        static void ParseNics(string infile, string outfile)
        {
            Console.WriteLine($"-=-=- Parsing nics: {infile} -> {outfile} -=-=-");
            string[] rows = File.ReadAllLines(infile);

            var nics = new List <Nic>();


            string currentserver = null;
            Nic    currentnic    = null;
            string currentname   = null;

            foreach (string row in rows)
            {
                if (row.StartsWith("Server: "))
                {
                    currentserver = row.Substring(8);
                    continue;
                }
                if (currentserver == null || row == string.Empty || row.StartsWith("----------"))
                {
                    continue;
                }
                if (!row.Contains(' '))
                {
                    continue;
                }

                string name  = row.Contains(':') ? row.Split(':').First().TrimStart() : row;
                string value = row.Contains(':') ? row.Split(new char[] { ':' }, 2).Last().Trim() : string.Empty;

                if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("Verbose")))
                {
                    Console.WriteLine($"name: '{name}'");
                    Console.WriteLine($"value: '{value}'");
                }

                if (name.StartsWith("Configuration for interface "))
                {
                    currentnic = new Nic {
                        _server = currentserver
                    };
                    currentnic._name = name.Substring(28).Trim('"');
                }
                else if (name == "DHCP enabled")
                {
                    currentnic._dhcpenabled = value;
                }
                else if (name == "IP Address")
                {
                    if (currentnic._ipaddresses == null)
                    {
                        currentnic._ipaddresses = value;
                    }
                    else
                    {
                        currentnic._ipaddresses += ", " + value;
                    }
                }
                else if (name == "Subnet Prefix")
                {
                    if (currentnic._subnetprefixes == null)
                    {
                        currentnic._subnetprefixes = value;
                    }
                    else
                    {
                        currentnic._subnetprefixes += ", " + value;
                    }
                }
                else if (name == "Default Gateway")
                {
                    currentnic._defaultgateway = value;
                }
                else if (name == "Gateway Metric")
                {
                    currentnic._gatewaymetric = value;
                }
                else if (name == "InterfaceMetric")
                {
                    currentnic._interfacemetric = value;
                    nics.Add(currentnic);
                    currentnic = null;
                }
                else
                {
                    Console.WriteLine($"Unknown row: Server: {currentnic._server}, name: '{name}'");
                }

                if (name != string.Empty)
                {
                    currentname = name;
                }
            }

            var output = new List <string>
            {
                "Server\tName\t_DhcpEnabled\tIpAddresses\t" +
                "SubnetPrefixes\tDefaultGateway\tGatewayMetric\tInterfaceMetric"
            };

            output.AddRange(nics
                            .Select(s =>
                                    $"{s._server}\t{s._name}\t{s._dhcpenabled}\t{s._ipaddresses}\t" +
                                    $"{s._subnetprefixes}\t{s._defaultgateway}\t{s._gatewaymetric}\t{s._interfacemetric}")
                            .OrderBy(s => s));

            File.WriteAllLines(outfile, output);

            return;
        }
        /// <summary>
        /// Create a Nic Adds a NIC to the target server
        /// </summary>
        /// <param name="datacenterId"></param>
        /// <param name="serverId"></param>
        /// <param name="nic">Nic to be created</param>
        /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param>
        /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n	- depth=0: only direct properties are included. Children (servers etc.) are not included\n	- depth=1: direct properties and children references are included\n	- depth=2: direct properties and children properties are included\n	- depth=3: direct properties and children properties and children&#39;s children are included\n	- depth=... and so on</param>
        /// <returns>Task of Nic</returns>
        public async System.Threading.Tasks.Task<Nic> CreateAsync(string datacenterId, string serverId, Nic nic, bool? parameter = null, int? depth = null)
        {
            ApiResponse<Nic> response = await CreateAsyncWithHttpInfo(datacenterId, serverId, nic, parameter, depth);
            return response.Data;

        }
Exemple #28
0
		internal Ssid(Nic owner, WlanInternSsidEntry ssidEntry, bool isConnectedOne)
		{
			_owner = owner;
			Reload(ssidEntry, isConnectedOne);
		}
        /// <summary>
        /// Create a Nic Adds a NIC to the target server
        /// </summary>
        /// <param name="datacenterId"></param>
        /// <param name="serverId"></param>
        /// <param name="nic">Nic to be created</param>
        /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param>
        /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n	- depth=0: only direct properties are included. Children (servers etc.) are not included\n	- depth=1: direct properties and children references are included\n	- depth=2: direct properties and children properties are included\n	- depth=3: direct properties and children properties and children&#39;s children are included\n	- depth=... and so on</param>
        /// <returns>Task of ApiResponse (Nic)</returns>
        public async System.Threading.Tasks.Task<ApiResponse<Nic>> CreateAsyncWithHttpInfo(string datacenterId, string serverId, Nic nic, bool? parameter = null, int? depth = null)
        {
            // verify the required parameter 'datacenterId' is set
            if (datacenterId == null) throw new ApiException(400, "Missing required parameter 'datacenterId' when calling Create");
            // verify the required parameter 'serverId' is set
            if (serverId == null) throw new ApiException(400, "Missing required parameter 'serverId' when calling Create");
            // verify the required parameter 'nic' is set
            if (nic == null) throw new ApiException(400, "Missing required parameter 'nic' when calling Create");


            var path_ = "/datacenters/{datacenterId}/servers/{serverId}/nics";

            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            Object postBody = null;

            // to determine the Content-Type header
            String[] httpContentTypes = new String[] {
                "application/json", "application/vnd.profitbricks.resource+json"
            };
            String httpContentType = Configuration.ApiClient.SelectHeaderContentType(httpContentTypes);

            // to determine the Accept header
            String[] httpHeaderAccepts = new String[] {
                "application/vnd.profitbricks.resource+json"
            };
            String httpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(httpHeaderAccepts);
            if (httpHeaderAccept != null)
                headerParams.Add("Accept", httpHeaderAccept);

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            if (datacenterId != null) pathParams.Add("datacenterId", Configuration.ApiClient.ParameterToString(datacenterId)); // path parameter
            if (serverId != null) pathParams.Add("serverId", Configuration.ApiClient.ParameterToString(serverId)); // path parameter

            if (parameter != null) queryParams.Add("parameter", Configuration.ApiClient.ParameterToString(parameter)); // query parameter
            if (depth != null) queryParams.Add("depth", Configuration.ApiClient.ParameterToString(depth)); // query parameter



            postBody = Configuration.ApiClient.Serialize(nic); // http body (model) parameter



            // authentication (basicAuth) required

            // http basic authentication required
            if (!String.IsNullOrEmpty(Configuration.Username) || !String.IsNullOrEmpty(Configuration.Password))
            {
                headerParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password);
            }


            // make the HTTP request
            IRestResponse response = (IRestResponse)await Configuration.ApiClient.CallApiAsync(path_,
                Method.POST, queryParams, postBody, headerParams, formParams, fileParams,
                pathParams, httpContentType);

            int statusCode = (int)response.StatusCode;

            if (statusCode >= 400)
                throw new ApiException(statusCode, "Error calling Create: " + response.Content, response.Content);
            else if (statusCode == 0)
                throw new ApiException(statusCode, "Error calling Create: " + response.ErrorMessage, response.ErrorMessage);

            return new ApiResponse<Nic>(statusCode,
                response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                (Nic)Configuration.ApiClient.Deserialize(response, typeof(Nic)));

        }
Exemple #30
0
		internal ReleaseFunction(Nic owner) : base(owner)
		{
		}
Exemple #31
0
        public void ReceiveCallback(IAsyncResult ar)
        {
            UdpClient  u        = (UdpClient)((UdpState)(ar.AsyncState)).u;
            IPEndPoint e        = (IPEndPoint)((UdpState)(ar.AsyncState)).e;
            bool       MatchMac = false;

            try
            {
                Byte[] receiveBytes = u.EndReceive(ar, ref e);

                if (receiveBytes.Length > 0)
                {
                    Log.LogLine("Remote sent WOL Packet on listening port [packet lenth {0}]", receiveBytes.Length);

                    StringBuilder hex = new StringBuilder(receiveBytes.Length * 2);
                    //foreach (byte b in receiveBytes) hex.AppendFormat("{0:x2}:", b);
                    for (int b = 6; b < 12; b++)
                    {
                        hex.AppendFormat("{0:x2}", receiveBytes[b]);
                    }

                    foreach (System.Net.NetworkInformation.NetworkInterface Nic in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
                    {
                        //Console.Write(Nic.OperationalStatus + " - " + Nic.GetPhysicalAddress().ToString() + "\n");
                        if (hex.ToString().ToUpper() == Nic.GetPhysicalAddress().ToString().ToUpper())
                        {
                            Log.LogLine("[{0}] Magic packet match host MAC Address", hex.ToString().ToUpper());
                            MatchMac = true;
                        }
                    }

                    // Start XBMC Only if MAC Address Match
                    if (MatchMac)
                    {
                        StartXBMC();
                    }
                    else
                    {
                        Log.LogLine("[{0}] Magic packet doesn't match host MAC Address: Ignoring WOL request", hex.ToString().ToUpper());
                    }

                    // BeginReceive Loop
                    s.e = e;
                    s.u = u;
                    u.BeginReceive(new AsyncCallback(ReceiveCallback), s);
                    Log.LogLine("Now listening on UDP port {0}", c.wake_on_lan_port);
                }
            }
            catch (ObjectDisposedException ex)
            {
                if (_quiting)
                {
                    Log.LogLine("No longer listening on UDP port {0}", c.wake_on_lan_port);
                    waitHandle.Set();
                    return;
                }
                Log.LogLine("[ObjectDisposedException] " + ex);
                StartListener();
            }
            catch (SocketException ex)
            {
                Log.LogLine("[SocketException] " + ex);
                StartListener();
            }
            catch (Exception)
            {
                // BeginReceive Loop
                s.e = e;
                s.u = u;
                u.BeginReceive(new AsyncCallback(ReceiveCallback), s);
            }
        }
Exemple #32
0
		internal Raw(Nic owner) : base(owner)
		{
		}
Exemple #33
0
		internal WwwConnectivity(Nic owner) : base(owner)
		{
		}
        static void Main(string[] args)
        {
            var configuration = new Configuration
            {
                Username = "******",
                Password = "******",

            };
            var dcApi = new DataCenterApi(configuration);
            var serverApi = new ServerApi(configuration);
            var volumeApi = new VolumeApi(configuration);
            var attachedVolumesApi = new AttachedVolumesApi(configuration);
            var nicApi = new NetworkInterfacesApi(configuration);

            // CreateDataCenterRequest.
            // The only required field is DataCenterName.
            // If location parameter is left empty data center will be created in the default region of the customer
            var datacenter = new Datacenter
            {
                Properties = new DatacenterProperties
                {
                    Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(),
                    Description = "Unit test for .Net SDK PB REST V2",
                    Location = "us/lasdev"
                }
            };

            // Response will contain Id of a newly created data center.
            datacenter = dcApi.Create(datacenter);

            // CreateServer.
            // DataCenterId: Defines the data center wherein the server is to be created.
            // AvailabilityZone: Selects the zone in which the server is going to be created (AUTO, ZONE_1, ZONE_2).
            // Cores: Number of cores to be assigned to the specified server. Required field.
            // InternetAccess: Set to TRUE to connect the server to the Internet via the specified LAN ID.
            // OsType: Sets the OS type of the server.
            // Ram: Number of RAM memory (in MiB) to be assigned to the server.
            var server = new Server
            {
                Properties = new ServerProperties
                {
                    Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(),
                    Cores = 1,
                    Ram = 256
                }
            };

            // response will contain Id of a newly created server.
            server = serverApi.Create(datacenter.Id, server);

            // UpdateServer
            // ServerId: Id of the server to be updated.
            // ServerName: Renames target virtual server
            // Cores: Updates the amount of cores of the target virtual server
            // Ram: Updates the RAM memory (in MiB) of the target virtual server. The minimum RAM size is 256 MiB
            server = serverApi.PartialUpdate(datacenter.Id, server.Id, new ServerProperties { Name = server.Properties.Name + " -Updated" });

            // CreateVolume
            // DataCenterId: Defines the data center wherein the storage is to be created. If left empty, the storage will be created in a new data center
            // Size: Storage size (in GiB). Required Field.
            // Type: SSD or HDD disk type, Required Field
            var volume = new Volume
            {
                Properties = new VolumeProperties
                {
                    Size = 4,
                    Image = "fbaae2b2-c899-11e5-aa10-52540005ab80",
                    Type = "HDD",
                    Name = ".Net V2 - Test " + DateTime.Now.ToShortTimeString(),
                    SshKeys = new System.Collections.Generic.List<string> { "hQGOEJeFL91EG3+l9TtRbWNjzhDVHeLuL3NWee6bekA=" }
                }
            };

            // Response will contain Id of a newly created volume.
            volume = volumeApi.Create(datacenter.Id, volume);

            // AttachVolume
            // ServerId: Identifier of the target virtual storage. Required field.
            // StorageId: Identifier of the virtual storage to be connected. Required field.
            // BusType: Bus type to which the storage will be connected
            attachedVolumesApi.AttachVolume(datacenter.Id, server.Id, new Volume { Id = volume.Id });

            attachedVolumesApi.DetachVolume(datacenter.Id, server.Id, volume.Id);

            // Fetches list of all Data Centers
            var dcs = dcApi.FindAll(depth: 5);

            // Fetches list of all Servers
            var servers = serverApi.FindAll(datacenter.Id, depth: 5);

            // Fetches list of all Volumes
            var volumes = volumeApi.FindAll(datacenter.Id, depth: 5);

            // CreateNicRequest
            // Identifier of the target virtual server. Required field.
            // Nic: Names the NIC
            // Toggles usage of ProfitBricks DHCP
            // Lan
            var nic = new Nic { Properties = new NicProperties { Lan = 1 , Dhcp = true, Name = "Nic name"} };

            nic = nicApi.Create(datacenter.Id, server.Id, nic);
        }
Exemple #35
0
 /// <summary>
 /// Initializes a new instance of the Interface class using the specified
 /// parameters.
 /// </summary>
 /// <param name="nic">The network interface card (NIC) this interface
 /// represents.</param>
 /// <param name="name">A unique name (such as eth0) for identifing the
 /// interface.</param>
 /// <param name="ipAddress">The IPv4 address to associate with this
 /// interface.</param>
 /// <param name="netmask">The subnetmask to assign to this interface.</param>
 /// <param name="gateway">The IPv4 address of the default gateway to
 /// configure this interface with.</param>
 /// <exception cref="ArgumentNullException">Thrown if any of the arguments
 /// is null.</exception>
 public Interface(Nic nic, string name, IpAddress ipAddress, IpAddress netmask,
                  IpAddress gateway = null)
 {
     Init(nic, name, ipAddress, netmask, gateway);
 }
 /// <summary>
 /// Create a Nic Adds a NIC to the target server
 /// </summary>
 /// <param name="datacenterId"></param> 
 /// <param name="serverId"></param> 
 /// <param name="nic">Nic to be created</param> 
 /// <param name="parameter">Controls whether response is pretty-printed (with indentation and new lines)</param> 
 /// <param name="depth">Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n	- depth=0: only direct properties are included. Children (servers etc.) are not included\n	- depth=1: direct properties and children references are included\n	- depth=2: direct properties and children properties are included\n	- depth=3: direct properties and children properties and children&#39;s children are included\n	- depth=... and so on</param> 
 /// <returns>Nic</returns>
 public Nic Create(string datacenterId, string serverId, Nic nic, bool? parameter = null, int? depth = null)
 {
     ApiResponse<Nic> response = CreateWithHttpInfo(datacenterId, serverId, nic, parameter, depth);
     return response.Data;
 }
Exemple #37
0
		internal Wlan(Nic owner) : base(owner)
		{
		}