[Ovirt-devel] [PATCH: ovirt-identify-node replacement 3/4] Removed ovirt-identify-node.
Arjun Roy
arroy at redhat.com
Wed Jul 8 18:39:58 UTC 2009
---
ovirt-identify-node/.gitignore | 3 -
ovirt-identify-node/AUTHOR | 1 -
ovirt-identify-node/COPYING | 339 -----------------------------
ovirt-identify-node/ChangeLog | 2 -
ovirt-identify-node/Makefile.am | 33 ---
ovirt-identify-node/NEWS | 2 -
ovirt-identify-node/README | 2 -
ovirt-identify-node/comm.c | 85 -------
ovirt-identify-node/debug.c | 50 -----
ovirt-identify-node/gather.c | 319 ---------------------------
ovirt-identify-node/hal_support.c | 61 -----
ovirt-identify-node/main.c | 248 ---------------------
ovirt-identify-node/ovirt-identify-node.h | 139 ------------
ovirt-identify-node/protocol.c | 293 -------------------------
14 files changed, 0 insertions(+), 1577 deletions(-)
delete mode 100644 ovirt-identify-node/.gitignore
delete mode 100644 ovirt-identify-node/AUTHOR
delete mode 100644 ovirt-identify-node/COPYING
delete mode 100644 ovirt-identify-node/ChangeLog
delete mode 100644 ovirt-identify-node/Makefile.am
delete mode 100644 ovirt-identify-node/NEWS
delete mode 100644 ovirt-identify-node/README
delete mode 100644 ovirt-identify-node/comm.c
delete mode 100644 ovirt-identify-node/debug.c
delete mode 100644 ovirt-identify-node/gather.c
delete mode 100644 ovirt-identify-node/hal_support.c
delete mode 100644 ovirt-identify-node/main.c
delete mode 100644 ovirt-identify-node/ovirt-identify-node.h
delete mode 100644 ovirt-identify-node/protocol.c
diff --git a/ovirt-identify-node/.gitignore b/ovirt-identify-node/.gitignore
deleted file mode 100644
index 0b2c3bd..0000000
--- a/ovirt-identify-node/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*.o
-.deps
-ovirt-identify-node
diff --git a/ovirt-identify-node/AUTHOR b/ovirt-identify-node/AUTHOR
deleted file mode 100644
index d37a107..0000000
--- a/ovirt-identify-node/AUTHOR
+++ /dev/null
@@ -1 +0,0 @@
-Darryl L. Pierce <dpierce at redhat.com>
diff --git a/ovirt-identify-node/COPYING b/ovirt-identify-node/COPYING
deleted file mode 100644
index d511905..0000000
--- a/ovirt-identify-node/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Lesser General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
diff --git a/ovirt-identify-node/ChangeLog b/ovirt-identify-node/ChangeLog
deleted file mode 100644
index 61dc8cc..0000000
--- a/ovirt-identify-node/ChangeLog
+++ /dev/null
@@ -1,2 +0,0 @@
-* Tue 17 Jun 2008 Darryl L. Pierce <dpierce at redhat.com> - 0.0.1-1
-- Created the initial RPM structure.
diff --git a/ovirt-identify-node/Makefile.am b/ovirt-identify-node/Makefile.am
deleted file mode 100644
index 980901c..0000000
--- a/ovirt-identify-node/Makefile.am
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2008 Red Hat, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA 02110-1301, USA. A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-bin_PROGRAMS = ovirt-identify-node
-
-EXTRA_DIST = AUTHOR
-
-ovirt_identify_node_SOURCES = \
- ovirt-identify-node.h \
- comm.c \
- gather.c \
- hal_support.c \
- main.c \
- protocol.c
-
-ovirt_identify_node_LDADD = \
- $(LDADD) $(DBUS_LIBS) $(HAL_LIBS) $(VIRT_LIBS)
-ovirt_identify_node_CPPFLAGS = \
- $(AM_CPPFLAGS) $(DBUS_CFLAGS) $(HAL_CFLAGS) $(VIRT_CFLAGS)
diff --git a/ovirt-identify-node/NEWS b/ovirt-identify-node/NEWS
deleted file mode 100644
index 139597f..0000000
--- a/ovirt-identify-node/NEWS
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
diff --git a/ovirt-identify-node/README b/ovirt-identify-node/README
deleted file mode 100644
index 139597f..0000000
--- a/ovirt-identify-node/README
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
diff --git a/ovirt-identify-node/comm.c b/ovirt-identify-node/comm.c
deleted file mode 100644
index ee5e174..0000000
--- a/ovirt-identify-node/comm.c
+++ /dev/null
@@ -1,85 +0,0 @@
-
-/* comm.c -- Contains communications routines.
- *
- * Copyright (C) 2008 Red Hat, Inc.
- * Written by Darryl L. Pierce <dpierce at redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA. A copy of the GNU General Public License is
- * also available at http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include "ovirt-identify-node.h"
-
-ssize_t
-saferead(int fd, char *buf, size_t count)
-{
- ssize_t bytes, offset;
-
- int len_left;
-
- int done = 0;
-
- offset = 0;
-
- len_left = count;
-
- DEBUG("Begin saferead(%d, %p, %zd)\n", fd, buf, count);
-
- while (!done) {
- DEBUG("Before read(%d,%p,%d)\n", fd, buf + offset, len_left);
-
- bytes = read(fd, buf + offset, len_left);
-
- DEBUG("After read: bytes=%zd\n", bytes);
-
- if (bytes == 0) {
- done = 1;
- } else if (bytes > 0) {
- offset += bytes;
- len_left -= bytes;
- done = 1;
- } else if (errno == EINTR) {
- continue;
- } else {
- done = 1;
- }
-
- DEBUG("End of decision loop: offset=%zd, len_left=%dl, done=%d\n",
- offset, len_left, done);
- }
-
- return offset;
-}
-
-ssize_t
-safewrite(int fd, const void *buf, size_t count)
-{
- size_t nwritten = 0;
-
- while (count > 0) {
- ssize_t r = write(fd, buf, count);
-
- if (r < 0 && errno == EINTR)
- continue;
- if (r < 0)
- return r;
- if (r == 0)
- return nwritten;
- buf = (const char *) buf + r;
- count -= r;
- nwritten += r;
- }
- return nwritten;
-}
diff --git a/ovirt-identify-node/debug.c b/ovirt-identify-node/debug.c
deleted file mode 100644
index 36a7f59..0000000
--- a/ovirt-identify-node/debug.c
+++ /dev/null
@@ -1,50 +0,0 @@
-
-/* debug.c -- Debugging methods.
- *
- * Copyright (C) 2008 Red Hat, Inc.
- * Written by Darryl L. Pierce <dpierce at redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA. A copy of the GNU General Public License is
- * also available at http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include "ovirt-identify-node.h"
-
-void
-debug_cpu_info(void)
-{
- fprintf(stdout, "Node Info:\n");
- fprintf(stdout, " UUID: %s\n", uuid);
- fprintf(stdout, " Arch: %s\n", arch);
- fprintf(stdout, " Memory: %s\n", memsize);
-
- cpu_info_ptr current = cpu_info;
-
- while (current != NULL) {
- fprintf(stdout, "\n");
- fprintf(stdout, " CPU Number: %s\n", current->cpu_num);
- fprintf(stdout, " Core Number: %s\n", current->core_num);
- fprintf(stdout, "Number of Cores: %s\n", current->number_of_cores);
- fprintf(stdout, " Vendor: %s\n", current->vendor);
- fprintf(stdout, " Model: %s\n", current->model);
- fprintf(stdout, " Family: %s\n", current->family);
- fprintf(stdout, " CPUID Level: %s\n", current->cpuid_level);
- fprintf(stdout, " CPU Speed: %s\n", current->speed);
- fprintf(stdout, " Cache Size: %s\n", current->cache);
- fprintf(stdout, " CPU Flags: %s\n", current->flags);
-
- current = current->next;
- }
-}
diff --git a/ovirt-identify-node/gather.c b/ovirt-identify-node/gather.c
deleted file mode 100644
index ae0bb73..0000000
--- a/ovirt-identify-node/gather.c
+++ /dev/null
@@ -1,319 +0,0 @@
-
-/* gather.c -- Contains methods for collecting data about the system.
- *
- * Copyright (C) 2008 Red Hat, Inc.
- * Written by Darryl L. Pierce <dpierce at redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA. A copy of the GNU General Public License is
- * also available at http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include "ovirt-identify-node.h"
-
-struct sockaddr_in sa;
-
-#define inaddrr(x) (*(struct in_addr *) &ifr.x[sizeof sa.sin_port])
-
-int
-init_gather(void)
-{
- int result = 1;
-
- hal_ctx = get_hal_ctx();
-
- if (hal_ctx != NULL) {
- result = 0;
- }
-
- return result;
-}
-
-int
-get_uuid(void)
-{
- const char *udi = "/org/freedesktop/Hal/devices/computer";
-
- const char *key = "system.hardware.uuid";
-
- VERBOSE("Getting system UUID.\n");
-
- int result = 1;
-
- int type;
-
- type = libhal_device_get_property_type(hal_ctx, udi, key, &dbus_error);
-
- if (type == LIBHAL_PROPERTY_TYPE_STRING) {
- char *value;
-
- DEBUG("%s/%s=%d\n", udi, key, type);
-
- value =
- libhal_device_get_property_string(hal_ctx, udi, key,
- &dbus_error);
- snprintf(uuid, BUFFER_LENGTH, "%s", value);
-
- DEBUG("UUID=%s\n", uuid);
-
- result = 0;
- } else {
- uuid[0] = 0;
- }
-
- return result;
-}
-
-/* Creates a new instance of type t_cpu_info and places it into the
- * linked list of CPUs.
- */
-cpu_info_ptr
-create_cpu_info(void)
-{
- cpu_info_ptr result = calloc(1, sizeof(t_cpu_info));
-
- bzero(result, sizeof(t_cpu_info));
-
- strcpy(result->core_num, "0");
- strcpy(result->number_of_cores, "1");
-
- return result;
-}
-
-int
-get_cpu_info(void)
-{
- int result = 1;
-
- FILE *inputfd;
-
- cpu_info_ptr current = NULL;
-
- /* in order to support Xen, this data will need to be gathered
- * from libvirt rather than directly from cpuinfo
- */
- if ((inputfd = fopen("/proc/cpuinfo", "rb")) != NULL) {
- VERBOSE("Parsing CPU information\n");
- do {
- char buffer[255];
-
- char label[BUFFER_LENGTH];
-
- char value[BUFFER_LENGTH];
-
- fgets(buffer, 255, inputfd);
- if (strlen(buffer) > 0)
- buffer[strlen(buffer) - 1] = '\0';
-
- get_label_and_value(buffer,
- label, BUFFER_LENGTH,
- value, BUFFER_LENGTH);
-
- DEBUG("label=\"%s\", value=\"%s\"\n", label, value);
-
- if (strlen(label)) {
- if (!strcmp(label, "processor")) {
- VERBOSE("Starting new CPU\n");
-
- cpu_info_ptr last = current;
-
- current = create_cpu_info();
- if (last != NULL) {
- last->next = current;
- } else {
- cpu_info = current;
- }
-
- COPY_VALUE_TO_BUFFER(value, current->cpu_num,
- BUFFER_LENGTH);
- } else
- /* core id and number of cores is not correct on
- * Xen machines
- */
- if (!strcmp(label, "core id")) {
- COPY_VALUE_TO_BUFFER(value, current->core_num,
- BUFFER_LENGTH);
- } else if (!strcmp(label, "cpu cores")) {
- COPY_VALUE_TO_BUFFER(value, current->number_of_cores,
- BUFFER_LENGTH);
- } else if (!strcmp(label, "vendor_id")) {
- COPY_VALUE_TO_BUFFER(value, current->vendor,
- BUFFER_LENGTH);
- } else if (!strcmp(label, "model")) {
- COPY_VALUE_TO_BUFFER(value, current->model,
- BUFFER_LENGTH);
- } else if (!strcmp(label, "cpu family")) {
- COPY_VALUE_TO_BUFFER(value, current->family,
- BUFFER_LENGTH);
- } else if (!strcmp(label, "cpuid level")) {
- COPY_VALUE_TO_BUFFER(value, current->cpuid_level,
- BUFFER_LENGTH);
- } else if (!strcmp(label, "cpu MHz")) {
- COPY_VALUE_TO_BUFFER(value, current->speed,
- BUFFER_LENGTH);
- } else if (!strcmp(label, "cache size")) {
- COPY_VALUE_TO_BUFFER(value, current->cache,
- BUFFER_LENGTH);
- } else if (!strcmp(label, "flags")) {
- COPY_VALUE_TO_BUFFER(value, current->flags,
- BUFFER_LENGTH);
- }
- }
-
- } while (!feof(inputfd));
-
- fclose(inputfd);
-
- result = 0;
- } else {
- VERBOSE("Unable to open /proc/cpuinfo\n");
- }
-
- return result;
-}
-
-/* Creates a new instance of type t_nic_info.
- */
-nic_info_ptr
-create_nic_info(void)
-{
- nic_info_ptr result = calloc(1, sizeof(t_nic_info));
-
- bzero(result, sizeof(t_nic_info));
-
- return result;
-}
-
-/* Determines the speed of the network interface.
- */
-void
-get_nic_data(char *nic, nic_info_ptr nic_info_p)
-{
- char *interface;
-
- struct ifreq ifr;
-
- int sockfd;
-
- struct ethtool_cmd ecmd;
-
- interface =
- libhal_device_get_property_string(hal_ctx, nic, "net.interface",
- &dbus_error);
- snprintf(nic_info_p->iface_name, BUFFER_LENGTH, "%s", interface);
- bzero(&ifr, sizeof(struct ifreq));
-
- sockfd = socket(AF_INET, SOCK_DGRAM, 0);
- if (sockfd >= 0) {
- int bandwidth;
-
- ifr.ifr_addr.sa_family = AF_INET;
- strncpy(ifr.ifr_name, interface, IFNAMSIZ - 1);
-
- if(!ioctl(sockfd,SIOCGIFADDR,&ifr)) {
-
- DEBUG("ip_address=%s\n",inet_ntoa(inaddrr(ifr_addr.sa_data)));
-
- snprintf(nic_info_p->ip_address, BUFFER_LENGTH, "%s",
- inet_ntoa(inaddrr(ifr_addr.sa_data)));
- }
-
- if(!ioctl(sockfd,SIOCGIFNETMASK,&ifr) &&
- strcmp("255.255.255.255", inet_ntoa(inaddrr(ifr_addr.sa_data)))) {
-
- DEBUG("netmask=%s",inet_ntoa(inaddrr(ifr_addr.sa_data)));
-
- snprintf(nic_info_p->netmask, BUFFER_LENGTH, "%s",
- inet_ntoa(inaddrr(ifr_addr.sa_data)));
- }
-
- if(!ioctl(sockfd,SIOCGIFBRDADDR,&ifr)) {
-
- DEBUG("broadcast=%s",inet_ntoa(inaddrr(ifr_addr.sa_data)));
-
- snprintf(nic_info_p->broadcast, BUFFER_LENGTH, "%s",
- inet_ntoa(inaddrr(ifr_addr.sa_data)));
- }
-
- ecmd.cmd = ETHTOOL_GSET;
- ifr.ifr_data = (caddr_t)&ecmd;
- ioctl(sockfd, SIOCETHTOOL, &ifr);
-
- bandwidth = 10;
- if (ecmd.supported & SUPPORTED_10000baseT_Full)
- bandwidth = 10000;
- else if (ecmd.supported & SUPPORTED_2500baseX_Full)
- bandwidth = 2500;
- else if (ecmd.supported & (SUPPORTED_1000baseT_Half |
- SUPPORTED_1000baseT_Full))
- bandwidth = 1000;
- else if (ecmd.supported & (SUPPORTED_100baseT_Half |
- SUPPORTED_100baseT_Full))
- bandwidth = 100;
- else if (ecmd.supported & (SUPPORTED_10baseT_Half |
- SUPPORTED_10baseT_Full))
- bandwidth = 10;
-
- snprintf(nic_info_p->bandwidth, BUFFER_LENGTH, "%d", bandwidth);
-
- close(sockfd);
- }
-}
-
-int
-get_nic_info(void)
-{
- int result = 0;
-
- nic_info_ptr current = NULL;
-
- nic_info_ptr last = NULL;
-
- char **nics;
-
- int num_results;
-
- int i;
-
- nics = libhal_find_device_by_capability(hal_ctx, "net.80203",
- &num_results, &dbus_error);
-
- DEBUG("Found %d NICs\n", num_results);
-
- for (i = 0; i < num_results; i++) {
- char *nic = nics[i];
-
- DEBUG("Starting new NIC; %s.\n", nic);
-
- if (current != NULL) {
- last = current;
- current = create_nic_info();
- last->next = current;
- } else {
- nic_info = current = create_nic_info();
- }
-
- snprintf(current->mac_address, BUFFER_LENGTH, "%s",
- libhal_device_get_property_string(hal_ctx, nic,
- "net.address",
- &dbus_error));
- get_nic_data(nic, current);
-
- DEBUG("NIC details: MAC:%s, speed:%s, IP:%s\n",
- current->mac_address, current->bandwidth,
- current->ip_address);
- }
-
- return result;
-}
diff --git a/ovirt-identify-node/hal_support.c b/ovirt-identify-node/hal_support.c
deleted file mode 100644
index 1b1d0ca..0000000
--- a/ovirt-identify-node/hal_support.c
+++ /dev/null
@@ -1,61 +0,0 @@
-
-/* hal_support.c -- Interfaces with the HAL libraries.
- *
- * Copyright (C) 2008 Red Hat, Inc.
- * Written by Darryl L. Pierce <dpierce at redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA. A copy of the GNU General Public License is
- * also available at http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include "ovirt-identify-node.h"
-
-DBusConnection *dbus_connection;
-
-DBusError dbus_error;
-
-LibHalContext *
-get_hal_ctx(void)
-{
- LibHalContext *result = NULL;
-
- LibHalContext *ctx;
-
- ctx = libhal_ctx_new();
- if (ctx != NULL) {
- dbus_error_init(&dbus_error);
- dbus_connection = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);
-
- if (!dbus_error_is_set(&dbus_error)) {
- libhal_ctx_set_dbus_connection(ctx, dbus_connection);
-
- if (libhal_ctx_init(ctx, &dbus_error)) {
- result = ctx;
- } else {
- fprintf(stderr,
- "Failed to initial libhal context: %s : %s\n",
- dbus_error.name, dbus_error.message);
- }
- } else {
- fprintf(stderr, "Unable to connect to system bus: %s : %s\n",
- dbus_error.name, dbus_error.message);
- dbus_error_free(&dbus_error);
- }
- } else {
- fprintf(stderr, "Unable to initialize HAL context.\n");
- }
-
- return result;
-}
diff --git a/ovirt-identify-node/main.c b/ovirt-identify-node/main.c
deleted file mode 100644
index 400ea54..0000000
--- a/ovirt-identify-node/main.c
+++ /dev/null
@@ -1,248 +0,0 @@
-
-/* identify-node -- Main entry point for the identify-node utility.
- *
- * Copyright (C) 2008 Red Hat, Inc.
- * Written by Darryl L. Pierce <dpierce at redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA. A copy of the GNU General Public License is
- * also available at http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include "ovirt-identify-node.h"
-
-int debug = 0;
-
-int verbose = 0;
-
-int testing = 0;
-
-char arch[BUFFER_LENGTH];
-
-char uuid[BUFFER_LENGTH];
-
-char memsize[BUFFER_LENGTH];
-
-char numcpus[BUFFER_LENGTH];
-
-char cpuspeed[BUFFER_LENGTH];
-
-char *hostname;
-
-int hostport = -1;
-
-char *management_interface;
-
-int socketfd;
-
-cpu_info_ptr cpu_info;
-
-nic_info_ptr nic_info;
-
-LibHalContext *hal_ctx;
-
-int
-main(int argc, char **argv)
-{
- int result = 1;
-
- virConnectPtr connection;
-
- virNodeInfo info;
-
- fprintf(stdout, "Sending oVirt Node details to server.\n");
-
- if (!config(argc, argv)) {
- VERBOSE("Connecting to libvirt.\n");
-
- connection =
- virConnectOpenReadOnly(testing ? "test:///default" : NULL);
-
- DEBUG("connection=%p\n", connection);
-
- if (connection) {
- VERBOSE("Retrieving node information.\n");
- if (!virNodeGetInfo(connection, &info)) {
- snprintf(arch, BUFFER_LENGTH, "%s", info.model);
- snprintf(memsize, BUFFER_LENGTH, "%ld", info.memory);
-
- cpu_info = NULL;
- nic_info = NULL;
-
- if (!init_gather() && !get_uuid() && !get_cpu_info()
- && !get_nic_info()) {
- if (!start_conversation() && !send_details()
- && !end_conversation()) {
- fprintf(stdout, "Finished!\n");
- result = 0;
- }
- } else {
- VERBOSE("Failed to get CPU info.\n");
- }
- } else {
- VERBOSE("Failed to get node info.\n");
- }
- } else {
- VERBOSE("Could not connect to libvirt.\n");
- }
- } else {
- usage();
- }
-
- return result;
-}
-
-int
-config(int argc, char **argv)
-{
- int result = 0;
-
- int option;
-
- while ((option = getopt(argc, argv, "s:p:m:dvth")) != -1) {
- DEBUG("Processing argument: %c (optarg:%s)\n", option, optarg);
-
- switch (option) {
- case 's':
- hostname = optarg;
- break;
- case 'p':
- hostport = atoi(optarg);
- break;
- case 'm':
- management_interface = optarg;
- break;
- case 't':
- testing = 1;
- break;
- case 'd':
- debug = 1;
- break;
- case 'v':
- verbose = 1;
- break;
- case 'h':
- // fall thru
- default:
- result = 1;
- break;
- }
- }
-
- // verify that required options are provided
- if (hostname == NULL || strlen(hostname) == 0) {
- fprintf(stderr,
- "ERROR: The server name is required. (-s [hostname])\n");
- result = 1;
- }
-
- if (hostport <= 0) {
- fprintf(stderr,
- "ERROR: The server port is required. (-p [port])\n");
- result = 1;
- }
-
- return result;
-}
-
-void
-usage()
-{
- fprintf(stdout, "\n");
- fprintf(stdout, "Usage: ovirt-identify [OPTION]\n");
- fprintf(stdout, "\n");
- fprintf(stdout, "\t-s [server]\t\tThe remote server's hostname.\n");
- fprintf(stdout, "\t-p [port]\t\tThe remote server's port.\n");
- fprintf(stdout, "\t-m [iface]\t\tThe management interface.\n");
- fprintf(stdout,
- "\t-d\t\tDisplays debug information during execution.\n");
- fprintf(stdout,
- "\t-v\t\tDisplays verbose information during execution.\n");
- fprintf(stdout,
- "\t-h\t\tDisplays this help information and then exits.\n");
- fprintf(stdout, "\n");
-}
-
-void
-get_label_and_value(char *text,
- char *label, size_t label_length,
- char *value, size_t value_length)
-{
- int offset = 0;
-
- int which = 0; /* 0 = label, 1 = value */
-
- char *current = text;
-
- /* iterate through the text supplied and find where the
- * label ends with a colon, then copy that into the supplied
- * label buffer and trim any trailing spaces
- */
-
- while (current != NULL && *current != '\0') {
- /* if we're on the separator, then switch modes and reset
- * the offset indicator, otherwise just process the character
- */
- if (which == 0 && *current == ':') {
- which = 1;
- offset = 0;
- } else {
- char *buffer = (which == 0 ? label : value);
-
- int length = (which == 0 ? label_length : value_length);
-
- /* only copy if we're past the first character and it's not
- * a space
- */
- if ((offset > 0 || (*current != 9 && *current != ' '))
- && offset < (length - 1)) {
- buffer[offset++] = *current;
- buffer[offset] = 0;
- }
- }
-
- current++;
- }
-
- /* now trim all trailing spaces from the values */
- while (label[strlen(label) - 1] == 9)
- label[strlen(label) - 1] = 0;
- while (value[strlen(value) - 1] == 9)
- value[strlen(value) - 1] = 0;
-}
-
-int
-get_text(const char *const expected)
-{
- int result = 1;
-
- int received;
-
- char buffer[BUFFER_LENGTH];
-
- bzero(buffer, BUFFER_LENGTH);
-
- VERBOSE("Looking to receive %s\n", expected);
-
- received = saferead(socketfd, buffer, BUFFER_LENGTH);
-
- buffer[received - 1] = 0;
-
- VERBOSE("Received \"%s\": size=%d (trimmed ending carriage return)\n",
- buffer, received);
-
- result = strcmp(expected, buffer);
-
- return result;
-}
diff --git a/ovirt-identify-node/ovirt-identify-node.h b/ovirt-identify-node/ovirt-identify-node.h
deleted file mode 100644
index bf439bd..0000000
--- a/ovirt-identify-node/ovirt-identify-node.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Copyright (C) 2008 Red Hat, Inc.
- * Written by Darryl L. Pierce <dpierce at redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA. A copy of the GNU General Public License is
- * also available at http://www.gnu.org/copyleft/gpl.html.
- */
-
-#ifndef __OVIRT_IDENTIFY_NODE_H
-#define __OVIRT_IDENTIFY_NODE_H
-
-#include <errno.h>
-#include <getopt.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <arpa/inet.h>
-
-#include <hal/libhal.h>
-
-#include <libvirt/libvirt.h>
-
-#include <linux/types.h>
-#include <linux/ethtool.h>
-#include <linux/sockios.h>
-#include <linux/if.h>
-
-#include <netinet/in.h>
-
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#define BUFFER_LENGTH 768
-
-typedef struct _cpu_info {
- char cpu_num[BUFFER_LENGTH];
- char core_num[BUFFER_LENGTH];
- char number_of_cores[BUFFER_LENGTH];
- char vendor[BUFFER_LENGTH];
- char model[BUFFER_LENGTH];
- char family[BUFFER_LENGTH];
- char cpuid_level[BUFFER_LENGTH];
- char speed[BUFFER_LENGTH];
- char cache[BUFFER_LENGTH];
- char flags[BUFFER_LENGTH];
- struct _cpu_info* next;
-} t_cpu_info;
-
-typedef t_cpu_info* cpu_info_ptr;
-
-typedef struct _nic_info {
- char mac_address[BUFFER_LENGTH];
- char bandwidth[BUFFER_LENGTH];
- char ip_address[BUFFER_LENGTH];
- char netmask[BUFFER_LENGTH];
- char iface_name[BUFFER_LENGTH];
- char broadcast[BUFFER_LENGTH];
- struct _nic_info* next;
-} t_nic_info;
-
-typedef t_nic_info* nic_info_ptr;
-
-int config(int argc,char** argv);
-void usage(void);
-
-void get_label_and_value(char* text,
- char* label,size_t label_length,
- char* value,size_t value_length);
-
-int send_text(char* text);
-int get_text(const char *const expected);
-
-/* comm.c */
-ssize_t saferead(int fd, char *buf, size_t count);
-ssize_t safewrite(int fd, const void *buf, size_t count);
-
-/* debug.c */
-void debug_cpu_info(void);
-
-/* gather.c */
-int init_gather(void);
-int get_uuid(void);
-int get_cpu_info(void);
-int get_nic_info(void);
-
-/* hal_support.c */
-LibHalContext* get_hal_ctx(void);
-
-/* protocol.c */
-int create_connection(void);
-int start_conversation(void);
-int send_details(void);
-int end_conversation(void);
-int send_value(char* label,char* value);
-int send_text(char* text);
-
-/* variables */
-extern int debug;
-extern int verbose;
-extern int testing;
-
-extern char arch[BUFFER_LENGTH];
-extern char uuid[BUFFER_LENGTH];
-extern char memsize[BUFFER_LENGTH];
-extern char numcpus[BUFFER_LENGTH];
-extern char cpuspeed[BUFFER_LENGTH];
-extern char *hostname;
-extern int hostport;
-extern char *management_interface;
-extern int socketfd;
-extern cpu_info_ptr cpu_info;
-extern nic_info_ptr nic_info;
-
-extern DBusConnection* dbus_connection;
-extern DBusError dbus_error;
-extern LibHalContext* hal_ctx;
-
-/* macros */
-#define DEBUG(arg...) if(debug) fprintf(stderr, ##arg)
-#define VERBOSE(arg...) if(verbose) fprintf(stdout, ##arg)
-#define COPY_VALUE_TO_BUFFER(value,buffer,length) \
- snprintf(buffer,length,"%s",value)
-
-#endif
diff --git a/ovirt-identify-node/protocol.c b/ovirt-identify-node/protocol.c
deleted file mode 100644
index 1099ebb..0000000
--- a/ovirt-identify-node/protocol.c
+++ /dev/null
@@ -1,293 +0,0 @@
-
-/* protocol.c -- Manages the communication between the oVirt Node and
- * the oVirt Server.
- *
- * Copyright (C) 2008 Red Hat, Inc.
- * Written by Darryl L. Pierce <dpierce at redhat.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA. A copy of the GNU General Public License is
- * also available at http://www.gnu.org/copyleft/gpl.html.
- */
-
-#include "ovirt-identify-node.h"
-
-int
-create_connection(void)
-{
- int result = 1;
-
- struct addrinfo hints;
-
- struct addrinfo *results;
-
- char port[6];
-
- struct addrinfo *rptr;
-
- VERBOSE("Creating the socket connection.\n");
-
- memset(&hints, 0, sizeof(struct addrinfo));
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = 0;
- hints.ai_protocol = 0;
-
- VERBOSE("Searching for host candidates.\n");
-
- snprintf(port, 6, "%d", hostport);
-
- if (!getaddrinfo(hostname, port, &hints, &results)) {
- VERBOSE
- ("Got address information. Searching for a proper entry.\n");
-
- for (rptr = results; rptr != NULL; rptr = rptr->ai_next) {
- if (debug) {
- fprintf(stdout,
- "Attempting connection: family=%d, socket type=%d, protocol=%d\n",
- rptr->ai_family, rptr->ai_socktype,
- rptr->ai_protocol);
- }
-
- socketfd =
- socket(rptr->ai_family, rptr->ai_socktype,
- rptr->ai_protocol);
-
- if (socketfd == -1) {
- continue;
- }
-
- if (connect(socketfd, rptr->ai_addr, rptr->ai_addrlen) != -1) {
- break;
- }
- // invalid connection, so close it
- VERBOSE("Invalid connection.\n");
- close(socketfd);
- }
-
- if (rptr == NULL) {
- VERBOSE("Unable to connect to server %s:%d\n", hostname,
- hostport);
- } else {
- // success
- result = 0;
- }
-
- freeaddrinfo(results);
- } else {
- VERBOSE("No hosts found. Exiting...\n");
- }
-
- DEBUG("create_connection: result=%d\n", result);
-
- return result;
-}
-
-int
-start_conversation(void)
-{
- int result = 1;
-
- VERBOSE("Starting conversation with %s:%d.\n", hostname, hostport);
-
- if (!create_connection()) {
- VERBOSE("Connected.\n");
-
- if (!get_text("HELLO?")) {
- VERBOSE("Checking for handshake.\n");
-
- if (!send_text("HELLO!")) {
- VERBOSE("Handshake received. Starting conversation.\n");
-
- if (!get_text("MODE?")) {
- VERBOSE("Shifting to IDENTIFY mode.\n");
-
- if (!send_text("IDENTIFY"))
- result = 0;
- } else {
- VERBOSE("Was not asked for a mode.\n");
- }
- }
- } else {
- VERBOSE("Did not receive a proper handshake.\n");
- }
- }
-
- else {
- VERBOSE("Did not get a connection.\n");
- }
-
- DEBUG("start_conversation: result=%d\n", result);
-
- return result;
-}
-
-/* Transmits the CPU details to the server.
- */
-int
-send_cpu_details(void)
-{
- int result = 1;
-
- cpu_info_ptr current = cpu_info;
-
- while (current != NULL) {
- send_text("CPU");
-
- if (!(get_text("CPUINFO?")) &&
- (!send_value("CPUNUM", current->cpu_num)) &&
- (!send_value("CORENUM", current->core_num)) &&
- (!send_value("NUMCORES", current->number_of_cores)) &&
- (!send_value("VENDOR", current->vendor)) &&
- (!send_value("MODEL", current->model)) &&
- (!send_value("FAMILY", current->family)) &&
- (!send_value("CPUIDLVL", current->cpuid_level)) &&
- (!send_value("SPEED", current->speed)) &&
- (!send_value("CACHE", current->cache)) &&
- (!send_value("FLAGS", current->flags))) {
- send_text("ENDCPU");
- result = get_text("ACK CPU");
- }
-
- current = current->next;
- }
-
-
- return result;
-}
-
-/* Transmits the NIC details to the server.
- */
-int
-send_nic_details(void)
-{
- int result = 1;
-
- nic_info_ptr current = nic_info;
-
- /* only send NIC details if we found NICs to process */
- if(current) {
- int sent_count = 0;
- while (current != NULL) {
- if((!management_interface) || (strcmp(management_interface, current->iface_name))) {
- send_text("NIC");
-
- if (!(get_text("NICINFO?")) &&
- (!send_value("MAC", current->mac_address)) &&
- (!send_value("BANDWIDTH", current->bandwidth)) &&
- (!send_value("IFACE_NAME", current->iface_name)) &&
- (!send_value("IP_ADDRESS", current->ip_address)) &&
- (!send_value("NETMASK", current->netmask)) &&
- (!send_value("BROADCAST", current->broadcast))) {
- send_text("ENDNIC");
- result = get_text("ACK NIC");
- sent_count++;
- }
-
- current = current->next;
- } else {
- current = current->next;
- }
- }
-
- /* if no nics were sent, then set default success */
- if( sent_count == 0)
- result = 0;
-
- } else { result = 0; }
-
- return result;
-}
-
-int
-send_details(void)
-{
- int result = 1;
-
- VERBOSE("Sending node details.\n");
-
- if (!get_text("INFO?")) {
- if ((!send_value("ARCH", arch)) &&
- (!send_value("UUID", uuid)) &&
- (!send_value("MEMSIZE", memsize)) &&
- (!send_cpu_details() && !send_nic_details())) {
- if (!send_text("ENDINFO"))
- result = 0;
- }
- } else {
- VERBOSE("Was not interrogated for hardware info.\n");
- }
-
- return result;
-}
-
-int
-end_conversation(void)
-{
- int result = 0;
-
- VERBOSE("Ending conversation.\n");
-
- send_text("ENDINFO");
-
- close(socketfd);
-
- return result;
-}
-
-int
-send_value(char *label, char *value)
-{
- char buffer[BUFFER_LENGTH];
-
- int result = 1;
-
- char expected[BUFFER_LENGTH];
-
- if (value != NULL && strlen(value) > 0) {
-
- snprintf(buffer, BUFFER_LENGTH, "%s=%s", label, value);
-
- if (!send_text(buffer)) {
- snprintf(expected, BUFFER_LENGTH, "ACK %s", label);
-
- VERBOSE("Expecting \"%s\"\n", expected);
-
- result = get_text(expected);
- }
- } else { result = 0; }
-
- return result;
-}
-
-int
-send_text(char *text)
-{
- int result = 1;
-
- int sent;
-
- VERBOSE("Sending: \"%s\"\n", text);
-
- sent = safewrite(socketfd, text, strlen(text));
- sent += safewrite(socketfd, "\n", 1);
-
- if (sent >= 0) {
- DEBUG("Sent %d bytes total.\n", sent);
-
- result = 0;
- }
-
- return result;
-}
--
1.6.2.5
More information about the ovirt-devel
mailing list