Browse Source

StarlingX open source release updates

Signed-off-by: Dean Troyer <dtroyer@gmail.com>
changes/91/574491/1
Dean Troyer 4 years ago
parent
commit
85cd488bef
  1. 10
      CONTRIBUTORS.wrs
  2. 202
      LICENSE
  3. 5
      README.rst
  4. 12
      guest-agent/PKG-INFO
  5. 2
      guest-agent/centos/build_srpm.data
  6. 137
      guest-agent/centos/guest-scale-agent.spec
  7. 202
      guest-agent/guest-scale-agent-2.0/LICENSE
  8. 110
      guest-agent/guest-scale-agent-2.0/Makefile
  9. 74
      guest-agent/guest-scale-agent-2.0/Makefile.sdk
  10. 4
      guest-agent/guest-scale-agent-2.0/bin/.gitignore
  11. 243
      guest-agent/guest-scale-agent-2.0/docs/README.txt
  12. BIN
      guest-agent/guest-scale-agent-2.0/docs/TiS-Guest-Resource-Scaling.doc
  13. BIN
      guest-agent/guest-scale-agent-2.0/docs/TiS-Guest-Resource-Scaling.pdf
  14. 515
      guest-agent/guest-scale-agent-2.0/guest_scale_agent.c
  15. 534
      guest-agent/guest-scale-agent-2.0/guest_scale_helper.c
  16. 81
      guest-agent/guest-scale-agent-2.0/misc.h
  17. 4
      guest-agent/guest-scale-agent-2.0/obj/.gitignore
  18. 150
      guest-agent/guest-scale-agent-2.0/parser.c
  19. 67
      guest-agent/guest-scale-agent-2.0/parser_test.c
  20. 107
      guest-agent/guest-scale-agent-2.0/scripts/app_scale_helper
  21. 13
      guest-agent/guest-scale-agent-2.0/scripts/guest-scale-agent.service
  22. 64
      guest-agent/guest-scale-agent-2.0/scripts/init_offline_cpus
  23. 12
      guest-agent/guest-scale-agent-2.0/scripts/offline-cpus.service
  24. 54
      guest-agent/guest-scale-agent-2.0/scripts/offline_cpus
  25. 202
      guest-client/LICENSE
  26. 12
      guest-client/PKG-INFO
  27. 3
      guest-client/centos/build_srpm.data
  28. 114
      guest-client/centos/guest-client.spec
  29. 202
      guest-client/guest-client-3.0.1/LICENSE
  30. 119
      guest-client/guest-client-3.0.1/Makefile
  31. 72
      guest-client/guest-client-3.0.1/README
  32. 291
      guest-client/guest-client-3.0.1/README.build
  33. 385
      guest-client/guest-client-3.0.1/README.usage
  34. BIN
      guest-client/guest-client-3.0.1/TiS-Guest-Heartbeat-Service.doc
  35. BIN
      guest-client/guest-client-3.0.1/TiS-Guest-Heartbeat-Service.pdf
  36. 84
      guest-client/guest-client-3.0.1/guest_client/Makefile
  37. 183
      guest-client/guest-client-3.0.1/guest_client/scripts/guest-client.init
  38. 57
      guest-client/guest-client-3.0.1/guest_client/scripts/guest-client.service
  39. 171
      guest-client/guest-client-3.0.1/guest_client/scripts/guest-client.systemd
  40. 116
      guest-client/guest-client-3.0.1/guest_client/scripts/guest_heartbeat.conf
  41. 165
      guest-client/guest-client-3.0.1/guest_client/scripts/sample_event_handling_script
  42. 42
      guest-client/guest-client-3.0.1/guest_client/scripts/sample_health_check_script
  43. 94
      guest-client/guest-client-3.0.1/guest_client/src/Makefile
  44. 351
      guest-client/guest-client-3.0.1/guest_client/src/guest_channel.c
  45. 95
      guest-client/guest-client-3.0.1/guest_client/src/guest_channel.h
  46. 312
      guest-client/guest-client-3.0.1/guest_client/src/guest_child_death.c
  47. 79
      guest-client/guest-client-3.0.1/guest_client/src/guest_child_death.h
  48. 67
      guest-client/guest-client-3.0.1/guest_client/src/guest_client.c
  49. 163
      guest-client/guest-client-3.0.1/guest_client/src/guest_config.c
  50. 73
      guest-client/guest-client-3.0.1/guest_client/src/guest_config.h
  51. 146
      guest-client/guest-client-3.0.1/guest_client/src/guest_debug.c
  52. 102
      guest-client/guest-client-3.0.1/guest_client/src/guest_debug.h
  53. 55
      guest-client/guest-client-3.0.1/guest_client/src/guest_limits.h
  54. 375
      guest-client/guest-client-3.0.1/guest_client/src/guest_process.c
  55. 50
      guest-client/guest-client-3.0.1/guest_client/src/guest_process.h
  56. 410
      guest-client/guest-client-3.0.1/guest_client/src/guest_script.c
  57. 75
      guest-client/guest-client-3.0.1/guest_client/src/guest_script.h
  58. 254
      guest-client/guest-client-3.0.1/guest_client/src/guest_selobj.c
  59. 83
      guest-client/guest-client-3.0.1/guest_client/src/guest_selobj.h
  60. 129
      guest-client/guest-client-3.0.1/guest_client/src/guest_signal.c
  61. 63
      guest-client/guest-client-3.0.1/guest_client/src/guest_signal.h
  62. 203
      guest-client/guest-client-3.0.1/guest_client/src/guest_stream.c
  63. 104
      guest-client/guest-client-3.0.1/guest_client/src/guest_stream.h
  64. 82
      guest-client/guest-client-3.0.1/guest_client/src/guest_time.c
  65. 68
      guest-client/guest-client-3.0.1/guest_client/src/guest_time.h
  66. 323
      guest-client/guest-client-3.0.1/guest_client/src/guest_timer.c
  67. 99
      guest-client/guest-client-3.0.1/guest_client/src/guest_timer.h
  68. 47
      guest-client/guest-client-3.0.1/guest_client/src/guest_types.c
  69. 54
      guest-client/guest-client-3.0.1/guest_client/src/guest_types.h
  70. 331
      guest-client/guest-client-3.0.1/guest_client/src/guest_unix.c
  71. 94
      guest-client/guest-client-3.0.1/guest_client/src/guest_unix.h
  72. 121
      guest-client/guest-client-3.0.1/guest_client/src/guest_utils.c
  73. 65
      guest-client/guest-client-3.0.1/guest_client/src/guest_utils.h
  74. 62
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/Makefile
  75. 318
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat.c
  76. 55
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat.h
  77. 235
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_config.c
  78. 78
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_config.h
  79. 118
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_disabled_state.c
  80. 81
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_disabled_state.h
  81. 698
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabled_state.c
  82. 81
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabled_state.h
  83. 211
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabling_state.c
  84. 81
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_enabling_state.h
  85. 204
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_event_script.c
  86. 73
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_event_script.h
  87. 369
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_fsm.c
  88. 105
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_fsm.h
  89. 124
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_health_script.c
  90. 71
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_health_script.h
  91. 112
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_initial_state.c
  92. 81
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_initial_state.h
  93. 1400
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_mgmt_api.c
  94. 83
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_mgmt_api.h
  95. 1209
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_msg.c
  96. 150
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_msg.h
  97. 134
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_msg_defs.h
  98. 132
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_types.c
  99. 114
      guest-client/guest-client-3.0.1/guest_client/src/heartbeat/guest_heartbeat_types.h
  100. 77
      guest-client/guest-client-3.0.1/guest_client/src/test/Makefile
  101. Some files were not shown because too many files have changed in this diff Show More

10
CONTRIBUTORS.wrs

@ -0,0 +1,10 @@
The following contributors from Wind River have developed the seed code in this
repository. We look forward to community collaboration and contributions for
additional features, enhancements and refactoring.
Contributors:
=============
Bart Wensley <Barton.Wensley@windriver.com>
Tao Liu <Tao.Liu@windriver.com>
Eric Macdonald <Eric.MacDonald@windriver.com>
Jack Ding <Jack.Ding@windriver.com>

202
LICENSE

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

5
README.rst

@ -0,0 +1,5 @@
=======
stx-nfv
=======
StarlingX NFVI Orchestration

12
guest-agent/PKG-INFO

@ -0,0 +1,12 @@
Metadata-Version: 1.1
Name: guest-scale-agent
Version: 2.0
Summary: Titanium Cloud agent and helper app to scale VMs up/down
Home-page:
Author: Windriver
Author-email: info@windriver.com
License: Apache-2.0
Description: Titanium Cloud agent and helper app to scale VMs up/down
Platform: UNKNOWN

2
guest-agent/centos/build_srpm.data

@ -0,0 +1,2 @@
SRC_DIR="guest-scale-agent-2.0"
TIS_PATCH_VER=6

137
guest-agent/centos/guest-scale-agent.spec

@ -0,0 +1,137 @@
Summary: Titanium Cloud agent and helper app to scale VMs up/down
Name: guest-scale-agent
Version: 2.0
%define patchlevel %{tis_patch_ver}
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: base
Packager: Wind River <info@windriver.com>
URL: unknown
%define cgcs_sdk_deploy_dir /opt/deploy/cgcs_sdk
Source0: %{name}-%{version}.tar.gz
BuildRequires: json-c-devel
BuildRequires: host-guest-comm-dev
BuildRequires: guest-host-comm-dev
BuildRequires: systemd-devel
Requires: bash
%description
Titanium Cloud agent and helper app to scale VMs up/down
%package -n guest-scale-agent-dbg
Summary: Titanium Cloud agent and helper app to scale VMs up/down - Debugging files
Group: devel
%description -n guest-scale-agent-dbg
Titanium Cloud agent and helper app to scale VMs up/down This package contains ELF
symbols and related sources for debugging purposes.
%package -n guest-scale-agent-dev
Summary: Titanium Cloud agent and helper app to scale VMs up/down - Development files
Group: devel
Requires: guest-scale-agent = %{version}-%{release}
%description -n guest-scale-agent-dev
Titanium Cloud agent and helper app to scale VMs up/down This package contains
symbolic links, header files, and related items necessary for software
development.
%package -n guest-scale-helper
Summary: Titanium Cloud agent and helper app to scale VMs up/down
Group: base
Requires: rtld(GNU_HASH)
%description -n guest-scale-helper
Titanium Cloud agent and helper app to scale VMs up/down
%package -n %{name}-cgts-sdk
Summary: SDK files for Titanium Cloud agent and helper app to scale VMs up/down
Group: devel
%description -n %{name}-cgts-sdk
SDK files for Titanium Cloud agent and helper app to scale VMs up/down
%prep
%setup
%build
VER=%{version}
MAJOR=`echo $VER | awk -F . '{print $1}'`
MINOR=`echo $VER | awk -F . '{print $2}'`
PATCH=%{patchlevel}
make all VER=${VER} MAJOR=${MAJOR} MINOR=${MINOR} PATCH=${PATCH}
%global _buildsubdir %{_builddir}/%{name}-%{version}
%install
install -d 750 -d %{buildroot}/usr/sbin
install -d 750 -d %{buildroot}%{_sysconfdir}/init.d
install -m 750 -d %{buildroot}/usr
install -m 750 -d %{buildroot}/usr/src
install -m 750 -d %{buildroot}/usr/src/debug
install -m 750 -d %{buildroot}/usr/src/debug/%{name}-%{version}
install -d 750 -d %{buildroot}/usr/sbin/.debug
install -m 750 %{_buildsubdir}/scripts/app_scale_helper %{buildroot}/usr/sbin/app_scale_helper
install -m 750 %{_buildsubdir}/scripts/offline_cpus %{buildroot}/usr/sbin/offline_cpus
install -m 750 %{_buildsubdir}/bin/guest_scale_helper %{buildroot}/usr/sbin/guest_scale_helper
install -m 750 %{_buildsubdir}/bin/guest_scale_agent %{buildroot}/usr/sbin/guest_scale_agent
install -m 750 %{_buildsubdir}/scripts/init_offline_cpus %{buildroot}/etc/init.d/offline_cpus
install -m 750 %{_buildsubdir}/bin/guest_scale_agent %{buildroot}/usr/sbin/.debug/guest_scale_agent
install -d %{buildroot}%{_unitdir}
install -m 750 %{_buildsubdir}/scripts/offline-cpus.service %{buildroot}%{_unitdir}/offline-cpus.service
install -m 750 %{_buildsubdir}/scripts/guest-scale-agent.service %{buildroot}%{_unitdir}/guest-scale-agent.service
# Deploy to the SDK deployment directory
install -d %{buildroot}%{cgcs_sdk_deploy_dir}
install -m 644 sdk/wrs-guest-scale-%{version}.%{patchlevel}.tgz %{buildroot}%{cgcs_sdk_deploy_dir}/wrs-guest-scale-%{version}.%{patchlevel}.tgz
%post
%systemd_post offline-cpus.service
%systemd_post guest-scale-agent.service
/usr/bin/systemctl enable offline-cpus.service >/dev/null 2>&1
/usr/bin/systemctl enable guest-scale-agent.service >/dev/null 2>&1
%preun
%systemd_preun offline-cpus.service
%systemd_preun guest-scale-agent.service
%postun
%systemd_postun guest-scale-agent.service
%systemd_postun offline-cpus.service
%files
%defattr(-,root,root,-)
/usr/sbin/guest_scale_agent
/usr/sbin/offline_cpus
/usr/sbin/app_scale_helper
/etc/init.d/offline_cpus
%{_unitdir}/offline-cpus.service
%{_unitdir}/guest-scale-agent.service
%files -n guest-scale-agent-dbg
%defattr(-,root,root,-)
/usr/src/debug/*
/usr/sbin/.debug/guest_scale_agent
%files -n guest-scale-agent-dev
%defattr(-,root,root,-)
/usr/sbin/.debug/guest_scale_agent
%files -n guest-scale-helper
%defattr(-,root,root,-)
/usr/sbin/guest_scale_helper
%files -n %{name}-cgts-sdk
%{cgcs_sdk_deploy_dir}/wrs-guest-scale-%{version}.%{patchlevel}.tgz

202
guest-agent/guest-scale-agent-2.0/LICENSE

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

110
guest-agent/guest-scale-agent-2.0/Makefile

@ -0,0 +1,110 @@
#
# BSD LICENSE
#
# Copyright(c) 2013-2016, Wind River Systems, Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Wind River Systems nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Note: if you change either Makefile or Makefile.sdk you need to manually
# do a "make clean" and then "make".
EXECS = guest_scale_helper guest_scale_agent
CFLAGS= -g -Wall
ODIR=obj
BINDIR=bin
BINEXECS=$(addprefix $(BINDIR)/, $(EXECS))
GUEST_SCALE_HELPER_SRCS = guest_scale_helper.c parser.c
GUEST_SCALE_HELPER_OBJ := $(patsubst %,$(ODIR)/%,$(GUEST_SCALE_HELPER_SRCS:.c=.o))
GUEST_SCALE_AGENT_SRCS= guest_scale_agent.c parser.c
GUEST_SCALE_AGENT_OBJ := $(patsubst %,$(ODIR)/%,$(GUEST_SCALE_AGENT_SRCS:.c=.o))
OBJS = $(GUEST_SCALE_OBJ) $(GUEST_SCALE_AGENT_OBJ)
DEPS = $(OBJS:.o=.d) sdk/sdk.d
-include $(DEPS)
EXPORT_SDK := wrs-guest-scale-$(MAJOR).$(MINOR).$(PATCH)
# SYSROOT = $(shell for i in $(LD) ; do echo $$i; done | grep sysroot= | awk -F = '{ print $$2 }'`)
SYSROOT = $(shell echo "$(LD)" | sed -n -e 's/^.*sysroot=//p' | awk '{ print $$1 }')
LIBSERVERGROUP_VER = $(shell find $(SYSROOT) | grep libservergroup.so. | sed -n -e 's/^.*libservergroup\.so\.//p')
print-%:
@echo $* = $($*)
printvars:
@$(foreach V,$(sort $(.VARIABLES)), $(if $(filter-out environment% default automatic, $(origin $V)),$(warning $V=$($V) ($(value $V)))))
.PHONY: printvars
all: host_all
host_all: $(BINEXECS) sdk/$(EXPORT_SDK).tgz
# The dependency tracking for the SDK tarball is rather crude. If any
# file changes they're all copied over again. This is quick, so it's
# not worth getting fancy.
sdk/$(EXPORT_SDK).tgz: printvars
@echo "Making SDK"
@mkdir -p sdk/$(EXPORT_SDK)
@mkdir -p sdk/$(EXPORT_SDK)/bin
@mkdir -p sdk/$(EXPORT_SDK)/obj
@mkdir -p sdk/$(EXPORT_SDK)/scripts
@cp scripts/* sdk/$(EXPORT_SDK)/scripts
@echo "MAJOR=$(MAJOR)" > sdk/$(EXPORT_SDK)/Makefile
@echo "MINOR=$(MINOR)" >> sdk/$(EXPORT_SDK)/Makefile
@echo "PATCH=$(PATCH)" >> sdk/$(EXPORT_SDK)/Makefile
@cat Makefile.sdk >> sdk/$(EXPORT_SDK)/Makefile
@cat docs/README.txt | sed 's/1\.0\.0/$(MAJOR).$(MINOR).$(PATCH)/' | sed 's/9.9.9/${LIBSERVERGROUP_VER}/' > sdk/$(EXPORT_SDK)/README.txt
@cp docs/TiS-Guest-Resource-Scaling.pdf sdk/$(EXPORT_SDK)/TiS-Guest-Resource-Scaling.pdf
@cp LICENSE sdk/$(EXPORT_SDK)/LICENSE
@cp $(GUEST_SCALE_AGENT_SRCS) sdk/$(EXPORT_SDK)
@cp misc.h sdk/$(EXPORT_SDK)
@cd sdk && tar czf $(EXPORT_SDK).tgz $(EXPORT_SDK)
@echo -n "sdk/$(EXPORT_SDK).tgz: Makefile.sdk docs/README.txt docs/TiS-Guest-Resource-Scaling.pdf " > sdk/sdk.d
@echo -n "scripts/init_offline_cpus scripts/offline_cpus scripts/offline-cpus.service" >> sdk/sdk.d
@echo -n "scripts/app_scale_helper " >> sdk/sdk.d
@echo -n "$(GUEST_SCALE_AGENT_SRCS) " >> sdk/sdk.d
@echo "misc.h " >> sdk/sdk.d
@echo '*' > sdk/.gitignore
$(ODIR)/%.o: %.c
$(CC) -c $(CFLAGS) $(CFLAGS2) -MMD -o $@ $<
$(BINDIR)/guest_scale_agent: $(GUEST_SCALE_AGENT_OBJ)
$(CC) -o $@ $^ $(LDFLAGS) -lguesthostmsg -ljson-c
$(BINDIR)/guest_scale_helper: $(GUEST_SCALE_HELPER_OBJ)
$(CC) -o $@ $^ $(LDFLAGS) -lhostguestmsg -ljson-c
# Add the host clean as a dependency to the SDK stuff
clean: host_clean
host_clean:
rm -rf sdk

74
guest-agent/guest-scale-agent-2.0/Makefile.sdk

@ -0,0 +1,74 @@
#
# BSD LICENSE
#
# Copyright(c) 2013-2016, Wind River Systems, Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Wind River Systems nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
.PHONY: all clean
EXECS= guest_scale_agent
CFLAGS= -g -Wall
ODIR=obj
BINDIR=bin
GUEST_SCALE_AGENT_SRCS= guest_scale_agent.c parser.c
GUEST_SCALE_AGENT_OBJ := $(patsubst %,$(ODIR)/%,$(GUEST_SCALE_AGENT_SRCS:.c=.o))
BINEXECS=$(addprefix $(BINDIR)/, $(EXECS))
OBJS = $(GUEST_SCALE_AGENT_OBJ)
_DEPS = *.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))
DEPS = $(OBJS:.o=.d)
-include $(DEPS)
WRS_SERVER_GROUP_DIR ?= $(shell find ../wrs-server-group*[0-9] -maxdepth 0 -type d | sort | tail -n 1)
WRS_SERVER_GROUP_INC2 = $(WRS_SERVER_GROUP_DIR)/include
WRS_SERVER_GROUP_INC ?= $(shell if [ -d $(WRS_SERVER_GROUP_INC2) ]; then echo "$(WRS_SERVER_GROUP_INC2)"; else echo "/usr/include"; fi)
WRS_SERVER_GROUP_LIB2 = $(WRS_SERVER_GROUP_DIR)/lib
WRS_SERVER_GROUP_LIB3 = $(shell if [ -d /usr/lib64 ]; then echo "/usr/lib64"; else echo "/usr/lib"; fi)
WRS_SERVER_GROUP_LIB ?= $(shell if [ -d $(WRS_SERVER_GROUP_LIB2) ]; then echo "$(WRS_SERVER_GROUP_LIB2)"; else echo "$(WRS_SERVER_GROUP_LIB3)"; fi)
CFLAGS += -I$(WRS_SERVER_GROUP_INC)
LDFLAGS += -L$(WRS_SERVER_GROUP_LIB)
$(ODIR)/%.o: %.c
$(CC) -c $(CFLAGS) $(CFLAGS2) -MMD -o $@ $<
all: $(BINEXECS)
$(BINDIR)/guest_scale_agent: $(GUEST_SCALE_AGENT_OBJ)
$(CC) -o $@ $^ $(LDFLAGS) -lguesthostmsg -ljson-c
clean:
rm -rf $(ODIR)/* *~ core $(BINDIR)/*

4
guest-agent/guest-scale-agent-2.0/bin/.gitignore vendored

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

243
guest-agent/guest-scale-agent-2.0/docs/README.txt

@ -0,0 +1,243 @@
BSD LICENSE
Copyright(c) 2013-2016, Wind River Systems, Inc.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Wind River Systems nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-----------------------------------------------------------------------
DESCRIPTION
===========
Guest Server Scaling is a service to allow a guest to scale the capacity of a
single guest server up and down on demand.
Current supported scaling operation is CPU scaling.
The resources can be scaled up/down from the nova CLI or GUI. Scaling can also
be set up via heat to be automatically triggered based on Ceilometer statistics.
(This will not be covered in this document, see the full documentation and the
heat SDK for how to configure heat templates for scaling a single guest server.)
This package contains an agent and a number of scripts to be included in the
guest image. These will handle the guest side of the coordinated efforts
involved in scaling up/down guest resources.
DEPENDENCIES
============
NOTE that this wrs-guest-scale SDK module has both a compile-time and run-time
dependency on the wrs-server-group SDK module.
This wrs-guest-scale SDK module requires that the wrs-server-group SDK tarball
has been previously extracted and built, and that the resulting libraries
and headers have been placed in a location that can be found by the normal build
tools, or the WRS_SERVER_GROUP_DIR environment variable has been set.
The output of BOTH the wrs-guest-scale SDK module and the wrs-server-group SDK
module are required to be installed in a guest image for guest resource scaling.
REQUIREMENTS
============
Compilation:
Linux OS, x86_64 architecture
gcc compiler
development libraries and headers for glibc
development libraries and headers for libguesthostmsg
(built by the wrs-server-group SDK package)
development libraries and headers for json-c
VM Runtime:
Linux OS, x86_64 architecture; CONFIG_HOTPLUG_CPU=y|m
runtime libraries for glibc
runtime libraries for libguesthostmsg
"guest_agent" binary daemon
(provided by the wrs-server-group SDK package)
runtime libraries for json-c
The code has been tested with glibc 2.15, gcc 4.6 and json-c 0.12.99 but it
should run on other versions without difficulty.
DELIVERABLE
===========
The Guest Server Scaling service is delivered as source with the required
Makefiles in a compressed tarball called "wrs-guest-scale-#.#.#.tgz", such that
it can be compiled for the applicable guest linux distribution.
COMPILE
=======
Pre-requisite:
Ensure that the wrs-server-group SDK tarball has been previously extracted and
built, and that the resulting libraries and headers have been placed in a
location that can be found by the normal build tools, or the WRS_SERVER_GROUP_DIR
environment variable has been set.
Extract the tarball contents:
tar xvf wrs-guest-scale-#.#.#.tgz
To compile:
# Note: assumes wrs-server-group-#.#.#.tgz has already been extracted and compiled.
cd wrs-guest-scale-#.#.#
# If wrs-guest-scale-#.#.#.tgz and wrs-server-group-#.#.#.tgz where extracted in a common directory
make
# Otherwise supply the path to where wrs-server-group can be found. e.g.
make WRS_SERVER_GROUP_DIR=/usr/src/wrs-server-group-#.#.#
This will produce:
1) An executable "bin/guest_scale_agent". This handles the basic vCPU scaling
in the guest, and calls out to a helper script if present to support
application-specific customization. It should be configured to respawn
(via /etc/inittab or some other process monitor) if it dies for any reason.
This executable must be installed into the guest (e.g. in "/usr/sbin") and configured
to run at startup as early as possible.
NOTE
The "guest_agent" executable from the wrs-server-group SDK package MUST ALSO
be installed into the guest (e.g. in "/usr/bin"), configured to run at startup
as early as possible and configured to respawn via /etc/inittab or some other
process monitor (in case it dies for any reason).
2) A script "script/app_scale_helper". This is an optional script that is
intended to allow for app-specific customization. If present, it must be
installed in "/usr/sbin". If present, it will be called by "guest_scale_agent"
when scaling in either direction.
3) A script "script/offline_cpus". This must be run later in the init sequence,
after guest_scale_agent has started up but before the application has started
any CPU-affined applications. A helper script "script/init_offline_cpus" has
been provided, and should be installed to "/etc/init.d/offline_cpus. The
"offline_cpus" script will offline vCPUs in the guest to match the status on
the hypervisor. This covers the case where we are booting up with some CPUs
offlined by the hypervisor.
4) For systemd users, the files "scripts/guest-scale-agent.service" and
"scripts/offline-cpus.service" should be copied to /lib/systemd/system/.
Note:
The inclusion of the files into the build system and the guest image and the
configuration of the guest startup scripts is left up to the user to allow for
different build systems and init subsystems in the guest.
INSTALL
=======
Installing in a running VM:
As the root user
1) Copy "bin/guest_scale_agent" to /usr/sbin in the VM.
2) Copy "scripts/app_scale_helper" and "scripts/offline_cpus" to /usr/sbin in the VM.
3) Copy "scripts/init_offline_cpus" to "/etc/init.d/offline_cpus". (Note the name change.)
4) Copy "scripts/guest-scale-agent.service" and "scripts/offline-cpus.service" to
/lib/systemd/system/.
5) Run "systemctl enable guest-scale-agent.service", "systemctl enable offline-cpus.service",
"systemctl start guest-scale-agent.service", "systemctl start offline-cpus.service"
The VM should now be ready to scale up and down.
USAGE
=====
The service is designed to be simple to use. A basic description is given
below, but more details are provided in the source and scripts.
1) Create a new flavor (or edit an existing flavor) such that the number of
vCPUs in the flavor matches the desired maximum number of vCPUs. To specify the
minimum number of vCPUs, create an "extra spec" metadata entry for the flavor
with a key of "wrs:min_vcpus" and a value that is an integer number between one
and the max number of vCPUs. This can be done from the CLI or the GUI. (In the
GUI select the "Admin" tab, go to the "Flavor" navigation link, click on a
flavor name, select the "Extra Specs" tab, click on "Create", select
"Minimum Number of CPUs" from the pulldown, and enter the desired value.)
2) Build BOTH the wrs-server-group SDK package and this wrs-guest-scale package,
and install the output of BOTH packages in an image. Lastly, ensure that the
CONFIG_HOTPLUG_CPU kernel config option is set in the image kernel.
3) Boot the image. It will come up with the full set of vCPUs.
4) To reduce the number of online vCPUs in the guest server, run
"nova scale <server> cpu down" from the controller (or anywhere else you can run
nova commands). This will pass a message up into the guest, where it will be
handled by "guest_scale_agent". That in turn will call out to
"/usr/sbin/app_scale_helper" (if it exists) which is expected to pick a vCPU to
offline. This script can be modified/replaced as needed for application-
specific purposes. By default, it will select the highest-numbered online vCPU.
If the script isn't present or errors out, then "guest_scale_agent" will itself
select the highest-numbered online vCPU as the one to be offlined. It will then
tell the guest kernel to offline the selected vCPU, and will pass the selected
vCPU back down to the hypervisor, which will adjust vCPU affinity so that the
underlying physical CPU can be freed up for use by other VMs. At this point
displaying the information for the guest server will show it using less than the
maximum number of cpus.
5) To increase the number of online vCPUs, run "nova scale <server> cpu up".
Assuming the resources are available the hypervisor will allocate a physical CPU
and will associate it with the guest server. "guest_scale_agent" will set the
lowest-numbered offline vCPU to "online", and will pass the vCPU number to
"/usr/sbin/app_scale_helper" (if it exists) for the application to do any
special handling that may be required.
The behaviour of a scaled-down server during various nova operations is as
follows:
live migration: server remains scaled-down
pause/unpause: server remains scaled-down
stop/start: server remains scaled-down
evacuation: server remains scaled-down
rebuild: server remains scaled-down
automatic restart on crash: server remains scaled-down
cold migration: server reverts to max vcpus
resize: server reverts to max vcpus for the new flavor
If a snapshot is taken of a scaled-down server, a new server booting the
snapshot will start with the number of vCPUs specified by the flavor.
CAVEATS
=======
It is possible for the scale-up operation to fail if the compute node has
already allocated all of its resources to other guests. If this happens,
the system will not do any automatic migration to try to free up resources.
Manual action will be required to free up resources.
Any CPUs that are handling userspace DPDK/AVP packet processing should not be
offlined. It may appear to work, but may lead to packet loss. This can be
enforced by setting the wrs:min_vcpus value appropriately high.
If hyperthreading is used, the flavor must set hw:cpu_thread_policy to
isolate and set cpu_policy to dedicated.

BIN
guest-agent/guest-scale-agent-2.0/docs/TiS-Guest-Resource-Scaling.doc

Binary file not shown.

BIN
guest-agent/guest-scale-agent-2.0/docs/TiS-Guest-Resource-Scaling.pdf

Binary file not shown.

515
guest-agent/guest-scale-agent-2.0/guest_scale_agent.c

@ -0,0 +1,515 @@
/**
* Copyright (c) <2013-2016>, Wind River Systems, Inc.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1) Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2) Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* 3) Neither the name of Wind River Systems nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <errno.h>
#include <error.h>
#include <fcntl.h>
#include <poll.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/select.h>
#include <cgcs/guest_host_msg.h>
#include <json-c/json.h>
#include "misc.h"
gh_info_t *info;
/* Scaling Request/Response message is encoded in JSON format.
The message sent out to UNIX socket is a null-terminated JSON format string
without embedded newlines.
Format:
{key:value,key:value,..., key:value}
Key/value pairs for Scaling Request:
"version": <integer> - version of the interface
"timeout_ms": <integer> - timeout for app_scale_helper scripts
"resource": cpu - indicate the resouce to scale.
Only cpu is currently supported.
"direction“: "up or down
"online_cpu": <integer> - vcpu number to online when scale up
"online_cpus": <array of integers> - array of current online cpus
when request was sent.
example: [0,1,2,3,4,5]
Key/value pairs for Scaling Response:
"version": <integer>
"resource": cpu
"direction“: "up or down
"online_cpu": <integer> - vcpu number to online when scale up
"offline_cpu": <integer> - actual offlined vcpu number
"online_cpus": <array of integers> - array of current online cpus
when response was sent.
"result": "success" or "fail"
"err_msg": <string> - error message if result is fail
*/
#define CPU_SCRIPT "/usr/sbin/app_scale_helper"
// generic function to call out to helper script
// need to add support for timeout in here in case script hangs
int call_helper_script(char *cmd, int timeout_ms)
{
FILE *fp;
int rc;
fp = popen(cmd, "w");
if (fp) {
rc = pclose(fp);
if (rc == -1) {
ERR_LOG("pclose failed: %m");
return -1;
} else {
if (WIFEXITED(rc)) {
rc = WEXITSTATUS(rc);
if (rc == 127) {
ERR_LOG("problem with shell or helper script, possibly script missing");
return -1;
} else
return rc;
} else {
return -1;
}
}
} else {
ERR_LOG("popen failed due to fork/pipe/memory");
return -1;
}
}
int online_cpu(unsigned cpu)
{
int fd;
int rc;
char buf[100];
char val;
snprintf(buf, sizeof(buf), "/sys/devices/system/cpu/cpu%u/online", cpu);
fd = open(buf, O_RDWR);
if (fd < 0) {
ERR_LOG("can't open cpu online path: %m");
return -1;
}
rc = read(fd, &val, 1);
if (rc != 1){
ERR_LOG("can't read cpu online value: %m");
return -1;
}
if (val == '1') {
ERR_LOG("cpu %d is already online", cpu);
return 0;
}
val = '1';
rc = write(fd, &val, 1);
if (rc != 1){
ERR_LOG("can't set cpu %d online", cpu);
return -1;
}
return 0;
}
int offline_cpu(unsigned cpu)
{
int fd;
int rc;
char buf[100];
char val;
snprintf(buf, sizeof(buf), "/sys/devices/system/cpu/cpu%u/online", cpu);
fd = open(buf, O_RDWR);
if (fd < 0) {
ERR_LOG("can't open cpu online path: %m");
return -1;
}
rc = read(fd, &val, 1);
if (rc != 1){
ERR_LOG("can't read cpu online value: %m");
return -1;
}
if (val == '0') {
ERR_LOG("cpu %d is already offline\n", cpu);
return 0;
}
val = '0';
rc = write(fd, &val, 1);
if (rc != 1){
ERR_LOG("can't set cpu %d offline", cpu);
return -1;
}
return 0;
}
// read /sys/devices/system/cpu/online and get the last cpu listed
int get_highest_online_cpu(void)
{
int fd, rc;
char buf[256];
char *start;
unsigned int cpu;
fd = open("/sys/devices/system/cpu/online", O_RDONLY);
if (fd < 0) {
ERR_LOG("can't fopen /sys/devices/system/cpu/online: %m");
return -1;
}
rc = read(fd, buf, sizeof(buf));
if (rc < 2) {
ERR_LOG("error parsing /sys/devices/system/cpu/online, too few chars");
return -1;
}
// go to the end of the string
start = buf+rc-1;
if(*start != '\n') {
ERR_LOG("error parsing /sys/devices/system/cpu/online, not null-terminated");
return -1;
}
// now go backwards until we get to a separator or the beginning of the string
while ((*start != ',') && (*start != '-') && (start != buf))
start--;
start++;
rc = sscanf(start, "%u", &cpu);
if (rc != 1) {
ERR_LOG("error parsing /sys/devices/system/cpu/online, bad number");
return -1;
}
return cpu;
}
char *get_online_cpu_range(void)
{
FILE *file;
int rc;
char *str = NULL;
file = fopen("/sys/devices/system/cpu/online", "r");
if (!file) {
ERR_LOG("can't fopen /sys/devices/system/cpu/online: %m");
return 0;
}
rc = fscanf(file, "%ms", &str);
if (rc != 1)
ERR_LOG("can't read /sys/devices/system/cpu/online: %m");
fclose(file);
return str;
}
void cpu_scale_down(json_object *jobj_request,
json_object *jobj_response)
{
char cmd[1000];
int cpu=-1;
int rc;
//build our command to send to the helper script
rc = snprintf(cmd, sizeof(cmd), "%s --cpu_del\n", CPU_SCRIPT);
if ((rc > sizeof(cmd)) || rc < 0) {
ERR_LOG("error generating command: %m");
goto pick_cpu;
}
struct json_object *jobj_timeout_ms;
int timeout_ms;
if (!json_object_object_get_ex(jobj_request, TIMEOUT_MS, &jobj_timeout_ms))
{
ERR_LOG("failed to parse timeout_ms");
goto failed;
}
errno = 0;
timeout_ms = json_object_get_int(jobj_timeout_ms);
if(errno){
ERR_LOG("Error converting timeout_ms: %s", strerror(errno));
goto failed;
}
// call app helper script to select cpu to offline
rc = call_helper_script(cmd, timeout_ms);
if (rc < 0) {
ERR_LOG("call to app helper script failed\n");
goto pick_cpu;
} else if (rc == 0) {
ERR_LOG("call to app helper script return invalid cpu number 0\n");
goto pick_cpu;
} else {
INFO_LOG("app helper script chose cpu %d to offline\n", rc);
cpu = rc;
}
pick_cpu:
// if the app helper script doesn't exist or didn't return
// a cpu to offline, pick one ourselves
if (cpu == -1) {
cpu = get_highest_online_cpu();
if (cpu <= 0) {
ERR_LOG("unable to find cpu to offline\n");
goto failed;
}
}
// try to offline selected cpu
rc = offline_cpu(cpu);
if (rc < 0) {
ERR_LOG("failed to set cpu %d offline\n", cpu);
goto failed;
}
INFO_LOG("set cpu %d offline", cpu);
// we have successfully offlined the cpu
json_object_object_add(jobj_response, RESULT, json_object_new_string("success"));
json_object_object_add(jobj_response, OFFLINE_CPU, json_object_new_int(cpu));
struct online_cpus *current_online_cpus = range_to_array(get_online_cpu_range());
// no need to release jobj_array as its ownership is transferred to jobj_response
struct json_object *jobj_array = new_json_obj_from_array(current_online_cpus);
json_object_object_add(jobj_response, ONLINE_CPUS, jobj_array);
return;
failed:
json_object_object_add(jobj_response, RESULT, json_object_new_string("fail"));
json_object_object_add(jobj_response, ERR_MSG, json_object_new_string(errorbuf));
return;
}
void cpu_scale_up(json_object *jobj_request,
json_object *jobj_response)
{
char cmd[1000];
struct json_object *jobj_timeout_ms;
if (!json_object_object_get_ex(jobj_request, TIMEOUT_MS, &jobj_timeout_ms)) {
ERR_LOG("failed to parse timeout_ms");
goto failed;
}
int timeout_ms = json_object_get_int(jobj_timeout_ms);
struct json_object *jobj_cpu;
if (!json_object_object_get_ex(jobj_request, ONLINE_CPU, &jobj_cpu)) {
ERR_LOG("failed to parse online_cpu");
goto failed;
}
int cpu = json_object_get_int(jobj_cpu);
//online_cpus is optional
struct json_object *jobj_online_cpus;
const char *online_cpus;
if (!json_object_object_get_ex(jobj_request, ONLINE_CPUS, &jobj_online_cpus)) {
ERR_LOG("failed to parse online_cpus");
goto failed;
}
json_object_object_get_ex(jobj_request, ONLINE_CPUS, &jobj_online_cpus);
if (!json_object_is_type(jobj_online_cpus, json_type_array)) {
ERR_LOG("failed to parse online_cpus");
goto failed;
}
online_cpus = json_object_to_json_string_ext(jobj_online_cpus, JSON_C_TO_STRING_PLAIN);
int rc = online_cpu(cpu);
if (rc < 0) {
printf("failed to set cpu %d online\n", cpu);
goto failed;
}
INFO_LOG("set cpu %d online", cpu);
// Now try to call out to the helper script
// If it fails, not the end of the world.
rc = snprintf(cmd, sizeof(cmd), "%s --cpu_add %d %s\n",
CPU_SCRIPT, cpu, online_cpus);
if ((rc > 0) && (rc < sizeof(cmd))) {
rc = call_helper_script(cmd, timeout_ms);
if (rc != 0)
ERR_LOG("call to app helper script failed, return code: %d\n", rc);
} else
ERR_LOG("error generating command: %m");
json_object_object_add(jobj_response, RESULT, json_object_new_string("success"));
json_object_object_add(jobj_response, ONLINE_CPU, json_object_new_int(cpu));
struct online_cpus *current_online_cpus = range_to_array(get_online_cpu_range());
// no need to release jobj_array as its ownership is transferred to jobj_response
struct json_object *jobj_array = new_json_obj_from_array(current_online_cpus);
json_object_object_add(jobj_response, ONLINE_CPUS, jobj_array);
return;
failed:
json_object_object_add(jobj_response, RESULT, json_object_new_string("fail"));
json_object_object_add(jobj_response, ERR_MSG, json_object_new_string(errorbuf));
return;
}
/* Callback message handler. This will be called by the generic guest/host
* messaging library when a valid message arrives from the host.
*/
void msg_handler(const char *source_addr, json_object *jobj_request)
{
int rc;
// parse version
struct json_object *jobj_version;
if (!json_object_object_get_ex(jobj_request, VERSION, &jobj_version)) {
ERR_LOG("failed to parse version");
return;
}
int version = json_object_get_int(jobj_version);
if (version != CUR_VERSION) {
ERR_LOG("invalid version %d, expecting %d", version, CUR_VERSION);
return;
}
// parse msg_type
struct json_object *jobj_msg_type;
if (!json_object_object_get_ex(jobj_request, MSG_TYPE, &jobj_msg_type)) {
ERR_LOG("failed to parse msg_type");
return;
}
const char *msg_type = json_object_get_string(jobj_msg_type);
if (!strcmp(msg_type, MSG_TYPE_NACK)) {
struct json_object *jobj_log_msg;
if (!json_object_object_get_ex(jobj_request, LOG_MSG, &jobj_log_msg)) {
ERR_LOG("Nack: failed to parse log_msg");
}
const char *log_msg = json_object_get_string(jobj_log_msg);
ERR_LOG("Nack received, error message from host: %s", log_msg);
return;
} else if (!strcmp(msg_type, MSG_TYPE_SCALE_REQUEST)) {
;
} else {
ERR_LOG("unknown message type: %s", msg_type);
return;
}
struct json_object *jobj_response = json_object_new_object();
if (jobj_response == NULL) {
ERR_LOG("failed to allocate json object for response");
return;
}
struct json_object *jobj_resource;
if (!json_object_object_get_ex(jobj_request, RESOURCE, &jobj_resource)) {
ERR_LOG("failed to parse resource");
goto done;
}
const char *resource = json_object_get_string(jobj_resource);
struct json_object *jobj_direction;
if (!json_object_object_get_ex(jobj_request, DIRECTION, &jobj_direction)) {
ERR_LOG("failed to parse direction'");
goto done;
}
const char *direction = json_object_get_string(jobj_direction);
rc = -1;
if (!strcmp(resource,"cpu")) {
if (!strcmp(direction,"up")) {
cpu_scale_up(jobj_request, jobj_response);
} else if (!strcmp(direction,"down")) {
cpu_scale_down(jobj_request, jobj_response);
}
}
json_object_object_add(jobj_response, VERSION, json_object_new_int(CUR_VERSION));
json_object_object_add(jobj_response, RESOURCE, jobj_resource);
json_object_object_add(jobj_response, DIRECTION, jobj_direction);
const char *response = json_object_to_json_string_ext(jobj_response, JSON_C_TO_STRING_PLAIN);