4eb3b8
From 6e79106a09a0d142915da1fb48640575bb4bfe08 Mon Sep 17 00:00:00 2001
4eb3b8
From: Anh Vo <anhvo@microsoft.com>
4eb3b8
Date: Tue, 13 Apr 2021 17:39:39 -0400
4eb3b8
Subject: [PATCH 3/7] azure: Removing ability to invoke walinuxagent (#799)
4eb3b8
4eb3b8
RH-Author: Eduardo Otubo <otubo@redhat.com>
4eb3b8
RH-MergeRequest: 45: Add support for userdata on Azure from IMDS
4eb3b8
RH-Commit: [3/7] f5e98665bf2093edeeccfcd95b47df2e44a40536
4eb3b8
RH-Bugzilla: 2023940
4eb3b8
RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
4eb3b8
RH-Acked-by: Mohamed Gamal Morsy <mmorsy@redhat.com>
4eb3b8
4eb3b8
Invoking walinuxagent from within cloud-init is no longer
4eb3b8
supported/necessary
4eb3b8
---
4eb3b8
 cloudinit/sources/DataSourceAzure.py          | 137 ++++--------------
4eb3b8
 doc/rtd/topics/datasources/azure.rst          |  62 ++------
4eb3b8
 tests/unittests/test_datasource/test_azure.py |  97 -------------
4eb3b8
 3 files changed, 35 insertions(+), 261 deletions(-)
4eb3b8
4eb3b8
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
4eb3b8
index de1452ce..020b7006 100755
4eb3b8
--- a/cloudinit/sources/DataSourceAzure.py
4eb3b8
+++ b/cloudinit/sources/DataSourceAzure.py
4eb3b8
@@ -381,53 +381,6 @@ class DataSourceAzure(sources.DataSource):
4eb3b8
                     util.logexc(LOG, "handling set_hostname failed")
4eb3b8
         return False
4eb3b8
 
4eb3b8
-    @azure_ds_telemetry_reporter
4eb3b8
-    def get_metadata_from_agent(self):
4eb3b8
-        temp_hostname = self.metadata.get('local-hostname')
4eb3b8
-        agent_cmd = self.ds_cfg['agent_command']
4eb3b8
-        LOG.debug("Getting metadata via agent.  hostname=%s cmd=%s",
4eb3b8
-                  temp_hostname, agent_cmd)
4eb3b8
-
4eb3b8
-        self.bounce_network_with_azure_hostname()
4eb3b8
-
4eb3b8
-        try:
4eb3b8
-            invoke_agent(agent_cmd)
4eb3b8
-        except subp.ProcessExecutionError:
4eb3b8
-            # claim the datasource even if the command failed
4eb3b8
-            util.logexc(LOG, "agent command '%s' failed.",
4eb3b8
-                        self.ds_cfg['agent_command'])
4eb3b8
-
4eb3b8
-        ddir = self.ds_cfg['data_dir']
4eb3b8
-
4eb3b8
-        fp_files = []
4eb3b8
-        key_value = None
4eb3b8
-        for pk in self.cfg.get('_pubkeys', []):
4eb3b8
-            if pk.get('value', None):
4eb3b8
-                key_value = pk['value']
4eb3b8
-                LOG.debug("SSH authentication: using value from fabric")
4eb3b8
-            else:
4eb3b8
-                bname = str(pk['fingerprint'] + ".crt")
4eb3b8
-                fp_files += [os.path.join(ddir, bname)]
4eb3b8
-                LOG.debug("SSH authentication: "
4eb3b8
-                          "using fingerprint from fabric")
4eb3b8
-
4eb3b8
-        with events.ReportEventStack(
4eb3b8
-                name="waiting-for-ssh-public-key",
4eb3b8
-                description="wait for agents to retrieve SSH keys",
4eb3b8
-                parent=azure_ds_reporter):
4eb3b8
-            # wait very long for public SSH keys to arrive
4eb3b8
-            # https://bugs.launchpad.net/cloud-init/+bug/1717611
4eb3b8
-            missing = util.log_time(logfunc=LOG.debug,
4eb3b8
-                                    msg="waiting for SSH public key files",
4eb3b8
-                                    func=util.wait_for_files,
4eb3b8
-                                    args=(fp_files, 900))
4eb3b8
-            if len(missing):
4eb3b8
-                LOG.warning("Did not find files, but going on: %s", missing)
4eb3b8
-
4eb3b8
-        metadata = {}
4eb3b8
-        metadata['public-keys'] = key_value or pubkeys_from_crt_files(fp_files)
4eb3b8
-        return metadata
4eb3b8
-
4eb3b8
     def _get_subplatform(self):
4eb3b8
         """Return the subplatform metadata source details."""
4eb3b8
         if self.seed.startswith('/dev'):
4eb3b8
@@ -1354,35 +1307,32 @@ class DataSourceAzure(sources.DataSource):
4eb3b8
            On failure, returns False.
4eb3b8
         """
4eb3b8
 
4eb3b8
-        if self.ds_cfg['agent_command'] == AGENT_START_BUILTIN:
4eb3b8
-            self.bounce_network_with_azure_hostname()
4eb3b8
+        self.bounce_network_with_azure_hostname()
4eb3b8
 
4eb3b8
-            pubkey_info = None
4eb3b8
-            try:
4eb3b8
-                raise KeyError(
4eb3b8
-                    "Not using public SSH keys from IMDS"
4eb3b8
-                )
4eb3b8
-                # pylint:disable=unreachable
4eb3b8
-                public_keys = self.metadata['imds']['compute']['publicKeys']
4eb3b8
-                LOG.debug(
4eb3b8
-                    'Successfully retrieved %s key(s) from IMDS',
4eb3b8
-                    len(public_keys)
4eb3b8
-                    if public_keys is not None
4eb3b8
-                    else 0
4eb3b8
-                )
4eb3b8
-            except KeyError:
4eb3b8
-                LOG.debug(
4eb3b8
-                    'Unable to retrieve SSH keys from IMDS during '
4eb3b8
-                    'negotiation, falling back to OVF'
4eb3b8
-                )
4eb3b8
-                pubkey_info = self.cfg.get('_pubkeys', None)
4eb3b8
-
4eb3b8
-            metadata_func = partial(get_metadata_from_fabric,
4eb3b8
-                                    fallback_lease_file=self.
4eb3b8
-                                    dhclient_lease_file,
4eb3b8
-                                    pubkey_info=pubkey_info)
4eb3b8
-        else:
4eb3b8
-            metadata_func = self.get_metadata_from_agent
4eb3b8
+        pubkey_info = None
4eb3b8
+        try:
4eb3b8
+            raise KeyError(
4eb3b8
+                "Not using public SSH keys from IMDS"
4eb3b8
+            )
4eb3b8
+            # pylint:disable=unreachable
4eb3b8
+            public_keys = self.metadata['imds']['compute']['publicKeys']
4eb3b8
+            LOG.debug(
4eb3b8
+                'Successfully retrieved %s key(s) from IMDS',
4eb3b8
+                len(public_keys)
4eb3b8
+                if public_keys is not None
4eb3b8
+                else 0
4eb3b8
+            )
4eb3b8
+        except KeyError:
4eb3b8
+            LOG.debug(
4eb3b8
+                'Unable to retrieve SSH keys from IMDS during '
4eb3b8
+                'negotiation, falling back to OVF'
4eb3b8
+            )
4eb3b8
+            pubkey_info = self.cfg.get('_pubkeys', None)
4eb3b8
+
4eb3b8
+        metadata_func = partial(get_metadata_from_fabric,
4eb3b8
+                                fallback_lease_file=self.
4eb3b8
+                                dhclient_lease_file,
4eb3b8
+                                pubkey_info=pubkey_info)
4eb3b8
 
4eb3b8
         LOG.debug("negotiating with fabric via agent command %s",
4eb3b8
                   self.ds_cfg['agent_command'])
4eb3b8
@@ -1617,33 +1567,6 @@ def perform_hostname_bounce(hostname, cfg, prev_hostname):
4eb3b8
     return True
4eb3b8
 
4eb3b8
 
4eb3b8
-@azure_ds_telemetry_reporter
4eb3b8
-def crtfile_to_pubkey(fname, data=None):
4eb3b8
-    pipeline = ('openssl x509 -noout -pubkey < "$0" |'
4eb3b8
-                'ssh-keygen -i -m PKCS8 -f /dev/stdin')
4eb3b8
-    (out, _err) = subp.subp(['sh', '-c', pipeline, fname],
4eb3b8
-                            capture=True, data=data)
4eb3b8
-    return out.rstrip()
4eb3b8
-
4eb3b8
-
4eb3b8
-@azure_ds_telemetry_reporter
4eb3b8
-def pubkeys_from_crt_files(flist):
4eb3b8
-    pubkeys = []
4eb3b8
-    errors = []
4eb3b8
-    for fname in flist:
4eb3b8
-        try:
4eb3b8
-            pubkeys.append(crtfile_to_pubkey(fname))
4eb3b8
-        except subp.ProcessExecutionError:
4eb3b8
-            errors.append(fname)
4eb3b8
-
4eb3b8
-    if errors:
4eb3b8
-        report_diagnostic_event(
4eb3b8
-            "failed to convert the crt files to pubkey: %s" % errors,
4eb3b8
-            logger_func=LOG.warning)
4eb3b8
-
4eb3b8
-    return pubkeys
4eb3b8
-
4eb3b8
-
4eb3b8
 @azure_ds_telemetry_reporter
4eb3b8
 def write_files(datadir, files, dirmode=None):
4eb3b8
 
4eb3b8
@@ -1672,16 +1595,6 @@ def write_files(datadir, files, dirmode=None):
4eb3b8
         util.write_file(filename=fname, content=content, mode=0o600)
4eb3b8
 
4eb3b8
 
4eb3b8
-@azure_ds_telemetry_reporter
4eb3b8
-def invoke_agent(cmd):
4eb3b8
-    # this is a function itself to simplify patching it for test
4eb3b8
-    if cmd:
4eb3b8
-        LOG.debug("invoking agent: %s", cmd)
4eb3b8
-        subp.subp(cmd, shell=(not isinstance(cmd, list)))
4eb3b8
-    else:
4eb3b8
-        LOG.debug("not invoking agent")
4eb3b8
-
4eb3b8
-
4eb3b8
 def find_child(node, filter_func):
4eb3b8
     ret = []
4eb3b8
     if not node.hasChildNodes():
4eb3b8
diff --git a/doc/rtd/topics/datasources/azure.rst b/doc/rtd/topics/datasources/azure.rst
4eb3b8
index e04c3a33..ad9f2236 100644
4eb3b8
--- a/doc/rtd/topics/datasources/azure.rst
4eb3b8
+++ b/doc/rtd/topics/datasources/azure.rst
4eb3b8
@@ -5,28 +5,6 @@ Azure
4eb3b8
 
4eb3b8
 This datasource finds metadata and user-data from the Azure cloud platform.
4eb3b8
 
4eb3b8
-walinuxagent
4eb3b8
-------------
4eb3b8
-walinuxagent has several functions within images.  For cloud-init
4eb3b8
-specifically, the relevant functionality it performs is to register the
4eb3b8
-instance with the Azure cloud platform at boot so networking will be
4eb3b8
-permitted.  For more information about the other functionality of
4eb3b8
-walinuxagent, see `Azure's documentation
4eb3b8
-<https://github.com/Azure/WALinuxAgent#introduction>`_ for more details.
4eb3b8
-(Note, however, that only one of walinuxagent's provisioning and cloud-init
4eb3b8
-should be used to perform instance customisation.)
4eb3b8
-
4eb3b8
-If you are configuring walinuxagent yourself, you will want to ensure that you
4eb3b8
-have `Provisioning.UseCloudInit
4eb3b8
-<https://github.com/Azure/WALinuxAgent#provisioningusecloudinit>`_ set to
4eb3b8
-``y``.
4eb3b8
-
4eb3b8
-
4eb3b8
-Builtin Agent
4eb3b8
--------------
4eb3b8
-An alternative to using walinuxagent to register to the Azure cloud platform
4eb3b8
-is to use the ``__builtin__`` agent command.  This section contains more
4eb3b8
-background on what that code path does, and how to enable it.
4eb3b8
 
4eb3b8
 The Azure cloud platform provides initial data to an instance via an attached
4eb3b8
 CD formatted in UDF.  That CD contains a 'ovf-env.xml' file that provides some
4eb3b8
@@ -41,16 +19,6 @@ by calling a script in /etc/dhcp/dhclient-exit-hooks or a file in
4eb3b8
 'dhclient_hook' of cloud-init itself. This sub-command will write the client
4eb3b8
 information in json format to /run/cloud-init/dhclient.hook/<interface>.json.
4eb3b8
 
4eb3b8
-In order for cloud-init to leverage this method to find the endpoint, the
4eb3b8
-cloud.cfg file must contain:
4eb3b8
-
4eb3b8
-.. sourcecode:: yaml
4eb3b8
-
4eb3b8
-  datasource:
4eb3b8
-    Azure:
4eb3b8
-      set_hostname: False
4eb3b8
-      agent_command: __builtin__
4eb3b8
-
4eb3b8
 If those files are not available, the fallback is to check the leases file
4eb3b8
 for the endpoint server (again option 245).
4eb3b8
 
4eb3b8
@@ -83,9 +51,6 @@ configuration (in ``/etc/cloud/cloud.cfg`` or ``/etc/cloud/cloud.cfg.d/``).
4eb3b8
 
4eb3b8
 The settings that may be configured are:
4eb3b8
 
4eb3b8
- * **agent_command**: Either __builtin__ (default) or a command to run to getcw
4eb3b8
-   metadata. If __builtin__, get metadata from walinuxagent. Otherwise run the
4eb3b8
-   provided command to obtain metadata.
4eb3b8
  * **apply_network_config**: Boolean set to True to use network configuration
4eb3b8
    described by Azure's IMDS endpoint instead of fallback network config of
4eb3b8
    dhcp on eth0. Default is True. For Ubuntu 16.04 or earlier, default is
4eb3b8
@@ -121,7 +86,6 @@ An example configuration with the default values is provided below:
4eb3b8
 
4eb3b8
   datasource:
4eb3b8
     Azure:
4eb3b8
-      agent_command: __builtin__
4eb3b8
       apply_network_config: true
4eb3b8
       data_dir: /var/lib/waagent
4eb3b8
       dhclient_lease_file: /var/lib/dhcp/dhclient.eth0.leases
4eb3b8
@@ -144,9 +108,7 @@ child of the ``LinuxProvisioningConfigurationSet`` (a sibling to ``UserName``)
4eb3b8
 If both ``UserData`` and ``CustomData`` are provided behavior is undefined on
4eb3b8
 which will be selected.
4eb3b8
 
4eb3b8
-In the example below, user-data provided is 'this is my userdata', and the
4eb3b8
-datasource config provided is ``{"agent_command": ["start", "walinuxagent"]}``.
4eb3b8
-That agent command will take affect as if it were specified in system config.
4eb3b8
+In the example below, user-data provided is 'this is my userdata'
4eb3b8
 
4eb3b8
 Example:
4eb3b8
 
4eb3b8
@@ -184,20 +146,16 @@ The hostname is provided to the instance in the ovf-env.xml file as
4eb3b8
 Whatever value the instance provides in its dhcp request will resolve in the
4eb3b8
 domain returned in the 'search' request.
4eb3b8
 
4eb3b8
-The interesting issue is that a generic image will already have a hostname
4eb3b8
-configured.  The ubuntu cloud images have 'ubuntu' as the hostname of the
4eb3b8
-system, and the initial dhcp request on eth0 is not guaranteed to occur after
4eb3b8
-the datasource code has been run.  So, on first boot, that initial value will
4eb3b8
-be sent in the dhcp request and *that* value will resolve.
4eb3b8
-
4eb3b8
-In order to make the ``HostName`` provided in the ovf-env.xml resolve, a
4eb3b8
-dhcp request must be made with the new value.  Walinuxagent (in its current
4eb3b8
-version) handles this by polling the state of hostname and bouncing ('``ifdown
4eb3b8
-eth0; ifup eth0``' the network interface if it sees that a change has been
4eb3b8
-made.
4eb3b8
+A generic image will already have a hostname configured.  The ubuntu
4eb3b8
+cloud images have 'ubuntu' as the hostname of the system, and the
4eb3b8
+initial dhcp request on eth0 is not guaranteed to occur after the
4eb3b8
+datasource code has been run.  So, on first boot, that initial value
4eb3b8
+will be sent in the dhcp request and *that* value will resolve.
4eb3b8
 
4eb3b8
-cloud-init handles this by setting the hostname in the DataSource's 'get_data'
4eb3b8
-method via '``hostname $HostName``', and then bouncing the interface.  This
4eb3b8
+In order to make the ``HostName`` provided in the ovf-env.xml resolve,
4eb3b8
+a dhcp request must be made with the new value. cloud-init handles
4eb3b8
+this by setting the hostname in the DataSource's 'get_data' method via
4eb3b8
+'``hostname $HostName``', and then bouncing the interface.  This
4eb3b8
 behavior can be configured or disabled in the datasource config.  See
4eb3b8
 'Configuration' above.
4eb3b8
 
4eb3b8
diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
4eb3b8
index dedebeb1..320fa857 100644
4eb3b8
--- a/tests/unittests/test_datasource/test_azure.py
4eb3b8
+++ b/tests/unittests/test_datasource/test_azure.py
4eb3b8
@@ -638,17 +638,10 @@ scbus-1 on xpt0 bus 0
4eb3b8
         def dsdevs():
4eb3b8
             return data.get('dsdevs', [])
4eb3b8
 
4eb3b8
-        def _invoke_agent(cmd):
4eb3b8
-            data['agent_invoked'] = cmd
4eb3b8
-
4eb3b8
         def _wait_for_files(flist, _maxwait=None, _naplen=None):
4eb3b8
             data['waited'] = flist
4eb3b8
             return []
4eb3b8
 
4eb3b8
-        def _pubkeys_from_crt_files(flist):
4eb3b8
-            data['pubkey_files'] = flist
4eb3b8
-            return ["pubkey_from: %s" % f for f in flist]
4eb3b8
-
4eb3b8
         if data.get('ovfcontent') is not None:
4eb3b8
             populate_dir(os.path.join(self.paths.seed_dir, "azure"),
4eb3b8
                          {'ovf-env.xml': data['ovfcontent']})
4eb3b8
@@ -675,8 +668,6 @@ scbus-1 on xpt0 bus 0
4eb3b8
 
4eb3b8
         self.apply_patches([
4eb3b8
             (dsaz, 'list_possible_azure_ds_devs', dsdevs),
4eb3b8
-            (dsaz, 'invoke_agent', _invoke_agent),
4eb3b8
-            (dsaz, 'pubkeys_from_crt_files', _pubkeys_from_crt_files),
4eb3b8
             (dsaz, 'perform_hostname_bounce', mock.MagicMock()),
4eb3b8
             (dsaz, 'get_hostname', mock.MagicMock()),
4eb3b8
             (dsaz, 'set_hostname', mock.MagicMock()),
4eb3b8
@@ -765,7 +756,6 @@ scbus-1 on xpt0 bus 0
4eb3b8
             ret = dsrc.get_data()
4eb3b8
             self.m_is_platform_viable.assert_called_with(dsrc.seed_dir)
4eb3b8
             self.assertFalse(ret)
4eb3b8
-            self.assertNotIn('agent_invoked', data)
4eb3b8
             # Assert that for non viable platforms,
4eb3b8
             # there is no communication with the Azure datasource.
4eb3b8
             self.assertEqual(
4eb3b8
@@ -789,7 +779,6 @@ scbus-1 on xpt0 bus 0
4eb3b8
             ret = dsrc.get_data()
4eb3b8
             self.m_is_platform_viable.assert_called_with(dsrc.seed_dir)
4eb3b8
             self.assertFalse(ret)
4eb3b8
-            self.assertNotIn('agent_invoked', data)
4eb3b8
             self.assertEqual(
4eb3b8
                 1,
4eb3b8
                 m_report_failure.call_count)
4eb3b8
@@ -806,7 +795,6 @@ scbus-1 on xpt0 bus 0
4eb3b8
                 1,
4eb3b8
                 m_crawl_metadata.call_count)
4eb3b8
             self.assertFalse(ret)
4eb3b8
-            self.assertNotIn('agent_invoked', data)
4eb3b8
 
4eb3b8
     def test_crawl_metadata_exception_should_report_failure_with_msg(self):
4eb3b8
         data = {}
4eb3b8
@@ -1086,21 +1074,6 @@ scbus-1 on xpt0 bus 0
4eb3b8
         self.assertTrue(os.path.isdir(self.waagent_d))
4eb3b8
         self.assertEqual(stat.S_IMODE(os.stat(self.waagent_d).st_mode), 0o700)
4eb3b8
 
4eb3b8
-    def test_user_cfg_set_agent_command_plain(self):
4eb3b8
-        # set dscfg in via plaintext
4eb3b8
-        # we must have friendly-to-xml formatted plaintext in yaml_cfg
4eb3b8
-        # not all plaintext is expected to work.
4eb3b8
-        yaml_cfg = "{agent_command: my_command}\n"
4eb3b8
-        cfg = yaml.safe_load(yaml_cfg)
4eb3b8
-        odata = {'HostName': "myhost", 'UserName': "myuser",
4eb3b8
-                 'dscfg': {'text': yaml_cfg, 'encoding': 'plain'}}
4eb3b8
-        data = {'ovfcontent': construct_valid_ovf_env(data=odata)}
4eb3b8
-
4eb3b8
-        dsrc = self._get_ds(data)
4eb3b8
-        ret = self._get_and_setup(dsrc)
4eb3b8
-        self.assertTrue(ret)
4eb3b8
-        self.assertEqual(data['agent_invoked'], cfg['agent_command'])
4eb3b8
-
4eb3b8
     @mock.patch('cloudinit.sources.DataSourceAzure.device_driver',
4eb3b8
                 return_value=None)
4eb3b8
     def test_network_config_set_from_imds(self, m_driver):
4eb3b8
@@ -1205,29 +1178,6 @@ scbus-1 on xpt0 bus 0
4eb3b8
         dsrc.get_data()
4eb3b8
         self.assertEqual('eastus2', dsrc.region)
4eb3b8
 
4eb3b8
-    def test_user_cfg_set_agent_command(self):
4eb3b8
-        # set dscfg in via base64 encoded yaml
4eb3b8
-        cfg = {'agent_command': "my_command"}
4eb3b8
-        odata = {'HostName': "myhost", 'UserName': "myuser",
4eb3b8
-                 'dscfg': {'text': b64e(yaml.dump(cfg)),
4eb3b8
-                           'encoding': 'base64'}}
4eb3b8
-        data = {'ovfcontent': construct_valid_ovf_env(data=odata)}
4eb3b8
-
4eb3b8
-        dsrc = self._get_ds(data)
4eb3b8
-        ret = self._get_and_setup(dsrc)
4eb3b8
-        self.assertTrue(ret)
4eb3b8
-        self.assertEqual(data['agent_invoked'], cfg['agent_command'])
4eb3b8
-
4eb3b8
-    def test_sys_cfg_set_agent_command(self):
4eb3b8
-        sys_cfg = {'datasource': {'Azure': {'agent_command': '_COMMAND'}}}
4eb3b8
-        data = {'ovfcontent': construct_valid_ovf_env(data={}),
4eb3b8
-                'sys_cfg': sys_cfg}
4eb3b8
-
4eb3b8
-        dsrc = self._get_ds(data)
4eb3b8
-        ret = self._get_and_setup(dsrc)
4eb3b8
-        self.assertTrue(ret)
4eb3b8
-        self.assertEqual(data['agent_invoked'], '_COMMAND')
4eb3b8
-
4eb3b8
     def test_sys_cfg_set_never_destroy_ntfs(self):
4eb3b8
         sys_cfg = {'datasource': {'Azure': {
4eb3b8
             'never_destroy_ntfs': 'user-supplied-value'}}}
4eb3b8
@@ -1311,51 +1261,6 @@ scbus-1 on xpt0 bus 0
4eb3b8
         self.assertTrue(ret)
4eb3b8
         self.assertEqual(dsrc.userdata_raw, mydata.encode('utf-8'))
4eb3b8
 
4eb3b8
-    def test_cfg_has_pubkeys_fingerprint(self):
4eb3b8
-        odata = {'HostName': "myhost", 'UserName': "myuser"}
4eb3b8
-        mypklist = [{'fingerprint': 'fp1', 'path': 'path1', 'value': ''}]
4eb3b8
-        pubkeys = [(x['fingerprint'], x['path'], x['value']) for x in mypklist]
4eb3b8
-        data = {'ovfcontent': construct_valid_ovf_env(data=odata,
4eb3b8
-                                                      pubkeys=pubkeys)}
4eb3b8
-
4eb3b8
-        dsrc = self._get_ds(data, agent_command=['not', '__builtin__'])
4eb3b8
-        ret = self._get_and_setup(dsrc)
4eb3b8
-        self.assertTrue(ret)
4eb3b8
-        for mypk in mypklist:
4eb3b8
-            self.assertIn(mypk, dsrc.cfg['_pubkeys'])
4eb3b8
-            self.assertIn('pubkey_from', dsrc.metadata['public-keys'][-1])
4eb3b8
-
4eb3b8
-    def test_cfg_has_pubkeys_value(self):
4eb3b8
-        # make sure that provided key is used over fingerprint
4eb3b8
-        odata = {'HostName': "myhost", 'UserName': "myuser"}
4eb3b8
-        mypklist = [{'fingerprint': 'fp1', 'path': 'path1', 'value': 'value1'}]
4eb3b8
-        pubkeys = [(x['fingerprint'], x['path'], x['value']) for x in mypklist]
4eb3b8
-        data = {'ovfcontent': construct_valid_ovf_env(data=odata,
4eb3b8
-                                                      pubkeys=pubkeys)}
4eb3b8
-
4eb3b8
-        dsrc = self._get_ds(data, agent_command=['not', '__builtin__'])
4eb3b8
-        ret = self._get_and_setup(dsrc)
4eb3b8
-        self.assertTrue(ret)
4eb3b8
-
4eb3b8
-        for mypk in mypklist:
4eb3b8
-            self.assertIn(mypk, dsrc.cfg['_pubkeys'])
4eb3b8
-            self.assertIn(mypk['value'], dsrc.metadata['public-keys'])
4eb3b8
-
4eb3b8
-    def test_cfg_has_no_fingerprint_has_value(self):
4eb3b8
-        # test value is used when fingerprint not provided
4eb3b8
-        odata = {'HostName': "myhost", 'UserName': "myuser"}
4eb3b8
-        mypklist = [{'fingerprint': None, 'path': 'path1', 'value': 'value1'}]
4eb3b8
-        pubkeys = [(x['fingerprint'], x['path'], x['value']) for x in mypklist]
4eb3b8
-        data = {'ovfcontent': construct_valid_ovf_env(data=odata,
4eb3b8
-                                                      pubkeys=pubkeys)}
4eb3b8
-
4eb3b8
-        dsrc = self._get_ds(data, agent_command=['not', '__builtin__'])
4eb3b8
-        ret = self._get_and_setup(dsrc)
4eb3b8
-        self.assertTrue(ret)
4eb3b8
-
4eb3b8
-        for mypk in mypklist:
4eb3b8
-            self.assertIn(mypk['value'], dsrc.metadata['public-keys'])
4eb3b8
-
4eb3b8
     def test_default_ephemeral_configs_ephemeral_exists(self):
4eb3b8
         # make sure the ephemeral configs are correct if disk present
4eb3b8
         odata = {}
4eb3b8
@@ -1919,8 +1824,6 @@ class TestAzureBounce(CiTestCase):
4eb3b8
     with_logs = True
4eb3b8
 
4eb3b8
     def mock_out_azure_moving_parts(self):
4eb3b8
-        self.patches.enter_context(
4eb3b8
-            mock.patch.object(dsaz, 'invoke_agent'))
4eb3b8
         self.patches.enter_context(
4eb3b8
             mock.patch.object(dsaz.util, 'wait_for_files'))
4eb3b8
         self.patches.enter_context(
4eb3b8
-- 
4eb3b8
2.27.0
4eb3b8