def get( self, volume_name_or_id_str ): # get the gateway, but we'll check for ourselves whether or not the gateway needs authentication gateway, volume, timing = response_begin( self, volume_name_or_id_str, fail_if_no_auth_header=False ) if volume == None: return if volume.need_gateway_auth() and gateway == None: response_user_error( self, 403 ) return root = storage.get_volume_root( volume ) if root == None: response_user_error( self, 404 ) return # request for volume metadata volume_metadata = ms_pb2.ms_volume_metadata(); root.protobuf( volume_metadata.root ) volume.protobuf( volume_metadata ) data = volume_metadata.SerializeToString() response_end( self, 200, data, "application/octet-stream", timing ) return
def update_volume( volume_name_or_id, **attrs ): """ Update a volume. Expect 'volume_cert_b64' as a keyword argument, which contains the serialized ms_volume_metadata cert with the new information. Expect 'cert_bundle_b64' as a keyword argument, which contains the serialized Manifest with the new cert version vector. Return True on success Raise an Exception on error. """ volume_cert_b64 = attrs.get('volume_cert_b64', None) if volume_cert_b64 is None: raise Exception("Missing 'volume_cert_b64'") cert_bundle_b64 = attrs.get('cert_bundle_b64', None) if cert_bundle_b64 is None: raise Exception("Missing 'cert_bundle_b64'") volume_cert_bin = base64.b64decode( volume_cert_b64 ) cert_bundle_bin = base64.b64decode( cert_bundle_b64 ) try: volume_cert = ms_pb2.ms_volume_metadata() volume_cert.ParseFromString( volume_cert_bin ) except Exception, e: log.error("Failed to deserialize volume certificate") raise e
def create_volume( **attrs ): """ Create a volume. * extract the parameters from the volume cert, given as 'volume_cert_b64' in **attrs * verify that the user-to-receive signed the cert * extract the volume cert bundle manifest ('cert_bundle_b64' in attrs), and verify that it is signed by the same user. * generate and store the volume from the certificate, keeping the cert on file. * put the cert bundle manifest. Return the Volume on success. Raise an exception on error. """ from common.api import verify_data volume_cert_b64 = attrs.get('volume_cert_b64', None) if volume_cert_b64 is None: raise Exception("Missing 'volume_cert_b64'") cert_bundle_b64 = attrs.get('cert_bundle_b64', None) if cert_bundle_b64 is None: raise Exception("Missing 'cert_bundle_b64'") try: volume_cert_bin = base64.b64decode( volume_cert_b64 ) volume_cert = ms_pb2.ms_volume_metadata() volume_cert.ParseFromString( volume_cert_bin ) except Exception, e: log.error("Failed to deserialize volume certificate") raise e
def update_volume(volume_name_or_id, **attrs): """ Update a volume. Expect 'volume_cert_b64' as a keyword argument, which contains the serialized ms_volume_metadata cert with the new information. Expect 'cert_bundle_b64' as a keyword argument, which contains the serialized Manifest with the new cert version vector. Return True on success Raise an Exception on error. """ volume_cert_b64 = attrs.get('volume_cert_b64', None) if volume_cert_b64 is None: raise Exception("Missing 'volume_cert_b64'") cert_bundle_b64 = attrs.get('cert_bundle_b64', None) if cert_bundle_b64 is None: raise Exception("Missing 'cert_bundle_b64'") volume_cert_bin = base64.b64decode(volume_cert_b64) cert_bundle_bin = base64.b64decode(cert_bundle_b64) try: volume_cert = ms_pb2.ms_volume_metadata() volume_cert.ParseFromString(volume_cert_bin) except Exception, e: log.error("Failed to deserialize volume certificate") raise e
def create_volume(**attrs): """ Create a volume. * extract the parameters from the volume cert, given as 'volume_cert_b64' in **attrs * verify that the user-to-receive signed the cert * extract the volume cert bundle manifest ('cert_bundle_b64' in attrs), and verify that it is signed by the same user. * generate and store the volume from the certificate, keeping the cert on file. * put the cert bundle manifest. Return the Volume on success. Raise an exception on error. """ from common.api import verify_data volume_cert_b64 = attrs.get('volume_cert_b64', None) if volume_cert_b64 is None: raise Exception("Missing 'volume_cert_b64'") cert_bundle_b64 = attrs.get('cert_bundle_b64', None) if cert_bundle_b64 is None: raise Exception("Missing 'cert_bundle_b64'") try: volume_cert_bin = base64.b64decode(volume_cert_b64) volume_cert = ms_pb2.ms_volume_metadata() volume_cert.ParseFromString(volume_cert_bin) except Exception, e: log.error("Failed to deserialize volume certificate") raise e
def get(self, volume_name_or_id_str): # get the gateway, but we'll check for ourselves whether or not the gateway needs authentication gateway, volume, timing = response_begin(self, volume_name_or_id_str, fail_if_no_auth_header=False) if volume == None: return if volume.need_gateway_auth() and gateway == None: response_user_error(self, 403) return root = storage.get_volume_root(volume) if root == None: response_user_error(self, 404) return # request for volume metadata volume_metadata = ms_pb2.ms_volume_metadata() root.protobuf(volume_metadata.root) volume.protobuf(volume_metadata) data = volume_metadata.SerializeToString() response_end(self, 200, data, "application/octet-stream", timing) return