Boto3不会将快照复制到其他区域,其他选项?(Boto3 not copying snapshot to other regions, other options?)
[对AWS很新]
嗨,
我正在尝试将EBS卷快照拷贝跨区域移动。 我一直在尝试使用Boto3来移动快照。 我的目标是每天自动将最新快照从
us-east-2
区域移动到us-east-1
区域。我在终端中使用了
aws configure
命令来设置我的安全凭证并将区域设置为us-east-2
。我使用熊猫来获取使用此代码的最新快照ID:
import boto3 import pandas as pd from pandas.io.json.normalize import nested_to_record import boto.ec2 client = boto3.client('ec2') aws_api_response = client.describe_snapshots(OwnerIds=['self']) flat = nested_to_record(aws_api_response) df = pd.DataFrame.from_dict(flat) df= df['Snapshots'].apply(pd.Series) insert_snap = df.loc[df['StartTime'] == max(df['StartTime']),'SnapshotId'] insert_snap = insert_snap.reset_index(drop=True)
insert_snap
返回一个类似snap-1234ABCD
的快照标识我尝试使用此代码将快照从
us-east-2
到us-east-1
:client.copy_snapshot(SourceSnapshotId='%s' %insert_snap[0], SourceRegion='us-east-2', DestinationRegion='us-east-1', Description='This is my copied snapshot.')
快照正在使用上述行复制到同一区域。
我也尝试通过终端中的
aws configure
命令切换区域,在同一区域中复制快照时发生同样的问题。Boto3中存在一个跳过
copy_snapshot()
代码中的目标参数的copy_snapshot()
。 在这里找到的信息: https : //github.com/boto/boto3/issues/886我曾尝试将此代码插入到lambda管理器中,但不断收到错误
"errorMessage": "Unable to import module 'lambda_function'"
:region = 'us-east-2' ec = boto3.client('ec2',region_name=region) def lambda_handler(event, context): response=ec.copy_snapshot(SourceSnapshotId='snap-xxx', SourceRegion=region, DestinationRegion='us-east-1', Description='copied from Ohio') print (response)
我没有选择,我可以做些什么来自动化aws中的快照传输?
[Very new to AWS]
Hi,
I am trying to move my EBS volume snapshot copies across regions. I have been trying to use Boto3 to move the snapshots. My objective is to move the latest snapshot from
us-east-2
region tous-east-1
region automatically on a daily basis.I have used
aws configure
command in terminal to setup my security credentials and set region tous-east-2
.I am using pandas to acquire the most recent snapshot-id using this code:
import boto3 import pandas as pd from pandas.io.json.normalize import nested_to_record import boto.ec2 client = boto3.client('ec2') aws_api_response = client.describe_snapshots(OwnerIds=['self']) flat = nested_to_record(aws_api_response) df = pd.DataFrame.from_dict(flat) df= df['Snapshots'].apply(pd.Series) insert_snap = df.loc[df['StartTime'] == max(df['StartTime']),'SnapshotId'] insert_snap = insert_snap.reset_index(drop=True)
insert_snap
returns a snapshot id something likesnap-1234ABCD
I am try to use this code to move the snap shot from
us-east-2
to us-east-1
:client.copy_snapshot(SourceSnapshotId='%s' %insert_snap[0], SourceRegion='us-east-2', DestinationRegion='us-east-1', Description='This is my copied snapshot.')
The snapshot is copying in the same region using the above line.
I have also tried switching regions through
aws configure
command in terminal, with the same issue occurring where snapshot is being copied in the same region.There is a bug in Boto3 that is skipping the destination parameter in the
copy_snapshot()
code. Information found here: https://github.com/boto/boto3/issues/886I have tried inserting this code with into the lambda manager but keep getting error
"errorMessage": "Unable to import module 'lambda_function'"
:region = 'us-east-2' ec = boto3.client('ec2',region_name=region) def lambda_handler(event, context): response=ec.copy_snapshot(SourceSnapshotId='snap-xxx', SourceRegion=region, DestinationRegion='us-east-1', Description='copied from Ohio') print (response)
I am out of options, what I can do to automate the transfer of snapshots in aws?
原文:https://stackoverflow.com/questions/50414179
最满意答案
您可以尝试使用Volley或类似的库来完成任务。 使用它比使用旧方法简单得多。 您通常需要重新编写Web服务调用,但我可以保证它不会像您已经完成的那样困难! 这是关于如何使用Volley的教程。 开始使用非常简单。
以下是他们网站上有关如何使用Volley的简单示例。 https://developer.android.com/training/volley/requestqueue.html
RequestQueue mRequestQueue; // Instantiate the cache Cache cache = new DiskBasedCache(getCacheDir(), 1024 * 1024); // 1MB cap // Set up the network to use HttpURLConnection as the HTTP client. Network network = new BasicNetwork(new HurlStack()); // Instantiate the RequestQueue with the cache and network. mRequestQueue = new RequestQueue(cache, network); // Start the queue mRequestQueue.start(); String url ="http://www.example.com"; // Formulate the request and handle the response. StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() { @Override public void onResponse(String response) { // Do something with the response } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // Handle error } }); // Add the request to the RequestQueue. mRequestQueue.add(stringRequest);
you can try using Volley or similar libraries to get your task done. It's much simpler to use than the old approach. You'll mostly need to re-write the web service calls, but I can guarantee that it won't be as difficult as what you've already done! Here's a tutorial on how to use Volley. It's very easy to get started with.
Following is a simple example as given on their website on how to use Volley. https://developer.android.com/training/volley/requestqueue.html
RequestQueue mRequestQueue; // Instantiate the cache Cache cache = new DiskBasedCache(getCacheDir(), 1024 * 1024); // 1MB cap // Set up the network to use HttpURLConnection as the HTTP client. Network network = new BasicNetwork(new HurlStack()); // Instantiate the RequestQueue with the cache and network. mRequestQueue = new RequestQueue(cache, network); // Start the queue mRequestQueue.start(); String url ="http://www.example.com"; // Formulate the request and handle the response. StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() { @Override public void onResponse(String response) { // Do something with the response } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // Handle error } }); // Add the request to the RequestQueue. mRequestQueue.add(stringRequest);
相关问答
更多-
总体思路是读入POST值,将其解析为XML,对其做出业务决策,根据您决定的API构建XML响应,并将其写入响应中。 读取POST值: $dataPOST = trim(file_get_contents('php://input')); 以XML解析: $xmlData = simplexml_load_string($dataPOST); 然后,您将创建一个XML字符串(或者文档树,如果您愿意的话),并将其输出到响应中。 print()或echo()会很好。 The general idea is t ...
-
在非常大的数据集中,XML会稍微重一些,因为它需要打开和关闭标记。 还有一个问题是标签之间的数据有多大。 如果在开始和结束标记之间有大量数据,那么这会“软化”效果。 如果您没有处理大量数据,那么我只会使用对客户端和服务器都有更好的本机库支持。 对于中小型数据集,我认为差异不会很明显。 In very large data sets XML will be slightly heavier because it needs opening and closing tags. There is also the ...
-
Android:xml还是json?(Android: xml or json?)[2023-04-09]
那么我会推荐JSON的原因不容易使用,但网络带宽。 与XML相比,JSON消息的大小更小。 所以考虑这也是为了选择一个。 其次,您可以使用Gson另一个lib来简化您的实现,与Android平台附带的org.json实现相比,这更易于使用。 Well the reason i ll recommend JSON not easy of use but the network bandwidth. JSON msgs are smaller in size as compared to XML. So con ... -
(Rails app Api)通过HTTP发送数据并接收JSON或XML((Rails app Api) Send data via HTTP and receive JSON or XML)[2022-03-11]
您必须使用套接字,以便客户端获取http请求,您在套接字上接收它,计算它并将结果发回给他。 url属性解析器的文档: http : //www.ruby-doc.org/stdlib-2.0/libdoc/cgi/rdoc/CGI.html#M000075 这可能有助于编辑: require 'cgi' CGI::parse('param1=value1¶m2=value2¶m3=value3') returns you sth like that: {"param1"=>["val ... -
您可以尝试使用Volley或类似的库来完成任务。 使用它比使用旧方法简单得多。 您通常需要重新编写Web服务调用,但我可以保证它不会像您已经完成的那样困难! 这是关于如何使用Volley的教程。 开始使用非常简单。 以下是他们网站上有关如何使用Volley的简单示例。 https://developer.android.com/training/volley/requestqueue.html RequestQueue mRequestQueue; // Instantiate the cache Cac ...
-
您的sinatra应用程序与http:// localhost:4567 / solve URL不匹配,所以它会从您的服务器返回404。 您需要通过示例更改您的sinatra应用程序: require "rubygems" require "sinatra" post '/solve/?' do jdata = params[:data] for_json = JSON.parse(jdata) end 您的RestClient请求也有问题。 您需要定义jdata的参数名称。 respons ...
-
我的下一个想法解决我的问题。 看起来,JSON消息应该包含一个标签“alert”,其中需要显示为通知的文本的值。 如果没有指定“alert”标签,则不显示通知。 所以我的{"x":"1"}不会显示出来,但是 { "x": "1", "alert": "show me to the user" } 正常显示。 不幸的是,我没有在解析用户指南的任何地方找到它,所以请将解析器添加到指南中让其他开发人员不浪费时间。 谢谢 My next idea solved my problem. It seems that ...
-
执行此操作的正确方法是使用SmsManager类中的sendDataMessage。 这是一个小代码(SMSSender): SmsManager smsMgr = SmsManager.getDefault(); smsMgr.sendDataMessage(phoneNumber, null, (short) myApplicationPort, messageString.getBytes(), sentIntent, deliveryIntent); 这是另一个小代码(SM ...
-
路径参数( @PathParam )是从传入的请求URL中提取的。 因此,例如,使用URL http://192.168.1.59/FareShareREST/api/rides/joinRide/5和以下代码: @POST @Consumes(MediaType.APPLICATION_JSON) @Path("/joinRide/{rideid}") public Response joinRide(@PathParam("rideid") long rideid) { System.out.p ...
-
涉及2个组件,收到短信和解析数据时的逻辑,以及将数据发送到Web应用程序的逻辑。 要在收到SMS时获得工作“挂钩”,您需要构建一个具有SMS_RECEIVED意图的广播接收器。 在您的应用程序中,创建一个名为MySMSReceiver的新BroadcastReceiver ,并将Receiver添加到清单中:
相关文章
更多- Hadoop 2.1.0 beta 发布,HDFS提供SnapShot模块
- Hadoop编译WordCount程序:class file for org.apache.commons.cli.Options no
- 将某个条目复制到其他分组的方案
- Hadoop 本地文件复制到hdfs目录
- 实战: SOLR的分布式部署(复制)CollectionDistribute 快照分发 (一)
- 如何把复选框中的值传到form里?
- secureCRT使用VIM 像LINUX中那样对语法高亮
- Shell命令格式
- 实战: SOLR的分布式部署(复制)CollectionDistribute 快照分发 (精简版)
- Hadoop命令手册
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)