python-watcher 11.0.0__py3-none-any.whl → 12.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. {python_watcher-11.0.0.dist-info → python_watcher-12.0.0.dist-info}/AUTHORS +2 -0
  2. {python_watcher-11.0.0.dist-info → python_watcher-12.0.0.dist-info}/METADATA +5 -4
  3. {python_watcher-11.0.0.dist-info → python_watcher-12.0.0.dist-info}/RECORD +46 -32
  4. python_watcher-12.0.0.dist-info/pbr.json +1 -0
  5. watcher/applier/actions/change_node_power_state.py +37 -31
  6. watcher/common/clients.py +25 -0
  7. watcher/common/metal_helper/__init__.py +0 -0
  8. watcher/common/metal_helper/base.py +81 -0
  9. watcher/common/metal_helper/constants.py +23 -0
  10. watcher/common/metal_helper/factory.py +33 -0
  11. watcher/common/metal_helper/ironic.py +94 -0
  12. watcher/common/metal_helper/maas.py +125 -0
  13. watcher/common/utils.py +38 -0
  14. watcher/conf/__init__.py +2 -0
  15. watcher/conf/maas_client.py +38 -0
  16. watcher/db/sqlalchemy/api.py +21 -20
  17. watcher/decision_engine/datasources/base.py +9 -1
  18. watcher/decision_engine/datasources/gnocchi.py +44 -5
  19. watcher/decision_engine/model/collector/ironic.py +1 -0
  20. watcher/decision_engine/model/collector/nova.py +4 -3
  21. watcher/decision_engine/model/model_root.py +1 -1
  22. watcher/decision_engine/strategy/strategies/saving_energy.py +34 -28
  23. watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py +100 -13
  24. watcher/decision_engine/strategy/strategies/workload_balance.py +1 -1
  25. watcher/tests/applier/actions/test_change_node_power_state.py +77 -60
  26. watcher/tests/common/metal_helper/__init__.py +0 -0
  27. watcher/tests/common/metal_helper/test_base.py +96 -0
  28. watcher/tests/common/metal_helper/test_factory.py +38 -0
  29. watcher/tests/common/metal_helper/test_ironic.py +128 -0
  30. watcher/tests/common/metal_helper/test_maas.py +126 -0
  31. watcher/tests/common/test_utils.py +52 -0
  32. watcher/tests/decision_engine/datasources/test_gnocchi_helper.py +18 -2
  33. watcher/tests/decision_engine/fake_metal_helper.py +47 -0
  34. watcher/tests/decision_engine/model/faker_cluster_and_metrics.py +21 -94
  35. watcher/tests/decision_engine/strategy/strategies/test_saving_energy.py +62 -109
  36. watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py +97 -29
  37. watcher/tests/objects/test_objects.py +2 -0
  38. python_watcher-11.0.0.dist-info/pbr.json +0 -1
  39. {python_watcher-11.0.0.data → python_watcher-12.0.0.data}/data/etc/apache2/watcher +0 -0
  40. {python_watcher-11.0.0.data → python_watcher-12.0.0.data}/data/etc/watcher/README-watcher.conf.txt +0 -0
  41. {python_watcher-11.0.0.data → python_watcher-12.0.0.data}/data/etc/watcher/oslo-config-generator/watcher.conf +0 -0
  42. {python_watcher-11.0.0.data → python_watcher-12.0.0.data}/data/etc/watcher/oslo-policy-generator/watcher-policy-generator.conf +0 -0
  43. {python_watcher-11.0.0.data → python_watcher-12.0.0.data}/scripts/watcher-api-wsgi +0 -0
  44. {python_watcher-11.0.0.dist-info → python_watcher-12.0.0.dist-info}/LICENSE +0 -0
  45. {python_watcher-11.0.0.dist-info → python_watcher-12.0.0.dist-info}/WHEEL +0 -0
  46. {python_watcher-11.0.0.dist-info → python_watcher-12.0.0.dist-info}/entry_points.txt +0 -0
  47. {python_watcher-11.0.0.dist-info → python_watcher-12.0.0.dist-info}/top_level.txt +0 -0
@@ -47,6 +47,7 @@ Ian Wienand <iwienand@redhat.com>
47
47
  Iswarya_Vakati <v.iswarya@nectechnologies.in>
48
48
  Jaewoo Park <jp655p@att.com>
49
49
  James E. Blair <jeblair@redhat.com>
50
+ James Page <james.page@canonical.com>
50
51
  Jean-Emile DARTOIS <jean-emile.dartois@b-com.com>
51
52
  Jeremy Liu <liujiong@gohighsec.com>
52
53
  Joe Cropper <jwcroppe@us.ibm.com>
@@ -57,6 +58,7 @@ Lance Bragstad <lbragstad@gmail.com>
57
58
  Larry Rensing <lr699s@att.com>
58
59
  LiXiangyu <lixiangyu@cmss.chinamobile.com>
59
60
  Lin Yang <lin.a.yang@intel.com>
61
+ Lucian Petrut <lpetrut@cloudbasesolutions.com>
60
62
  Luigi Toscano <ltoscano@redhat.com>
61
63
  Luong Anh Tuan <tuanla@vn.fujitsu.com>
62
64
  M V P Nitesh <m.nitesh@nectechnologies.in>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-watcher
3
- Version: 11.0.0
3
+ Version: 12.0.0
4
4
  Summary: OpenStack Watcher provides a flexible and scalable resource optimization service for multi-tenant OpenStack-based clouds.
5
5
  Home-page: https://docs.openstack.org/watcher/latest/
6
6
  Author: OpenStack
@@ -16,10 +16,11 @@ Classifier: Programming Language :: Python
16
16
  Classifier: Programming Language :: Python :: Implementation :: CPython
17
17
  Classifier: Programming Language :: Python :: 3 :: Only
18
18
  Classifier: Programming Language :: Python :: 3
19
- Classifier: Programming Language :: Python :: 3.6
20
- Classifier: Programming Language :: Python :: 3.7
21
19
  Classifier: Programming Language :: Python :: 3.8
22
- Requires-Python: >=3.6
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Requires-Python: >=3.8
23
24
  Requires-Dist: PasteDeploy (>=1.5.2)
24
25
  Requires-Dist: PrettyTable (>=0.7.2)
25
26
  Requires-Dist: SQLAlchemy (>=1.2.5)
@@ -1,8 +1,8 @@
1
- python_watcher-11.0.0.data/data/etc/apache2/watcher,sha256=urybYUTb0kAVIvbm4WK5oDfXR82QSK2lyMl4Z9dCz4Q,1190
2
- python_watcher-11.0.0.data/data/etc/watcher/README-watcher.conf.txt,sha256=EIa_sjXDyl1XSg0ovsFwUjqw0euS0N2PYn4HtyBGJME,131
3
- python_watcher-11.0.0.data/data/etc/watcher/oslo-config-generator/watcher.conf,sha256=O7g1DZqgXvbQgkBfot0dR1ar1d-3SBkOU_ZK4Dz7SFc,406
4
- python_watcher-11.0.0.data/data/etc/watcher/oslo-policy-generator/watcher-policy-generator.conf,sha256=ZfIuVdtrj7IZm2BrRQvAW3JOL_kqCiILf-vBmwX3ufw,76
5
- python_watcher-11.0.0.data/scripts/watcher-api-wsgi,sha256=YcIpUO3iRVW6Fu3Md_ooAeHkmJJasG031naMdf8cv2A,1829
1
+ python_watcher-12.0.0.data/data/etc/apache2/watcher,sha256=urybYUTb0kAVIvbm4WK5oDfXR82QSK2lyMl4Z9dCz4Q,1190
2
+ python_watcher-12.0.0.data/data/etc/watcher/README-watcher.conf.txt,sha256=EIa_sjXDyl1XSg0ovsFwUjqw0euS0N2PYn4HtyBGJME,131
3
+ python_watcher-12.0.0.data/data/etc/watcher/oslo-config-generator/watcher.conf,sha256=O7g1DZqgXvbQgkBfot0dR1ar1d-3SBkOU_ZK4Dz7SFc,406
4
+ python_watcher-12.0.0.data/data/etc/watcher/oslo-policy-generator/watcher-policy-generator.conf,sha256=ZfIuVdtrj7IZm2BrRQvAW3JOL_kqCiILf-vBmwX3ufw,76
5
+ python_watcher-12.0.0.data/scripts/watcher-api-wsgi,sha256=YcIpUO3iRVW6Fu3Md_ooAeHkmJJasG031naMdf8cv2A,1829
6
6
  watcher/__init__.py,sha256=Vs2olXPZ_IAV1rukHYRl3ITzYFBNXX9mIUtFXkMWYwg,640
7
7
  watcher/_i18n.py,sha256=-25OcpwjDCiYdFIUJh86S7Sg0fs3wMIIjEreaGUyCyY,1295
8
8
  watcher/version.py,sha256=3bUsLHmwjNgOJ9hfzy5yQ67UGFOriUNFJqyh8lGQazE,760
@@ -49,7 +49,7 @@ watcher/applier/action_plan/base.py,sha256=MNhGmeOZJdwmdV4jfJz-jdOOnd5PZah37ahxq
49
49
  watcher/applier/action_plan/default.py,sha256=9CCBoPGPaoQ_uDnbF_ZEHTlKFyzZwSafNUACCtzGStg,4286
50
50
  watcher/applier/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  watcher/applier/actions/base.py,sha256=FpKa8OUNwLo1-n97ElvAw4TqsHKVXb9saLL5Fh0wC40,4876
52
- watcher/applier/actions/change_node_power_state.py,sha256=KAgZR4aouBRp9rA8YUnd7KRHHJEIkL2TOHaTkB8R8uY,4047
52
+ watcher/applier/actions/change_node_power_state.py,sha256=RvvlGljFwyIfu-0AwmEKcuikREuN46V9zEfOt387IKI,4274
53
53
  watcher/applier/actions/change_nova_service_state.py,sha256=KyrOv-eCaWZZnhkx6upWkUpQxB-XF_x2wEjckJoh_Rw,4484
54
54
  watcher/applier/actions/factory.py,sha256=F1_14MGlhZsgsfYuqlHLo35a5HRzRcsPzOy1yTxIN2c,1568
55
55
  watcher/applier/actions/migration.py,sha256=qSCBX7DILKb9f5215THvX29m7xdAMSG3AeNqFveR9Sg,7989
@@ -73,7 +73,7 @@ watcher/cmd/status.py,sha256=xbxSdX7WBCHerTwPXUYvEGxQLOXx7VYRhSpD00D4eRE,1829
73
73
  watcher/cmd/sync.py,sha256=aLOCKrYxRYKeuxsr7Q6E-sFVtk5iZIA_TO0y4H5qV1s,1059
74
74
  watcher/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
75
75
  watcher/common/cinder_helper.py,sha256=WurmDVm4JzYyU-yn4HcleJ9JwduIc76rr9XBhFgMwO0,9599
76
- watcher/common/clients.py,sha256=r0D6KQEs6N19jsvOndlltQkV2ENMebLASQu5qevM2lw,12032
76
+ watcher/common/clients.py,sha256=H1i8WyQ0r-8HuXYRePBvnrvJd0ehRNFjQFmZQ2dUbjY,12751
77
77
  watcher/common/config.py,sha256=2_9hklnzAICpZAIDQmxoE8d8qMFS03sjkoVdXPLchmU,1465
78
78
  watcher/common/context.py,sha256=SAxWJSopUogTMC2hAwLa6vK_Ra_Etk5V8CcDf4tgb-I,4555
79
79
  watcher/common/exception.py,sha256=QoxjeIWLyXdzbkePyE_vvZzUllb0_OP3eEgxRDxd72o,14304
@@ -87,11 +87,17 @@ watcher/common/rpc.py,sha256=X1ZEohTH6Maw_iZaj9JBDAD_sfUPzV35W4lCeJhRITc,4415
87
87
  watcher/common/scheduling.py,sha256=jx-kfyzhHZfwdanXBaVwhrPkvqer9mZJnT_v4vTdcMY,2145
88
88
  watcher/common/service.py,sha256=FvkphJ3RW9l8Xp1_GRTz1P__BPEQsU78mDNt3z4dyTs,9715
89
89
  watcher/common/service_manager.py,sha256=XT_4JmmsthD1NaAbQdk501PIiyr_BflC_UYpSoYvqz0,1337
90
- watcher/common/utils.py,sha256=u65vEb9ulSLr55Jdw5e34S-05qeP0eF7NqwOE8FDtQw,4758
90
+ watcher/common/utils.py,sha256=Fmq9ynz2QjJcqnJmvS8IdrvBI98Rt_XAYHUMnw-ZXsk,6190
91
91
  watcher/common/loader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
92
92
  watcher/common/loader/base.py,sha256=SeI1QVtA11JcQcC8jRxfOraQ9D2WTUdSZv3zAou47Us,842
93
93
  watcher/common/loader/default.py,sha256=P-HZM7wJbQFfNrGSAzZnHj-3t3a6NVx9dQl3dUvawFc,3076
94
94
  watcher/common/loader/loadable.py,sha256=pVdin0J2vhplPYTXpKwdR8rI8rNmiVLQipR_UgZJNIs,2224
95
+ watcher/common/metal_helper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
96
+ watcher/common/metal_helper/base.py,sha256=k_Znck_ulAE4P27lQWF--PpwVq_smhK7eMJUIcmEXPo,2326
97
+ watcher/common/metal_helper/constants.py,sha256=-PxOEDy-gikO6XOf9kcqEBgnI6enWSES5Vdq0xB_5qo,757
98
+ watcher/common/metal_helper/factory.py,sha256=JFPK3pcoNJpFswrzp-DISJBL29P-UGE-7mmcE5nOPiQ,1060
99
+ watcher/common/metal_helper/ironic.py,sha256=dqWxu3nog66pruj81PgLSVM_o-G5qYHYsexheMxBilI,3322
100
+ watcher/common/metal_helper/maas.py,sha256=6-UQXMNij8ISKi469PhtlDf3B1I6vXt-7L69jiaNrtg,4397
95
101
  watcher/common/policies/__init__.py,sha256=WyMS1WUDZrXZi1PTcNRWeoaXozJ12WCh-C6pLUmGqOg,1384
96
102
  watcher/common/policies/action.py,sha256=xCmS8atw4HLGhX-6WyMuKESIbL5jlFG2eApLYUL58cE,1617
97
103
  watcher/common/policies/action_plan.py,sha256=bspo8mihCtUiHwYT6vMDkB6JEIlkDJQjrhQSoEEQ4ks,2597
@@ -103,7 +109,7 @@ watcher/common/policies/goal.py,sha256=qrTbC9NIFJKbcRl_JCuEJI0IqmM8oSadTSaLwo6LV
103
109
  watcher/common/policies/scoring_engine.py,sha256=DSB21nxhKlt74VIEuV_Rd1VuwT5Kp4sT1dfZRgpMMQY,2136
104
110
  watcher/common/policies/service.py,sha256=TjaoGXXRz_GnjRsUOyZN4YIAPe7QVzL8OOgyQyzkr6U,1577
105
111
  watcher/common/policies/strategy.py,sha256=1TlqnmG_MmVvqEaFCnQyl_YDEHJg3LAFwl60OF_ZTrM,1904
106
- watcher/conf/__init__.py,sha256=mFpwL2tUo0A_4uDtAA3DGEJtE3j-e6IuhEjH90PAi8M,2340
112
+ watcher/conf/__init__.py,sha256=G8CL9aKZhV4D2kCHIt6UMWOnj-ij2lYm-aijG5sRDvU,2409
107
113
  watcher/conf/api.py,sha256=y_o2YZ5Pm04qP8WAqBmDYDkoiJf5I0S9TxXNTHMvZG4,2792
108
114
  watcher/conf/applier.py,sha256=DcnkPIHpj-mZSNNS54HH2ZCXU8jjc-NacAPdKfPYTDg,2207
109
115
  watcher/conf/ceilometer_client.py,sha256=80Pe4TKZ1d2ENOT5nW5ZeYON24NdXeih7ePENDOx5Xw,2503
@@ -120,6 +126,7 @@ watcher/conf/grafana_client.py,sha256=JMalRmtMpRwpMMr8EkkV_maUcbEw4PGzPSv8Z4DTDp
120
126
  watcher/conf/grafana_translators.py,sha256=5mqq-ZUYpiOaOtm7GRbxiyiJQFw_GFb8JynGhCMAwyE,1651
121
127
  watcher/conf/ironic_client.py,sha256=Ux2gvBHlHBrrnfR8vDlwHrCWJLgileiaL6xSgqXkOxw,1589
122
128
  watcher/conf/keystone_client.py,sha256=V7PKGylRSrw9zwMw_xuehxmpqXM7up9y_DIdYJBJFdg,1349
129
+ watcher/conf/maas_client.py,sha256=7KGb3yIKWDvCdYA5Kc22uszkFEOp9rcJQHpQFES2dfA,1277
123
130
  watcher/conf/monasca_client.py,sha256=LcUhyHOZ-VgAY2p3dhuvNeNsmITBhHaoKJxGYD7-Q5w,1596
124
131
  watcher/conf/neutron_client.py,sha256=VyLPAeKSJ6hy-eL_a-DhRLUrLCPQ2TBsb7eBIrAB8Ws,1608
125
132
  watcher/conf/nova_client.py,sha256=hEYsV5j5TzvK1iAl9JA-ESZ2AT2HXtJ_F7qGTqvr0nk,1923
@@ -135,7 +142,7 @@ watcher/db/migration.py,sha256=luOV_QnQp1XvtKFrgIMmrn7NFPbOgIcDxOBDQt5wVzE,1636
135
142
  watcher/db/purge.py,sha256=cqC37xAcb18pEAdneQUcHdLMv8ZpC6FCS2iKr-CNmAQ,16858
136
143
  watcher/db/sqlalchemy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
137
144
  watcher/db/sqlalchemy/alembic.ini,sha256=LzCgKVKhFQctG7OUdDzWHGKnwA7WkTCLame3foHscuE,975
138
- watcher/db/sqlalchemy/api.py,sha256=IHrOaf_2nZsurEJfv9YukPzBKmvQIMMJ8g6Q2TmOPfk,44322
145
+ watcher/db/sqlalchemy/api.py,sha256=c1XurvUAEqA7peDbqVVQ33oAr63vN5phiR3vQCBL6Ws,44334
139
146
  watcher/db/sqlalchemy/job_store.py,sha256=_pNekgw3AEdmd7ZIJ0avTae04Zxhq2UcGa90vvXvWeI,4441
140
147
  watcher/db/sqlalchemy/migration.py,sha256=VNPXd-8i3ib5Cqq43uAQegwYiuWREZnHvmJCEmnErAo,3676
141
148
  watcher/db/sqlalchemy/models.py,sha256=738iG47Amlb-QXpJhrNwpquQmjxIC-lqhOPaWa1ZTq8,10945
@@ -164,9 +171,9 @@ watcher/decision_engine/audit/continuous.py,sha256=8s8x0km844W7RLMcqwrCzOY3rAstN
164
171
  watcher/decision_engine/audit/event.py,sha256=TQNiPB806LhrxXtBZMz69qGKOFW2mZZ6zXXv4xoStrk,1049
165
172
  watcher/decision_engine/audit/oneshot.py,sha256=hbcAofXAVEjC5HWJpKq8y1AEKuyFjk33nP1JD5Nc_ps,1046
166
173
  watcher/decision_engine/datasources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
167
- watcher/decision_engine/datasources/base.py,sha256=SdGgznrux59Dj-9yQ5Su4WdXctC_6RCoWrrD1yt8UaI,9376
174
+ watcher/decision_engine/datasources/base.py,sha256=G0t0nHAD1_5FwIfdl1vwYXSib5D9kZxjt1R5ym0hv9Q,9764
168
175
  watcher/decision_engine/datasources/ceilometer.py,sha256=gvURZVkOl-RJ6M_-NAQzMopsrvzlUZZCITsMbQB08Aw,10668
169
- watcher/decision_engine/datasources/gnocchi.py,sha256=E5UJ9NOT1O-5i0KnkZP4sghl69M-nayW57hKqbxoj2c,8788
176
+ watcher/decision_engine/datasources/gnocchi.py,sha256=L4pUSwXsrh_xSbBuGl2F0PzkbgEUHhvt7AkYBNg-MMU,10442
170
177
  watcher/decision_engine/datasources/grafana.py,sha256=tzuswoqx_Yd2cBVR9r3QSH18RjDPIMZDhUETKaXpsp0,10287
171
178
  watcher/decision_engine/datasources/manager.py,sha256=3ovPD5qyzMW8YZeWki7gf6W5iu744fgl0G_XhmeOQqc,5680
172
179
  watcher/decision_engine/datasources/monasca.py,sha256=NtD_OV00uTUS5L3Vg1xJ_R0WhR1rHyueuXUeALMf_aU,6950
@@ -187,13 +194,13 @@ watcher/decision_engine/messaging/audit_endpoint.py,sha256=TM7rWzmwuVpsiFS_ffwz0
187
194
  watcher/decision_engine/messaging/data_model_endpoint.py,sha256=bh_ViPvF7I_Nha32eSqsRpDt8FPomM78PENZkGOyDYs,2180
188
195
  watcher/decision_engine/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
189
196
  watcher/decision_engine/model/base.py,sha256=epNLXZ-bxuglMdyNe9oQawAfBlzip7foRzqu9FOPU-k,1131
190
- watcher/decision_engine/model/model_root.py,sha256=iQwCvowe2M2Ph4YTkX0pEb2bnHysvBP0YKuF24Aeeu8,23973
197
+ watcher/decision_engine/model/model_root.py,sha256=1uNCHfGOjneLYVwUG4zTHF_jVstUn4SwlcIqhBU92Hs,23980
191
198
  watcher/decision_engine/model/collector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
192
199
  watcher/decision_engine/model/collector/base.py,sha256=t8S6gRd_uaV1GbBuGJLG4AvVwU0loqQ6UoRv5WmArQM,9607
193
200
  watcher/decision_engine/model/collector/cinder.py,sha256=B743mJca8gQiIu6QG9zaf_du3ihUY6iBv82W1EWoWgk,11683
194
- watcher/decision_engine/model/collector/ironic.py,sha256=XMcY9m-zUWyNtANnl_UZ-m1E9PWkt68V90zaRJl5Ba8,4037
201
+ watcher/decision_engine/model/collector/ironic.py,sha256=cejUXlzcJN2okI2mTWh3MZ6M7YMqs2BKfgJTGlWegaQ,4079
195
202
  watcher/decision_engine/model/collector/manager.py,sha256=lEw6-CfyLPBmX97ZaZj7vEu1eHTzQU67oggoQo-KEoI,2327
196
- watcher/decision_engine/model/collector/nova.py,sha256=LRp1pX6HmbmGEpNhRmv0S-K9iynUzUKBgieJSqeQkf4,21542
203
+ watcher/decision_engine/model/collector/nova.py,sha256=pmuxXBGEAgFr4Q_nh4L8uhaItNbvk2S8ulCXiU1HTr0,21616
197
204
  watcher/decision_engine/model/element/__init__.py,sha256=R3XmeW4-ufWnbWruWGLR4SQJP9olmBLADRfyrvP-PaE,1320
198
205
  watcher/decision_engine/model/element/baremetal_resource.py,sha256=WC6CkGhruAXIiynWDsvKbV3VdvDihBMy3YNTa18Q5bg,924
199
206
  watcher/decision_engine/model/element/base.py,sha256=dYgFk33RSoylQbNjCmcwSIb3ZIDccVBpO8FFwqQEPBc,2063
@@ -249,11 +256,11 @@ watcher/decision_engine/strategy/strategies/host_maintenance.py,sha256=IJAuDVOX_
249
256
  watcher/decision_engine/strategy/strategies/node_resource_consolidation.py,sha256=O69x-Mi1LEb-rJD_NErMONiR2yyKMA4zKgw2s1TXIas,11292
250
257
  watcher/decision_engine/strategy/strategies/noisy_neighbor.py,sha256=YURA2g46ql6jnsvwTq3sb9ZpDyc68PJ6pUOmSvbDv2g,9922
251
258
  watcher/decision_engine/strategy/strategies/outlet_temp_control.py,sha256=NaeBhuu45wbBHPArwA9FKNsaBUV7i4nOyzj5Lkq1RLM,11010
252
- watcher/decision_engine/strategy/strategies/saving_energy.py,sha256=beRAXqUumnkL8w0uTSiT2-jcZgzjJXnaLHdI65wDsII,8732
259
+ watcher/decision_engine/strategy/strategies/saving_energy.py,sha256=gzjv0Uk3bEV63_zhWyibiMyQ221GxU1oHURDZAn0qC4,9155
253
260
  watcher/decision_engine/strategy/strategies/storage_capacity_balance.py,sha256=a2C12V3LfISTJLEVFsjvrXWCXmv9knhmU5smzG0N-XE,15669
254
261
  watcher/decision_engine/strategy/strategies/uniform_airflow.py,sha256=8jaW5LGkM9dHb8q9aX_7_hQV-MOXHS2o6jyw9-Z6668,13390
255
- watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py,sha256=tFnVwAxuye5jLbt8vYElnQv-Hg5XuQSM-c0QDFJWlnA,23147
256
- watcher/decision_engine/strategy/strategies/workload_balance.py,sha256=hPoX5LbIjITQn43hjLg5Z_rr1a_vVzgJmgbYe5dglgA,14332
262
+ watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py,sha256=-usWMjqFcbTSWbGKNmsSlZ-0wnMNwLv2w22Fu6nIqyw,27190
263
+ watcher/decision_engine/strategy/strategies/workload_balance.py,sha256=MMJZkfi8kFJDT4Hcp-NTCclN1MMKj02t88OdMinWYnI,14333
257
264
  watcher/decision_engine/strategy/strategies/workload_stabilization.py,sha256=xKnjDeSAkGxvAuUKlxRGuaHVyBjSy-1nFcgI4ni8pnk,24902
258
265
  watcher/decision_engine/strategy/strategies/zone_migration.py,sha256=bNKarllyWVgtNMSIzckV2C4I9IFjQPHfgqdTiOTvEes,33189
259
266
  watcher/hacking/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -321,7 +328,7 @@ watcher/tests/applier/test_sync.py,sha256=eUdJ5eIQZunXxpdgFfE6cpSNYisO34w-mFxdB4
321
328
  watcher/tests/applier/action_plan/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
322
329
  watcher/tests/applier/action_plan/test_default_action_handler.py,sha256=hFS2Q9IuoAygHfHHCfabnABkdOXKPKhCPVCImCU0eFQ,5488
323
330
  watcher/tests/applier/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
324
- watcher/tests/applier/actions/test_change_node_power_state.py,sha256=qg9oA0f9iAdOBbZBDQ4HFFXRYaHGkS9TEU0-jVcQvD4,6267
331
+ watcher/tests/applier/actions/test_change_node_power_state.py,sha256=NqZIXKgxh810A9vzCj55qyjzcxIiE77T6WYZyLWOynE,6251
325
332
  watcher/tests/applier/actions/test_change_nova_service_state.py,sha256=DnA-nUo4p7ets3dCpUY0TTCi9f8lUO2TfUS1-tMaX3Q,5154
326
333
  watcher/tests/applier/actions/test_migration.py,sha256=_1squ_q5oZVRFtl3y7WLbFUFOGVjkL2CXR5Ayy2tSsk,8654
327
334
  watcher/tests/applier/actions/test_resize.py,sha256=L0fV24QS7sAibgVh5WmwIpywby3RKcjFEu6yQYBA7o8,3470
@@ -349,8 +356,14 @@ watcher/tests/common/test_ironic_helper.py,sha256=Ut-bpvPBQJWdu9xWPvzQ0sFEimuHU0
349
356
  watcher/tests/common/test_nova_helper.py,sha256=BaJ4Gfn1hGG5sho2QZ7btCvzrvzbIpR6PI6kAejr6Yw,28524
350
357
  watcher/tests/common/test_placement_helper.py,sha256=Y4P2YbWhC0itWGJbaDkoua9ot0XknXuM8disvceIXQQ,11761
351
358
  watcher/tests/common/test_service.py,sha256=C7i4Pdawc_XKpqZuklJqQd3unztgiVpvkwwjUujGRK0,3535
359
+ watcher/tests/common/test_utils.py,sha256=9ibjt0EDkm_H3RRGHCOYW4vNOhV7rEzEJKZMYCaDDvE,1749
352
360
  watcher/tests/common/loader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
353
361
  watcher/tests/common/loader/test_loader.py,sha256=mBnhe2apSmqpEL-8QZUlRDhDuWEEGo7iZQxpZIuGCWM,3612
362
+ watcher/tests/common/metal_helper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
363
+ watcher/tests/common/metal_helper/test_base.py,sha256=bH5dq46kGZ81bZU5EKbyZG_Luxy4E5LxA4yB71t35NA,2936
364
+ watcher/tests/common/metal_helper/test_factory.py,sha256=ICH22LdsQboC6hPDePmbc8xIm4M5-QExRplRYIkCNmU,1377
365
+ watcher/tests/common/metal_helper/test_ironic.py,sha256=fHIsBxLxXUxOQAndta5xgy9S8p_FbO8n6OCX9VLSTMw,4702
366
+ watcher/tests/common/metal_helper/test_maas.py,sha256=SrPJ7Jbr8UtRsQDRodDtfLHf0RLDSZln1TmVzxtaMuU,4371
354
367
  watcher/tests/conf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
355
368
  watcher/tests/conf/test_list_opts.py,sha256=A9mqxfT1Be4zrJvGnAP_yb4A4jZBSzYQ5IDbFuIQMZM,7028
356
369
  watcher/tests/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -369,6 +382,7 @@ watcher/tests/db/test_strategy.py,sha256=P4TYivLdbLgZzDbZgH-znyJ-KKWj8ziNAjB5kcN
369
382
  watcher/tests/db/utils.py,sha256=yqDpIDgcnKU9wAye1463Ch5b9DI1NKGYgjNaw3Hwln0,13532
370
383
  watcher/tests/decision_engine/__init__.py,sha256=Y4KmmaTQFmQFKeccuUnkwKnrb8T_O2-sIxPQSox7wos,65
371
384
  watcher/tests/decision_engine/fake_goals.py,sha256=vKYl8ZB0-3819cq73gmJ3mjvwURVuZIlZ-9BgruhW7w,2203
385
+ watcher/tests/decision_engine/fake_metal_helper.py,sha256=hGe7Ys3kpIysFMz-kYu64ytvD_oifwDDzI9QiJQY3Zg,1674
372
386
  watcher/tests/decision_engine/fake_strategies.py,sha256=2mD3hw5rMoHdHX4SoUt2J0gbagmiIaIAASlgwgYRqqI,1996
373
387
  watcher/tests/decision_engine/test_gmr.py,sha256=fUV6UIERUTbN4JK6Ij96FTESL8zP8zYHVVB-_1Kl7Ao,1319
374
388
  watcher/tests/decision_engine/test_rpcapi.py,sha256=H6oHI97HfJCoxuF5omHDdY4Kn5kodfC9rrimxpBUEqo,2534
@@ -382,7 +396,7 @@ watcher/tests/decision_engine/cluster/test_cluster_data_model_collector.py,sha25
382
396
  watcher/tests/decision_engine/cluster/test_nova_cdmc.py,sha256=GtqTL9jfS5w6CvmZQUGYATtVtRcboHbzvasLGeMBkEA,19581
383
397
  watcher/tests/decision_engine/datasources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
384
398
  watcher/tests/decision_engine/datasources/test_base.py,sha256=swGXWVrnypcsVB7eBqhHGqlX0ewkIWheVlX0NRBhMcE,2391
385
- watcher/tests/decision_engine/datasources/test_gnocchi_helper.py,sha256=fyBTVP29n1waFCBvFBNzOMUR5JAtL36dllYLP2WyaJw,8381
399
+ watcher/tests/decision_engine/datasources/test_gnocchi_helper.py,sha256=CqvO0wcvmmBL3rXPW_x9D9RuQcQqNfYkHIlBQmK9z8M,8855
386
400
  watcher/tests/decision_engine/datasources/test_grafana_helper.py,sha256=NVGVlzjAtxOaJLL-1s1V0jETAc5_2QP0Hr0qb4TiEn0,11858
387
401
  watcher/tests/decision_engine/datasources/test_manager.py,sha256=_daZ57iHQI6PWkNHLV7H-B6_Ljk9d9xtzST7IcZ-E1c,6822
388
402
  watcher/tests/decision_engine/datasources/test_monasca_helper.py,sha256=toxxJCRCDgjvnN3wAXzdi6MPOCeMpKRikzXtcg-Oq0k,5697
@@ -400,7 +414,7 @@ watcher/tests/decision_engine/messaging/test_audit_endpoint.py,sha256=RQ6yT3MxeZ
400
414
  watcher/tests/decision_engine/messaging/test_data_model_endpoint.py,sha256=6wj90UIYwXDqRiOFamHtlW3cKxavFewV27xhEhVxHi4,2008
401
415
  watcher/tests/decision_engine/model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
402
416
  watcher/tests/decision_engine/model/ceilometer_metrics.py,sha256=JW1fPHNe4fFAIF_4yQe9_QgRpIJHYD69mFw645BHiJk,9723
403
- watcher/tests/decision_engine/model/faker_cluster_and_metrics.py,sha256=AjEoAgvO__Abgj9goA-3ac6P2cdSEzxDhUvfwrSPFvY,10175
417
+ watcher/tests/decision_engine/model/faker_cluster_and_metrics.py,sha256=nPObe9x-O4apsIy2r3BqRE3ELqKlxZz6kRrGKVsfDuA,7036
404
418
  watcher/tests/decision_engine/model/faker_cluster_state.py,sha256=whaEpzD8zt7BVnqsBrWcbugDOeyChAyn74d1YwO0P1o,12405
405
419
  watcher/tests/decision_engine/model/gnocchi_metrics.py,sha256=LoKRVLPPwi_BIJgRlPRZ_gG87Nqkfd0_4e0DcmonSu8,9358
406
420
  watcher/tests/decision_engine/model/monasca_metrics.py,sha256=s-voe8Cu7Su2_Tn_sp3dSxWTPI3zgFd9Wtrf9CZ7Wu4,4121
@@ -502,11 +516,11 @@ watcher/tests/decision_engine/strategy/strategies/test_host_maintenance.py,sha25
502
516
  watcher/tests/decision_engine/strategy/strategies/test_node_resource_consolidation.py,sha256=kyvyxJyrj_ArJsuoIDpOWDn-Ek-gkKlNxlYF3bDt4MA,15906
503
517
  watcher/tests/decision_engine/strategy/strategies/test_noisy_neighbor.py,sha256=-IGlCBVkqtc785Y_XbOI8qrgaK4cEyHM78yj5HFKnJ0,5609
504
518
  watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py,sha256=fz4RskntOUMSxvCLEfTjj92mvAo6dA1CTOwJVq0Mric,4902
505
- watcher/tests/decision_engine/strategy/strategies/test_saving_energy.py,sha256=Z6T16u-oqiaLnveIGcgO5sxKZRUmU_gr3WZQrPDA1lY,8589
519
+ watcher/tests/decision_engine/strategy/strategies/test_saving_energy.py,sha256=_cEjJFWFUHV7lxTRJxNHor-Hqa3UJ56Eml2JRx2rxiw,6528
506
520
  watcher/tests/decision_engine/strategy/strategies/test_storage_capacity_balance.py,sha256=voWP8cfqJtsaK5Dz-vIQKZFwyARHLZSY7a1-I6bDTlA,9419
507
521
  watcher/tests/decision_engine/strategy/strategies/test_strategy_endpoint.py,sha256=mw2CFX-JfWwaNM3EYFLoZzHZxJXpEh5YD7JPrZz0ggI,2886
508
522
  watcher/tests/decision_engine/strategy/strategies/test_uniform_airflow.py,sha256=xxYk5pEzw8V6dROIYwys-WISDw2ZglJNwOk5xXjrQi4,7470
509
- watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py,sha256=eu3sMGhf9dSdZ4LAqjzvXpiMWdiZ9vNuXxz8iASV3uw,16970
523
+ watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py,sha256=8Rq_-6Qy7D0OlxAvUhojVFz7GOPrHlI2aoYSwF5EVjs,19358
510
524
  watcher/tests/decision_engine/strategy/strategies/test_workload_balance.py,sha256=76Gnxfg_T8YMI26XWGvguAd7Eiix4tL5AOTyIWXJKaY,6279
511
525
  watcher/tests/decision_engine/strategy/strategies/test_workload_stabilization.py,sha256=_5GvZZZKcmMFsf6UMmJX_cYD5wCJV0lbP4Y2Kd4PuzM,12007
512
526
  watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py,sha256=HVDn6i3ayCJjEkPwifi_8u2hekuNyrU-jyCucp8kzoc,30679
@@ -524,16 +538,16 @@ watcher/tests/objects/test_audit.py,sha256=MATtKS7MBDpuhrLpq994rRM2UNahW9LRA7KMD
524
538
  watcher/tests/objects/test_audit_template.py,sha256=fSHdfYAm-RNjcubd8kixkScJIAunyRV-R9NHTeO8a4Y,10670
525
539
  watcher/tests/objects/test_efficacy_indicator.py,sha256=nZs4l4wmB3pKFQeC2S8p8tC8LFeTUBfUQhIbSFXx1EQ,6888
526
540
  watcher/tests/objects/test_goal.py,sha256=kD6WsEoH4jgLbUsEMOSNx4lzgWBruPPsQ3FFlZichHQ,6177
527
- watcher/tests/objects/test_objects.py,sha256=g8MhUmXC7AzqBNUAVISsZAJRSt6591Lk273HK0w1D4c,21201
541
+ watcher/tests/objects/test_objects.py,sha256=7W-FA3kDunGcGGj2q1_Lf6UqLwTGchoextSNjM2h4M4,21303
528
542
  watcher/tests/objects/test_scoring_engine.py,sha256=y_crleFQFOUKrqT9tSI1NIP7eEMsnoLwb7ZyEZrY5mI,7617
529
543
  watcher/tests/objects/test_service.py,sha256=w8r6qgLJd0Vp3B774BInkWij4qUbMiykisIRSaxiqaA,5100
530
544
  watcher/tests/objects/test_strategy.py,sha256=WoJYFQD0LU7vkUT2MMy1bx3S6eY458aTICjoGRiPccI,7364
531
545
  watcher/tests/objects/utils.py,sha256=WtBFlXWIBRvl1keAjz1GtrkUWppil2pFIA-RngcqA5c,8058
532
- python_watcher-11.0.0.dist-info/AUTHORS,sha256=08XBbMJwOj9SJiMhnpHUCr96nKVexCsUY9OfZss9Y2s,7476
533
- python_watcher-11.0.0.dist-info/LICENSE,sha256=XfKg2H1sVi8OoRxoisUlMqoo10TKvHmU_wU39ks7MyA,10143
534
- python_watcher-11.0.0.dist-info/METADATA,sha256=bFi4zdopmPZDAnVCn5MmzMTTTQbTkORI7rMXzJuv4gI,3876
535
- python_watcher-11.0.0.dist-info/WHEEL,sha256=g4nMs7d-Xl9-xC9XovUrsDHGXt-FT0E17Yqo92DEfvY,92
536
- python_watcher-11.0.0.dist-info/entry_points.txt,sha256=FCdhj8D9hluy9jjmwnwmFVumvMeOCv6n_IoOCHF8-WU,4397
537
- python_watcher-11.0.0.dist-info/pbr.json,sha256=EZscyvXwW8ULxvq17Kxh5LgPHkK-5G07mUZahS6SfXA,47
538
- python_watcher-11.0.0.dist-info/top_level.txt,sha256=O2B7Sbzshq5s-tZxb2a7VETvMDiJItSYieAiJ6Jm5yY,8
539
- python_watcher-11.0.0.dist-info/RECORD,,
546
+ python_watcher-12.0.0.dist-info/AUTHORS,sha256=rNNrz_B6rtFdh_rVxCA4bdb-DYrk54lnKQWwOprkikI,7561
547
+ python_watcher-12.0.0.dist-info/LICENSE,sha256=XfKg2H1sVi8OoRxoisUlMqoo10TKvHmU_wU39ks7MyA,10143
548
+ python_watcher-12.0.0.dist-info/METADATA,sha256=6HjMsSTL7CJDkfMSFeI4m-T8xm2E89JgVE_fvAj3P3Q,3928
549
+ python_watcher-12.0.0.dist-info/WHEEL,sha256=g4nMs7d-Xl9-xC9XovUrsDHGXt-FT0E17Yqo92DEfvY,92
550
+ python_watcher-12.0.0.dist-info/entry_points.txt,sha256=FCdhj8D9hluy9jjmwnwmFVumvMeOCv6n_IoOCHF8-WU,4397
551
+ python_watcher-12.0.0.dist-info/pbr.json,sha256=PAdKzDYnH_Of-U8XHeZmF8PGhRBVqUFq2GCWfGGjKvU,47
552
+ python_watcher-12.0.0.dist-info/top_level.txt,sha256=O2B7Sbzshq5s-tZxb2a7VETvMDiJItSYieAiJ6Jm5yY,8
553
+ python_watcher-12.0.0.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ {"git_version": "6b433b35", "is_release": true}
@@ -17,17 +17,17 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- import enum
21
20
  import time
22
21
 
22
+ from oslo_log import log
23
+
23
24
  from watcher._i18n import _
24
25
  from watcher.applier.actions import base
25
26
  from watcher.common import exception
27
+ from watcher.common.metal_helper import constants as metal_constants
28
+ from watcher.common.metal_helper import factory as metal_helper_factory
26
29
 
27
-
28
- class NodeState(enum.Enum):
29
- POWERON = 'on'
30
- POWEROFF = 'off'
30
+ LOG = log.getLogger(__name__)
31
31
 
32
32
 
33
33
  class ChangeNodePowerState(base.BaseAction):
@@ -43,8 +43,8 @@ class ChangeNodePowerState(base.BaseAction):
43
43
  'state': str,
44
44
  })
45
45
 
46
- The `resource_id` references a ironic node id (list of available
47
- ironic node is returned by this command: ``ironic node-list``).
46
+ The `resource_id` references a baremetal node id (list of available
47
+ ironic nodes is returned by this command: ``ironic node-list``).
48
48
  The `state` value should either be `on` or `off`.
49
49
  """
50
50
 
@@ -59,10 +59,14 @@ class ChangeNodePowerState(base.BaseAction):
59
59
  'type': 'string',
60
60
  "minlength": 1
61
61
  },
62
+ 'resource_name': {
63
+ 'type': 'string',
64
+ "minlength": 1
65
+ },
62
66
  'state': {
63
67
  'type': 'string',
64
- 'enum': [NodeState.POWERON.value,
65
- NodeState.POWEROFF.value]
68
+ 'enum': [metal_constants.PowerState.ON.value,
69
+ metal_constants.PowerState.OFF.value]
66
70
  }
67
71
  },
68
72
  'required': ['resource_id', 'state'],
@@ -82,10 +86,10 @@ class ChangeNodePowerState(base.BaseAction):
82
86
  return self._node_manage_power(target_state)
83
87
 
84
88
  def revert(self):
85
- if self.state == NodeState.POWERON.value:
86
- target_state = NodeState.POWEROFF.value
87
- elif self.state == NodeState.POWEROFF.value:
88
- target_state = NodeState.POWERON.value
89
+ if self.state == metal_constants.PowerState.ON.value:
90
+ target_state = metal_constants.PowerState.OFF.value
91
+ elif self.state == metal_constants.PowerState.OFF.value:
92
+ target_state = metal_constants.PowerState.ON.value
89
93
  return self._node_manage_power(target_state)
90
94
 
91
95
  def _node_manage_power(self, state, retry=60):
@@ -93,30 +97,32 @@ class ChangeNodePowerState(base.BaseAction):
93
97
  raise exception.IllegalArgumentException(
94
98
  message=_("The target state is not defined"))
95
99
 
96
- ironic_client = self.osc.ironic()
97
- nova_client = self.osc.nova()
98
- current_state = ironic_client.node.get(self.node_uuid).power_state
99
- # power state: 'power on' or 'power off', if current node state
100
- # is the same as state, just return True
101
- if state in current_state:
100
+ metal_helper = metal_helper_factory.get_helper(self.osc)
101
+ node = metal_helper.get_node(self.node_uuid)
102
+ current_state = node.get_power_state()
103
+
104
+ if state == current_state.value:
102
105
  return True
103
106
 
104
- if state == NodeState.POWEROFF.value:
105
- node_info = ironic_client.node.get(self.node_uuid).to_dict()
106
- compute_node_id = node_info['extra']['compute_node_id']
107
- compute_node = nova_client.hypervisors.get(compute_node_id)
108
- compute_node = compute_node.to_dict()
107
+ if state == metal_constants.PowerState.OFF.value:
108
+ compute_node = node.get_hypervisor_node().to_dict()
109
109
  if (compute_node['running_vms'] == 0):
110
- ironic_client.node.set_power_state(
111
- self.node_uuid, state)
110
+ node.set_power_state(state)
111
+ else:
112
+ LOG.warning(
113
+ "Compute node %s has %s running vms and will "
114
+ "NOT be shut off.",
115
+ compute_node["hypervisor_hostname"],
116
+ compute_node['running_vms'])
117
+ return False
112
118
  else:
113
- ironic_client.node.set_power_state(self.node_uuid, state)
119
+ node.set_power_state(state)
114
120
 
115
- ironic_node = ironic_client.node.get(self.node_uuid)
116
- while ironic_node.power_state == current_state and retry:
121
+ node = metal_helper.get_node(self.node_uuid)
122
+ while node.get_power_state() == current_state and retry:
117
123
  time.sleep(10)
118
124
  retry -= 1
119
- ironic_node = ironic_client.node.get(self.node_uuid)
125
+ node = metal_helper.get_node(self.node_uuid)
120
126
  if retry > 0:
121
127
  return True
122
128
  else:
@@ -130,4 +136,4 @@ class ChangeNodePowerState(base.BaseAction):
130
136
 
131
137
  def get_description(self):
132
138
  """Description of the action"""
133
- return ("Compute node power on/off through ironic.")
139
+ return ("Compute node power on/off through Ironic or MaaS.")
watcher/common/clients.py CHANGED
@@ -25,6 +25,7 @@ from novaclient import api_versions as nova_api_versions
25
25
  from novaclient import client as nvclient
26
26
 
27
27
  from watcher.common import exception
28
+ from watcher.common import utils
28
29
 
29
30
  try:
30
31
  from ceilometerclient import client as ceclient
@@ -32,6 +33,12 @@ try:
32
33
  except ImportError:
33
34
  HAS_CEILCLIENT = False
34
35
 
36
+ try:
37
+ from maas import client as maas_client
38
+ except ImportError:
39
+ maas_client = None
40
+
41
+
35
42
  CONF = cfg.CONF
36
43
 
37
44
  _CLIENTS_AUTH_GROUP = 'watcher_clients_auth'
@@ -74,6 +81,7 @@ class OpenStackClients(object):
74
81
  self._monasca = None
75
82
  self._neutron = None
76
83
  self._ironic = None
84
+ self._maas = None
77
85
  self._placement = None
78
86
 
79
87
  def _get_keystone_session(self):
@@ -265,6 +273,23 @@ class OpenStackClients(object):
265
273
  session=self.session)
266
274
  return self._ironic
267
275
 
276
+ def maas(self):
277
+ if self._maas:
278
+ return self._maas
279
+
280
+ if not maas_client:
281
+ raise exception.UnsupportedError(
282
+ "MAAS client unavailable. Please install python-libmaas.")
283
+
284
+ url = self._get_client_option('maas', 'url')
285
+ api_key = self._get_client_option('maas', 'api_key')
286
+ timeout = self._get_client_option('maas', 'timeout')
287
+ self._maas = utils.async_compat_call(
288
+ maas_client.connect,
289
+ url, apikey=api_key,
290
+ timeout=timeout)
291
+ return self._maas
292
+
268
293
  @exception.wrap_keystone_exception
269
294
  def placement(self):
270
295
  if self._placement:
File without changes
@@ -0,0 +1,81 @@
1
+ # Copyright 2023 Cloudbase Solutions
2
+ # All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+ # not use this file except in compliance with the License. You may obtain
6
+ # a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations
14
+ # under the License.
15
+
16
+ import abc
17
+
18
+ from watcher.common import exception
19
+ from watcher.common.metal_helper import constants as metal_constants
20
+
21
+
22
+ class BaseMetalNode(abc.ABC):
23
+ hv_up_when_powered_off = False
24
+
25
+ def __init__(self, nova_node=None):
26
+ self._nova_node = nova_node
27
+
28
+ def get_hypervisor_node(self):
29
+ if not self._nova_node:
30
+ raise exception.Invalid(message="No associated hypervisor.")
31
+ return self._nova_node
32
+
33
+ def get_hypervisor_hostname(self):
34
+ return self.get_hypervisor_node().hypervisor_hostname
35
+
36
+ @abc.abstractmethod
37
+ def get_power_state(self):
38
+ # TODO(lpetrut): document the following methods
39
+ pass
40
+
41
+ @abc.abstractmethod
42
+ def get_id(self):
43
+ """Return the node id provided by the bare metal service."""
44
+ pass
45
+
46
+ @abc.abstractmethod
47
+ def power_on(self):
48
+ pass
49
+
50
+ @abc.abstractmethod
51
+ def power_off(self):
52
+ pass
53
+
54
+ def set_power_state(self, state):
55
+ state = metal_constants.PowerState(state)
56
+ if state == metal_constants.PowerState.ON:
57
+ self.power_on()
58
+ elif state == metal_constants.PowerState.OFF:
59
+ self.power_off()
60
+ else:
61
+ raise exception.UnsupportedActionType(
62
+ "Cannot set power state: %s" % state)
63
+
64
+
65
+ class BaseMetalHelper(abc.ABC):
66
+ def __init__(self, osc):
67
+ self._osc = osc
68
+
69
+ @property
70
+ def nova_client(self):
71
+ if not getattr(self, "_nova_client", None):
72
+ self._nova_client = self._osc.nova()
73
+ return self._nova_client
74
+
75
+ @abc.abstractmethod
76
+ def list_compute_nodes(self):
77
+ pass
78
+
79
+ @abc.abstractmethod
80
+ def get_node(self, node_id):
81
+ pass
@@ -0,0 +1,23 @@
1
+ # Copyright 2023 Cloudbase Solutions
2
+ # All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+ # not use this file except in compliance with the License. You may obtain
6
+ # a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations
14
+ # under the License.
15
+
16
+ import enum
17
+
18
+
19
+ class PowerState(str, enum.Enum):
20
+ ON = "on"
21
+ OFF = "off"
22
+ UNKNOWN = "unknown"
23
+ ERROR = "error"
@@ -0,0 +1,33 @@
1
+ # Copyright 2023 Cloudbase Solutions
2
+ # All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
5
+ # not use this file except in compliance with the License. You may obtain
6
+ # a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations
14
+ # under the License.
15
+
16
+ from oslo_config import cfg
17
+
18
+ from watcher.common import clients
19
+ from watcher.common.metal_helper import ironic
20
+ from watcher.common.metal_helper import maas
21
+
22
+ CONF = cfg.CONF
23
+
24
+
25
+ def get_helper(osc=None):
26
+ # TODO(lpetrut): consider caching this client.
27
+ if not osc:
28
+ osc = clients.OpenStackClients()
29
+
30
+ if CONF.maas_client.url:
31
+ return maas.MaasHelper(osc)
32
+ else:
33
+ return ironic.IronicHelper(osc)