Commit Graph

146 Commits

Author SHA1 Message Date
Felipe Reyes b915f8e6f8 Use wss protocol when SSL enabled
This patch checks if HTTPS configuration is enabled in Apache to
determine if the websocket protocol should switch from 'ws' to 'wss' or
not.

Change-Id: I738652373604966b6df079e45a0ad26c83e21688
Closes-Bug: #2039490
2023-10-26 18:09:35 -03:00
Felipe Reyes 816ee80cd0 Add new interface 'dashboard'
This new interface consumes information exposed by openstack-dashboard
to correctly configure nova-serialproxy and allow requests coming from
the web browser that tries to load the serial console.

Change-Id: I2d82abffb9649f16a792f180806cea36cc5e25df
Closes-Bug: #2030094
2023-09-21 10:17:36 -03:00
Felipe Reyes 89b94fe7f5 Update unittests
Drop the use of the pattern "self.assertTrue([...].called)" in favor
"[...].assert_called()"

Change-Id: I6546623d043c4bde14b8532fa9125f8a12db280d
2023-03-22 15:27:36 -03:00
Alex Kavanagh 007f9e33b0 In nova_cc_utils.py:resolve_hosts_for: .append -> .add
The method was refactored (in part) to use sets to enforce uniqueness of
the hosts.  Unfortunately, a list method (.append()) slipped through
that should have been converted to .add(). This fixes that error.

Change-Id: I248430cd1a9156efab745fe110a39441b503b3a5
Closes-Bug: #1992789
2022-10-17 11:12:44 +01:00
Hervé Beraud 71bc319326 Use unittest.mock instead of mock
The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we can use the
standard lib unittest.mock module instead.

Note that https://github.com/openstack/charms.openstack is used during tests
and he need `mock`, unfortunatelly it doesn't declare `mock` in its
requirements so it retrieve mock from other charm project (cross dependency).
So we depend on charms.openstack first and when
Ib1ed5b598a52375e29e247db9ab4786df5b6d142 will be merged then CI
will pass without errors.

Depends-On: Ib1ed5b598a52375e29e247db9ab4786df5b6d142
Change-Id: Id925078c5c04c2f89a570bdf7171c666839f9e40
2021-12-15 14:16:56 +00:00
Alex Kavanagh 36ef217bc6 Fix SQLite locking issue on unit tests
stestr runs tests in parallel and this can cause issues with locking
when SQLite is not mocked out properly and gets used in a test.  This
patch just switches Storage to use :memory: so that locking does not
occur.

Closes-Bug: #1908282
Change-Id: Iaa1c7b78dee498e0cc6dc6fccf12e74f22225ecd
2021-11-04 10:52:39 +00:00
Rodrigo Barbieri 1a63d9c0b6 Fix ssh keys duplication
Upon running hooks that update ssh_keys, they
end up duplicated in the /etc/nova/compute_ssh/* files
and cloud-compute relations because the code that
checks whether the keys already exist are currently
not working.

This change fixes the deduplication code and improves
unit tests, while also handling a special case for
specific ubuntu-version scenarios.

Change-Id: I93f9418d5340e7cb599a42970d78557362c1542f
Closes-bug: #1943753
2021-10-06 13:07:33 +00:00
Billy Olsen 231a0f1459 Drop placement endpoints from relation in train+
When a cloud is deployed earlier than the Train release, the placement
service is provided by nova-cloud-controller. As part of an upgrade to
Train, the new placement service is added and updates the placement
endpoint in the service catalog. The nova-cloud-controller charm no
longer advertises the placement service URL, but because the data
exists on the relation until removed, the service catalog changes the
placement URL to the placement endpoints advertised from
nova-cloud-controller.

Fix this by explicitly removing the placement service URLs when the
placement service is not provided by nova-cloud-controller.

Change-Id: Ibb3b1429820a4188fe3d2c1142c295c0de4ee24e
Closes-Bug: #1928992
2021-07-27 11:23:59 -07:00
Aurelien Lourot bd3e24f359 Fix for not passing CA cert to nova-compute
The charm looked for `keystone_juju_ca_cert` on disk
instead of
`/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt`

Synced charm-helpers for
https://github.com/juju/charm-helpers/pull/570

Change-Id: Ib7cfdadc3a75fca951792ef2c2e2b454b1ad021d
Closes-Bug: #1915504
2021-02-16 14:45:03 +01:00
Frode Nordahl 93efd6e81d
Fix CA certificate on cloud-compute relation
Note that part of this fix belongs in c-h, but let's add it here
as a tactical measure given we are practically frozen.

Enable TLS in the functional test for focal-ussuri and onwards.

Also switch to focal-ussuri as target for smoke.

Drop Trusty/Mitaka as it currently does not pass with symptoms
like https://bugs.launchpad.net/charm-nova-compute/+bug/1861094

Closes-Bug: #1911902
Change-Id: I7b12479ce3afb94a0fb21c26b1ac78736b81aba2
2021-01-18 13:57:24 +01:00
Corey Bryant 7983d1aaa9 Ensure cell0 updated on db/amqp change
Prior to this change, cell1 was updated when there was a database
or rabbitmq-server relation change, but cell0 wasn't. Ensure that
cell0 is also updated.

Change-Id: I670d0295ea339b21166ef7b18509b04a5beaa959
Closes-Bug: #1892904
2020-09-09 01:18:44 +00:00
David Ames 86bb59ec3e Specify port for mysql connection
Change-Id: I35cadeed547e669bc68a380dbf50929e304b697c
2020-05-05 16:16:52 -07:00
Zuul adcbd7b28c Merge "Disable Apache port 80" 2020-01-31 15:52:57 +00:00
tpsilva 56c70d055a Disable Apache port 80
Currently, Apache ports.conf file is not being configured by this
charm. This patch changes the ports.conf default file with another one
that does not open port 80 on SSL environments..

Change-Id: Id0b3ce106e2779ce6a44b59c0b08fb1011dfdd54
Closes-bug: #1845665
2020-01-28 14:53:13 +00:00
Liam Young 0a300b919e When resuming, exclude haproxy
When resuming services exclude those managed by hacluster, in
this case haproxy. If pacemaker lacks quorum it may shut haproxy
down which will cause this charm to error.

Charmhelper sync included to bring in required
get_managed_services_and_ports method.

Change-Id: I063c168595bee05c924cb23469f8dc866a43982b
2020-01-25 07:47:57 +00:00
Tiago Pasqualini da Silva 9ad9a8423a Revert "Disable Apache default ports"
This reverts commit 0bf9812bc1.

Change-Id: Ia935798994e24910ad23aca24cd777aa21d35561
2019-12-20 02:05:22 +00:00
tpsilva 0bf9812bc1 Disable Apache default ports
Openstack services don't use the default ports (80 and 443), so
change Apache to not open them.

Change-Id: I518465cd2d6f53e229ab81ebd751f311f8627f83
Closes-bug: #1845665
2019-11-27 12:51:56 +00:00
Corey Bryant 45988df1ed Make placement a required interface as of train
Make placement a required interface for train and above as
placement is required in order to schedule instances.

Change-Id: If2472ec24df4c3d90b14189f8c4d3cceee5edc97
Closes-Bug: #1849893
2019-10-25 21:23:00 +00:00
Corey Bryant 2cfb795490 Ensure placement charm related before Train upgrade
As of OpenStack Train, the placement charm manages the placement API, and it
is no longer managed by nova-cloud-controller. This requires the placement
charm to be deployed and related to nova-cloud-controller prior to upgrading
nova-cloud-controller to Train.

This patch ensures that if an attempt is made to upgrade nova-cloud-controller
from Stein to Train, and placement is not yet related, it will block and
prevent the upgrade.

Change-Id: I217adfb59aed2e509a56b6559a528ae4c0adaa48
Closes-Bug: 1848529
2019-10-18 13:52:15 +00:00
Frode Nordahl bf2cd49829
Remove ``nova-consoleauth`` package as of Train
The Nova console authorization has been moved to the database
backend and the separate service and package is no longer
necessary.

Change-Id: I672ae9538dc687a1c868bf99001041a54241ec24
Closes-Bug: #1848478
2019-10-17 12:29:40 +02:00
Corey Bryant 81860afeca Disable nova placement API
The placement project has split from nova into its own project
in Train. This patch disables the nova placement API as of Stein
when the placement charm relatation joins, and discontinues
nova placement installation as of Train for new installs.

Change-Id: If7c37ef8936e418b5afd21d83c9322563348cbcf
Needed-By: https://review.opendev.org/#/c/687915/
Partial-Bug: 1811681
2019-10-11 20:00:38 +00:00
James Page 3c806a23f6 stein: install python3-mysqldb for sqlalchemy dialect change
At Stein, the default mysql dialect in SQLAlchemy switched back
to MySQLDB in Ubuntu; as a result the db connection URL's stored
in the nova_api database for Nova cells are stale and need to
prefixed mysql+pymysql:// to work with the pymysql dialect.

However at this point in time there is no way to update the DB
URL for Nova Cell 0.

This fix works around this problem by installing python3-mysqldb
which provides the default dialect needed when using mysql://
prefixed DB connection URI's.

Change-Id: I3f74f18f649786fefa113fc3d8fa7c24010a185d
Related-Bug: 1835037
2019-07-23 16:47:06 +01:00
Alex Kavanagh afa3c9a58e Refactor ssh_known_hosts_lines() and ssh_authorized_keys_lines()
Refactor ssh_known_hosts_lines() and ssh_authorized_keys_lines to be
easier to maintain and only call rstrip() once (per function).

Change-Id: Id2774bb1551e4826a2fd71d1a371d65ab2439a7d
2019-07-03 14:18:16 +01:00
Zuul 7d10e5d942 Merge "Refactor ssh_compute_remove() in nova" 2019-06-25 09:21:42 +00:00
Alex Kavanagh a0edc83109 Remove the nova-api handling functions
The nova-api (commit 962790239b)
introduced a 'nova-api' ready relation, but it was never added to the
metadata.yaml and it has never been used.  This commit removes it, as
there is no need for it after 3 years, and it therefore has a
maintenance burden, even if not being used.

Change-Id: I6b13e2639b808fd640a6f8d892d1e3dd58215361
2019-06-24 20:48:20 +01:00
Alex Kavanagh 978e29012f Refactor ssh_compute_remove() in nova
This removes one loop, but also changes the unit test so that it is not
dependent on the implementation of the function, specifically w.r.t. the
number of writes to the output file (which can now be changed in the
future).

Change-Id: Ieb0a373ed55971af0c357fa89c199fb781e772ab
2019-06-24 10:58:49 +01:00
Rodrigo Barbieri a51efaf640 Propagate vendor_data from nova-cloud-controller
When using DVR and L3HA neutron deployment options,
Nova API Metadata requests are served from compute nodes,
instead of from neutron-gateway nodes.

This change allows nova-cloud-controller to send vendor_data
configuration values to nova-compute charm relation so it
can write to nova-compute's nova.conf appropriately.

Replaced the existing context logic with inheritance
from a new context created in charm-helpers, so the
logic can be shared across several charms that write
vendor metadata to nova.conf and vendor_data.json.

Also, small fix in the vendor-data and vendor-data-url
descriptions, where it was incorrectly stating that such
configuration would be effective in nova-cloud-controller
on Queens release.

The values set in vendor-data and vendor-data-url config
options will always be propagated to nova-compute regardless
of the OpenStack release. Those values will continue to only
be effective in nova-cloud-controller nodes on Rocky release
or later.

Included sync of charm-helpers code in order to inherit
the refactored vendor metadata contexts.

Change-Id: If8373fc6b2d04dbc29ed07896d385ac920cae3f4
Depends-On: I0c79e1bfac9fbe7009a7e862ad010cfa2de8cfda
Closes-Bug: #1777714
2019-06-05 10:22:56 -03:00
Liam Young 822daf2794 Check Apache ssl dir when determining restart map
If the certificates change then services needs to be restarted. This
change adds the SSL directory to the restart map to ensure any
certificate changes trigger a restart.

Also, if the certificates change we need to pass those on to
nova-compute.

Change-Id: I4cb2f760c26f0804d3cb7466c8aa741d5e0ec314
Closes-Bug: 1828530
2019-05-10 15:01:04 +00:00
Zhang Hua b182ffa7f7 Add the support to customize the console access port
For novnc, need to set novncproxy_port in proxy nodes and
novncproxy_base_url in nova-compute nodes.
For xvpvnc, need to set xvpvncproxy_port in proxy nodes and
xvpvncproxy_base_url in nova-compute nodes.
For spice, need to set spicehtml5proxy_port in proxy nodes and
spicehtml5proxy_base_url in nova-compute nodes.

When release >= Mitaka, novncproxy_port and xvpvncproxy_port
are moved from [default] section into [vnc] section.
spicehtml5proxy_port is renamed to html5proxy_port and moved
to [spice] section.

So eventually the console access port can be customized by:

juju config nova-cloud-controller console-access-protocol=novnc
juju config nova-cloud-controller console-access-port=xx

If console-access-port is not defined, then default port is 6080
for novpc, 6081 for xvpvnc, 6082 for spice.

Change-Id: I4775ad42ba11b0c28163bf7e3718c56d18a2031f
Closes-Bug: #1800753
Signed-off-by: Zhang Hua <joshua.zhang@canonical.com>
2019-03-16 10:46:44 +00:00
Liam Young ba19f921c5 Check console enabled before starting console svc
Check if console is enabled in this deploy before trying to start
console service. As part of this add a functions to determine whether
console is enabled and change existing methods to use them.

Change-Id: I91e2654bb0c5f89f51c703330ae2bd0a64cc84f3
Closes-Bug: #1820266
2019-03-15 14:29:54 +00:00
James Page b6e314077f Drop support for single-nova-consoleauth
Remove support for single-nova-consoleauth operation; this option
managed a single instance of the nova-consoleauth process across
a cluster nova-cloud-controller application using the hacluster
charm.  This proves somewhat racey on deployment as the ocf resource
deep checks the operation of nova-consoleauth including connectivity
to AMQP etc..  If the clustering of the service occurs before
other principle relations have been completed, the resource will
fail to start and the hook execution will spin, never returning.

HA deployments should always use memcached to share tokens between
instances of the nova-consolauth daemon; If the 'ha' relation is
detected, then ensure that a memcache relation is then required
for charm operation.

To support evaluation of the memcache relation completeness
the memcache specific code in InstanceConsoleContext was split out
into a new memcache specific class RemoteMemcacheContext.

Existing pacemaker resources will be deleted on upgrade; units will
move into a blocked state until a relation is added to memcached.

The nova-consoleauth service is resumed on upgrade to ensure that
instances run on all nova-cloud-controller units.

Change-Id: I2ac91b2bd92269b761befeb7563ad01cc5431151
Closes-Bug: 1781620
2019-03-06 12:36:06 +00:00
Sahid Orentino Ferdjaoui 13eca55803 service: updates nova-api-os-compute service to use apache wsgi
Due to an issue in python3 oslo_cache+eventlet when using
memcached. As workaroud for Rocky it has been decided to run service
nova-api-os-compute from systemd to apache2.

Closes-Bug: #1812672
Depends-On: https://review.openstack.org/#/c/633218
Depends-On: https://review.openstack.org/#/c/633482
Change-Id: I3bf279638c5decf1020345f3d2e876e379144997
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
2019-02-01 16:32:28 -05:00
Sahid Orentino Ferdjaoui 131497868f template: update conf template for placement-api
Currently we directly use the one provided by charmhelper which does
not allow to reuse it for an other service. In this commit we symlink
a new template called wsgi-placement-api.conf to
charmhelper/../wsgi-openstack-api.conf.

The disable_package_apache2_site() call has been added in
do_openstack_upgrade() since previously it was not necessary to have
it during this step.

The disable_package_apache2_site() call has been added in
upgrade-charm to ensure that we remove old wsgi config for users which
are already using bionic-rocky and are upgrading their charm.

Partial-Bug: #1812672
Change-Id: Idc3cad9304eaf9b610db20650c32cd754f016358
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@canonical.com>
2019-02-01 15:00:14 -05:00
lijunjie 8eaefe37b5 Fix the misspelling of "except"
Change-Id: I0d83a5ac4ca7e377a096adc9d23cf284ab1f997d
2019-01-04 17:15:14 +08:00
Alex Kavanagh 50a7253b80 Fix guardmap as a function object issue in service_guard()
The issue was the original commit had a bug (using the wrong variable),
and also that there were no tests to verify the functionality.  This
patchset fixes the bug and adds tests to verify the contract.

Change-Id: Ia8b5580132c5a592461a57fb514994ab64a9ed42
Closes-Bug: #1805128
2018-11-26 12:44:01 +00:00
Liam Young 314aff9e53 Fix type error when encoding certificate
The keystone_ca_cert_b64 function retrieved the CA cert from a file
before encoding it but it was passing a str to the b64encode which
requires a bytes-like object.

Change-Id: Iafaf5916b04746eb045fcd3dfe9676a80c88b464
2018-10-30 17:13:50 +00:00
Alex Kavanagh 9c12812735 Switch the charm to support py3
Some major changes:
* the charm has been rebased (from a Python perspective) to be rooted in
  the charm directory.  This is a single root.
* Imports have been changed so that the don't add lots of imports to the
  namespace of the module doing the import.
* The code that used to run at module import time has been made lazy
  such that it only has to run if the relevant functions are called.
  This includes restart_on_change parameters, the harden function and
  the parameters to the guard_map.  Appropriate changes will be
  submitted to charm-helpers.
* Several tests had to be re-written as (incorrect) mocking meant that
  text fixtures didn't actually match what the code was doing.  Thus,
  the tests were meaningless.
* This has had a net positive impact on the unit tests wrt to importing
  modules and mocking.

Change-Id: Id07d9d1caaa9b29453a63c2e49ba831071e9457f
2018-10-18 15:43:03 +01:00
Liam Young 0f9ada1713 Fix assess status for super-conductor
In a cells deployment its possible that the top-level
nova-cloud-controller will have no compute nodes associated with it.
This change fixes the work load status in that scenario.

There is also a drive by fix to return empty contexts for the cell
db and amqp contexts if the relation do not yet exists.

Change-Id: Ia8eeccb6794dd016185eb0cfb05339b76cef9348
2018-10-09 10:32:51 +00:00
Liam Young 6695d79c95 Add support for cells v2
This change adds relations necessary for registering a compute cell
with the superconductor. For a cell to be registered this charm
must have relations with the compute cells conductor, database and
message queue. Only when all these relations are complete can the
registration happen. Below are major changes included in this PR.

* Add nova-cell-api relation for communicating with the
  nova-cell-conductor
* Add shared-db-cell relation for communicating with the
  a compute cells database.
* Add amqp-cell relation for communicating with the
  a compute cells message queue.
* Add methods for registering cells with the
  superconductors database.
* Charm helper sync

Change-Id: Ic6ddc29426319b98b147c29031f60485fccc513f
2018-10-05 11:50:21 +00:00
Corey Bryant d5c5cccb0a py3: Switch to using Python 3 for rocky or later
Switch package install to Python 3 for OpenStack Rocky or later.

When upgrading, remove any python-* packages that were explicitly
installated and then autoremove --purge any dependencies that are
no longer required.

Change-Id: I87ee4a0a854f88b931093f6245a3a1057bf56c57
2018-10-04 11:19:06 +01:00
Liam Young e20db83c7d Add nova-metadata service
Add a service for handling nova metadata api services. This was
previously handled by the neutron-gateway and still is for
deployemnts up to and including Pike, For the neutron metadata
service and the nova service to communicate they need a shared
secret. To achieve this, the change includes:

* A charmhelper sync to get support for multiple wsgi vhosts
* Rendering new wsgi vhost and corresponding haproxy config.
* Setting a shared-secret down the relation with the neutron
  gateway.
* Remove fragile keystone authtoken checks as they are failing
  after a ch sync and any issues will be caught by the instance
  launch functional test.

Change-Id: I5ad15ba782cb87b6fdb3c0941a6482d201670bff
2018-10-03 07:24:05 +00:00
James Page 935d30571c Use v2.1 API for >= Queens
Switch to using the v2.1 API endpoint for OpenStack Queens or later.

Closes-Bug: 1794271

Change-Id: Ia21b3a6782ab944b7c41564e889e6b12d264b731
2018-09-27 15:08:17 +01:00
Frode Nordahl edc18d4937
Make charm agnostic of underlying init system
Replace charm custom init control functions with `service_pause`
and `service_resume` functions from charm-helpers.

Change-Id: I235af30a19294316f65fba0e13fe10ae50164a42
Closes-Bug: #1765215
2018-04-20 19:10:59 +02:00
Liam Young a0778a5304 Only run map_instances for Ocata
map_instances only needs to be run during the transition from
Newton to Ocata to map existing instances into a cell. All
new Ocata instances will be automatically mapped to a call.
This change limits the slow running map_instances command to
just run for upgrades to Ocata

Change-Id: Ic2e2df530504284d28cfcab26a71d211342203fa
Closes-Bug: #1743357
2018-01-23 13:27:00 +00:00
Liam Young c276dfdb96 Batch up map_instances call
nova-manage map_instances maps all instances into a cell in batches
of 50 if max-count is not set. Setting max-count causes the script
to run a single batch of size max-count. The return code of the
script shows if there are still more to do. This change runs
map_instances repeatedly with a batch size of 50000 while rc is 1
and then exists cleanly when a rc 0 is recieved.

Change-Id: Id1184778a5ae94bb3b57348b10d12077b093d6dd
Partial-Bug: #1742115
2018-01-17 14:43:10 +00:00
Liam Young edd9b1face Add action for running archive-deleted-rows
Add an action for moving stale data to shadow tables using
nova-manage *1. This will speed up other operations such as
map_instances which no longer need to work against stale
data.

*1 https://docs.openstack.org/nova/pike/cli/nova-manage.html

Change-Id: I03f3d641b50cfc6f02262edb0f714ba6e9566775
Partial-Bug: #1742115
2018-01-12 14:11:16 +00:00
James Page 0f14eac672 Remove deploy from source support
Drop support for deployment from Git repositories, as deprecated
in the 17.02 charm release.  This feature is unmaintained and has
no known users.

Change-Id: I2fe15b648d485e5b03965a00dee6324669ebe9fa
2018-01-12 10:42:50 +00:00
James Page 5c79af1bd1 Drop postgresql support
Remove postgresql DB support; This feature is untested as part
of the charms, is not in use and was deprecated as part of
the 1708 charms release.

Change-Id: I866559f519ace3476e0cc85661d99e5f5491227d
2017-12-21 12:01:58 +00:00
Corey Bryant 3b873932be Add nova-manage failure verbosity and clean up Cells V2 code
Update all nova-manage commands to use subprocess.check_output()
and log subprocess.CalledProcessError.output on failure. This
will help capture nova-manage error details on first failure.

Specify cell1 uuid on discover_hosts call. This doesn't change
behavior, it is just more explicit and useful if we move to
multiple cells in the future.

Introduce an is_cellv2_init_ready() function that uses contexts to
check if cells_v2 is ready to initialize. This cleans up the
corresponding TODOs.

Move checks for cell v2 init readiness to update_cell_db_if_ready(),
also cleaning up corresponding TODOs.

Change-Id: I313edce84d3d249031e020a4fbb4baf216c01ddb
Related-Bug: 1720846
2017-10-16 12:19:55 +00:00
zhangyangyang 29f42fa5de change assert(Not)Equals to assert(Not)Equal
According to http://docs.python.org/2/library/unittest.html
assert(Not)Equals is a deprecated alias of assert(Not)Equal.

Change-Id: Iac2d5eefe47b96efc787c6eca5ca014ca3b3910c
Closes-Bug: #1329757
2017-09-12 15:50:42 +08:00