Ejemplo n.º 1
0
    def _ask_child_zone_to_create_instance(self, context, weighted_host,
                                           request_spec, kwargs):
        """Once we have determined that the request should go to one
        of our children, we need to fabricate a new POST /servers/
        call with the same parameters that were passed into us.
        This request is always for a single instance.

        Note that we have to reverse engineer from our args to get back the
        image, flavor, ipgroup, etc. since the original call could have
        come in from EC2 (which doesn't use these things).
        """
        instance_type = request_spec['instance_type']
        instance_properties = request_spec['instance_properties']

        name = instance_properties['display_name']
        image_ref = instance_properties['image_ref']
        meta = instance_properties['metadata']
        flavor_id = instance_type['flavorid']
        reservation_id = instance_properties['reservation_id']
        files = kwargs['injected_files']

        zone = db.zone_get(context.elevated(), weighted_host.zone)
        zone_name = zone.name
        url = zone.api_url
        LOG.debug(
            _("Forwarding instance create call to zone '%(zone_name)s'. "
              "ReservationID=%(reservation_id)s") % locals())
        engine = None
        try:
            # This operation is done as the caller, not the zone admin.
            engine = engineclient.Client(zone.username,
                                         zone.password,
                                         None,
                                         url,
                                         token=context.auth_token,
                                         region_name=zone_name)
            engine.authenticate()
        except engineclient_exceptions.BadRequest, e:
            raise exception.NotAuthorized(
                _("Bad credentials attempting "
                  "to talk to zone at %(url)s.") % locals())
    def _ask_child_zone_to_create_instance(self, context, weighted_host,
            request_spec, kwargs):
        """Once we have determined that the request should go to one
        of our children, we need to fabricate a new POST /servers/
        call with the same parameters that were passed into us.
        This request is always for a single instance.

        Note that we have to reverse engineer from our args to get back the
        image, flavor, ipgroup, etc. since the original call could have
        come in from EC2 (which doesn't use these things).
        """
        instance_type = request_spec['instance_type']
        instance_properties = request_spec['instance_properties']

        name = instance_properties['display_name']
        image_ref = instance_properties['image_ref']
        meta = instance_properties['metadata']
        flavor_id = instance_type['flavorid']
        reservation_id = instance_properties['reservation_id']
        files = kwargs['injected_files']

        zone = db.zone_get(context.elevated(), weighted_host.zone)
        zone_name = zone.name
        url = zone.api_url
        LOG.debug(_("Forwarding instance create call to zone '%(zone_name)s'. "
                "ReservationID=%(reservation_id)s") % locals())
        engine = None
        try:
            # This operation is done as the caller, not the zone admin.
            engine = engineclient.Client(zone.username, zone.password, None, url,
                                     token=context.auth_token,
                                     region_name=zone_name)
            engine.authenticate()
        except engineclient_exceptions.BadRequest, e:
            raise exception.NotAuthorized(_("Bad credentials attempting "
                    "to talk to zone at %(url)s.") % locals())
Ejemplo n.º 3
0
def zone_get(context, zone_id):
    return db.zone_get(context, zone_id)
Ejemplo n.º 4
0
def zone_get(context, zone_id):
    return db.zone_get(context, zone_id)