All pastes #3784776 Raw Edit

Unknown provider Error

public unlisted text v1 · immutable
#3784776 ·published 2017-03-23 08:29 UTC
rendered paste body
I've defined a module with no dependencies:

<code>
gbpAPI.module.js:

  (function () {
    'use strict';

    angular
        .module('horizon.dashboard.dugdashboard.duginstancepanel.gbpAPI', []);

  }());
</code>

I've also defined a service on that module:

<code>
(function () {
    'use strict';

    angular
        .module('horizon.dashboard.dugdashboard.duginstancepanel.gbpAPI')
        .factory('horizon.dashboard.dugdashboard.duginstancepanel.gbpAPI.service',
                 gbpAPIService);

    gbpAPIService.$inject = [
      'horizon.framework.util.http.service',
      'horizon.framework.widgets.toast.service'
    ];

  /**
   * @ngdoc service
   * @name horizon.dashboard.dugdashboard.duginstancepanel.gbpAPI.service
   * @description Provides access to GBP APIs.
   */
  function gbpAPIService(apiService, toastService) {
    var service = {
      getPolicyTargets: getPolicyTargets
/*      createNetwork: createNetwork,
      getSubnets: getSubnets,
      createSubnet: createSubnet,
      getPorts: getPorts,
      getAgents: getAgents,
      getExtensions: getExtensions */
    };

    return service;
    // Group Based Policies.

    /**
     * @name horizon.dashboard.dugdashboard.duginstancepanel.gbpAPI.service.getPolicyTargets
     * @description
     * Get a list of ACI Group based Policy Targets.
     *
     * The listing result is an object with property "items". Each item is
     * a Policy Target.
     */
    function getPolicyTargets() {
        // Since I don't know how to talk to GBP, I'll just try using
        // neutron for now.
        console.log("DUG: Surely this didn't work!");
      return apiService.get('/api/neutron/networks/')
        .error(function () {
          toastService.add('error', gettext('Unable to retrieve the networks.'));
        });
    }
  }

}());
</code>

And finally, I've tried to add them to the launch-instance-model.service.js:

  1) I inject the additional dependency on my service:

  <code>
  ... lines omitted ...
  launchInstanceModel.$inject = [
    '$q',
    '$log',
    'horizon.app.core.openstack-service-api.cinder',
    'horizon.app.core.openstack-service-api.glance',
    'horizon.app.core.openstack-service-api.neutron',
    'horizon.app.core.openstack-service-api.nova',
    'horizon.app.core.openstack-service-api.novaExtensions',
    'horizon.app.core.openstack-service-api.security-group',
    'horizon.app.core.openstack-service-api.serviceCatalog',
    'horizon.app.core.openstack-service-api.settings',
    'horizon.framework.widgets.toast.service',
    'horizon.dashboard.dugdashboard.duginstancepanel.gbpAPI.service'
  ];
  </code>

  2) I add my service as a parameter to the launchInstanceModel method:

  <code>
  function launchInstanceModel(
    $q,
    $log,
    cinderAPI,
    glanceAPI,
    neutronAPI,
    novaAPI,
    novaExtensions,
    securityGroup,
    serviceCatalog,
    settings,
    toast,
    gbpAPI // FIXME DUG - sort this out!
  ) {

    var initPromise;
    ... lines omitted ...
  </code>

And finally I was going to make it call my service in the getNetworks method but I've left my code commented out as I get the dreaded Unknown Provider error:

  <code>
    function getNetworks() {
        return neutronAPI.getNetworks().then(onGetNetworks, noop).then(getPorts, noop);
        // DUG FIXME, make me work: return gbpAPIService.getPolicyTargets().then(onGetNetworks, noop).then(getPorts, noop);
        //return gbpAPIService.getPolicyTargets().then(onGetNetworks, noop).then(getPorts, noop);
    }
  </code>

Here's the error:

  Unknown provider: horizon.dashboard.dugdashboard.duginstancepanel.gbpAPI.gbpAPIServiceProvider <- horizon.dashboard.dugdashboard.duginstancepanel.gbpAPI.gbpAPIService <- launchInstanceModel

I'm completely stumped! Can anyone help!!!

Doug