コード例 #1
0
 def setUp(self):
     self.context = context.get_admin_context()
     shr = {}
     shr['host'] = 'fake_host'
     shr['availability_zone'] = CONF.storage_availability_zone
     shr['status'] = "available"
     share = db.share_create(self.context, shr)
     acs = {}
     acs['access_type'] = "ip"
     acs['access_to'] = "123.123.123.123"
     acs['share_id'] = share['id']
     access = db.share_access_create(self.context, acs)
     snap = {}
     snap['share_id'] = share['id']
     snapshot = db.share_snapshot_create(self.context, snap)
     self.fake_share = jsonutils.to_primitive(share)
     self.fake_access = jsonutils.to_primitive(access)
     self.fake_snapshot = jsonutils.to_primitive(snapshot)
     super(ShareRpcAPITestCase, self).setUp()
コード例 #2
0
ファイル: api.py プロジェクト: nkrinner/manila
def notify(context, publisher_id, event_type, priority, payload):
    """Sends a notification using the specified driver

    :param publisher_id: the source worker_type.host of the message
    :param event_type:   the literal type of event (ex. Instance Creation)
    :param priority:     patterned after the enumeration of Python logging
                         levels in the set (DEBUG, WARN, INFO, ERROR, CRITICAL)
    :param payload:       A python dictionary of attributes

    Outgoing message format includes the above parameters, and appends the
    following:

    message_id
      a UUID representing the id for this notification

    timestamp
      the GMT timestamp the notification was sent at

    The composite message will be constructed as a dictionary of the above
    attributes, which will then be sent via the transport mechanism defined
    by the driver.

    Message example::

        {'message_id': str(uuid.uuid4()),
         'publisher_id': 'compute.host1',
         'timestamp': timeutils.utcnow(),
         'priority': 'WARN',
         'event_type': 'compute.create_instance',
         'payload': {'instance_id': 12, ... }}

    """
    if priority not in log_levels:
        raise BadPriorityException(_("%s not in valid priorities") % priority)

    # Ensure everything is JSON serializable.
    payload = jsonutils.to_primitive(payload, convert_instances=True)

    msg = dict(
        message_id=str(uuid.uuid4()),
        publisher_id=publisher_id,
        event_type=event_type,
        priority=priority,
        payload=payload,
        timestamp=str(timeutils.utcnow()),
    )

    for driver in _get_drivers():
        try:
            driver.notify(context, msg)
        except Exception as e:
            LOG.exception(
                _LE("Problem '%(e)s' attempting to " "send to notification system. " "Payload=%(payload)s")
                % dict(e=e, payload=payload)
            )
コード例 #3
0
ファイル: rpcapi.py プロジェクト: bobcallaway/manila
 def create_share(self, ctxt, share, host,
                  request_spec, filter_properties,
                  snapshot_id=None):
     cctxt = self.client.prepare(server=host, version='1.0')
     request_spec_p = jsonutils.to_primitive(request_spec)
     cctxt.cast(
         ctxt,
         'create_share',
         share_id=share['id'],
         request_spec=request_spec_p,
         filter_properties=filter_properties,
         snapshot_id=snapshot_id,
     )
コード例 #4
0
ファイル: rpcapi.py プロジェクト: nkrinner/manila
 def create_share(self, ctxt, topic, share_id, snapshot_id=None, request_spec=None, filter_properties=None):
     request_spec_p = jsonutils.to_primitive(request_spec)
     return self.cast(
         ctxt,
         self.make_msg(
             "create_share",
             topic=topic,
             share_id=share_id,
             snapshot_id=snapshot_id,
             request_spec=request_spec_p,
             filter_properties=filter_properties,
         ),
         version="1.3",
     )
コード例 #5
0
 def setUp(self):
     super(ShareRpcAPITestCase, self).setUp()
     self.context = context.get_admin_context()
     shr = {}
     shr['host'] = 'fake_host'
     shr['availability_zone'] = CONF.storage_availability_zone
     shr['status'] = "available"
     share = db.share_create(self.context, shr)
     acs = {}
     acs['access_type'] = "ip"
     acs['access_to'] = "123.123.123.123"
     acs['share_id'] = share['id']
     access = db.share_access_create(self.context, acs)
     snap = {}
     snap['share_id'] = share['id']
     snapshot = db.share_snapshot_create(self.context, snap)
     server = {'id': 'fake_share_server_id', 'host': 'fake_host'}
     share_server = db.share_server_create(self.context, server)
     self.fake_share = jsonutils.to_primitive(share)
     self.fake_access = jsonutils.to_primitive(access)
     self.fake_snapshot = jsonutils.to_primitive(snapshot)
     self.fake_share_server = jsonutils.to_primitive(share_server)
     self.ctxt = context.RequestContext('fake_user', 'fake_project')
     self.rpcapi = share_rpcapi.ShareAPI()
コード例 #6
0
ファイル: test_share_rpcapi.py プロジェクト: mbr4v0v/manila
 def setUp(self):
     super(ShareRpcAPITestCase, self).setUp()
     self.context = context.get_admin_context()
     shr = {}
     shr['host'] = 'fake_host'
     shr['availability_zone'] = CONF.storage_availability_zone
     shr['status'] = "available"
     share = db.share_create(self.context, shr)
     acs = {}
     acs['access_type'] = "ip"
     acs['access_to'] = "123.123.123.123"
     acs['share_id'] = share['id']
     access = db.share_access_create(self.context, acs)
     snap = {}
     snap['share_id'] = share['id']
     snapshot = db.share_snapshot_create(self.context, snap)
     server = {'id': 'fake_share_server_id', 'host': 'fake_host'}
     share_server = db.share_server_create(self.context, server)
     self.fake_share = jsonutils.to_primitive(share)
     self.fake_access = jsonutils.to_primitive(access)
     self.fake_snapshot = jsonutils.to_primitive(snapshot)
     self.fake_share_server = jsonutils.to_primitive(share_server)
     self.ctxt = context.RequestContext('fake_user', 'fake_project')
     self.rpcapi = share_rpcapi.ShareAPI()
コード例 #7
0
 def create_share(self,
                  ctxt,
                  share,
                  host,
                  request_spec,
                  filter_properties,
                  snapshot_id=None):
     cctxt = self.client.prepare(server=host, version='1.0')
     request_spec_p = jsonutils.to_primitive(request_spec)
     cctxt.cast(
         ctxt,
         'create_share',
         share_id=share['id'],
         request_spec=request_spec_p,
         filter_properties=filter_properties,
         snapshot_id=snapshot_id,
     )
コード例 #8
0
 def create_share(self,
                  ctxt,
                  topic,
                  share_id,
                  snapshot_id=None,
                  request_spec=None,
                  filter_properties=None):
     request_spec_p = jsonutils.to_primitive(request_spec)
     cctxt = self.client.prepare(version='1.0')
     return cctxt.cast(
         ctxt,
         'create_share',
         topic=topic,
         share_id=share_id,
         snapshot_id=snapshot_id,
         request_spec=request_spec_p,
         filter_properties=filter_properties,
     )
コード例 #9
0
ファイル: rpc.py プロジェクト: bobcallaway/manila
 def serialize_entity(context, entity):
     return jsonutils.to_primitive(entity, convert_instances=True)
コード例 #10
0
ファイル: rpc.py プロジェクト: poornimakshirsagar/manila
 def serialize_entity(context, entity):
     return jsonutils.to_primitive(entity, convert_instances=True)