-
使用gcc-sdk开发,本地测试通过。决赛阶段一直报 answer exit abnormal Missing output file. 错误。 使用原始版本的gcc-sdk,参考这篇贴子,修改了buff数组内存分配,https://forum.huaweicloud.com/thread-8487-1-1.html 调试后还是存在一些案例跑通,另一些案例报此错误。 可否请专家修复一些sdk中的这个问题?调试的心累。
-
本帖最后由 jakps 于 2018-4-10 23:45 编辑#### ANSWER BUILD INFO#### {"build_failed": "Build answer failed: found no main file, build should be failed!"} 这部分内容sdk有的shell script不会输出,求解失败原因。 ... (deflated 41%) build jar success! #### ANSWER BUILD INFO#### {"build_failed": "Build answer failed: found no main file, build should be failed!"} WARNING: Your kernel does not support swap limit capabilities, memory limited without swap. 把云端git版本退回到初始版本就正常了,
-
帮助中心 > OBS_JAVA_SDK > 开发指南 > 相关资源 > 示例工程 huawei-obs-java-sdk-demo.zip 无法添加的啊?
-
本帖最后由 Mercy 于 2018-3-27 10:33 编辑[code]import java.util.List; import java.util.stream.Collectors; import sun.misc.BASE64Encoder; import sun.misc.BASE64Decoder; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; import com.huawei.openstack4j.api.Builders; import com.huawei.openstack4j.api.OSClient.OSClientV3; import com.huawei.openstack4j.api.types.ServiceType; import com.huawei.openstack4j.core.transport.Config; import com.huawei.openstack4j.model.common.ActionResponse; import com.huawei.openstack4j.model.common.Identifier; import com.huawei.openstack4j.openstack.OSFactory; import com.huawei.openstack4j.openstack.identity.internal.OverridableEndpointURLResolver; import com.huawei.openstack4j.model.compute.Action; import com.huawei.openstack4j.model.compute.RebootType; import com.huawei.openstack4j.model.compute.Server; import com.huawei.openstack4j.model.compute.Server.Status; import com.huawei.openstack4j.model.compute.ServerCreate; import com.huawei.openstack4j.model.network.AttachInte**ceType; import com.huawei.openstack4j.model.network.Network; import com.huawei.openstack4j.model.network.Subnet; import com.huawei.openstack4j.model.network.Router; import com.huawei.openstack4j.model.network.RouterInte**ce; public class Demo_for_VPC { private static final String LANGUAGE = "zh-cn"; public static void main(String[] args) { // 第一步:填入华为云区域的endpoint,如下,对接华北区1就需要填入华北区服务的endpoint OverridableEndpointURLResolver endpointResolver = new OverridableEndpointURLResolver(); endpointResolver.addOverrideEndpoint(ServiceType.VOLUME_BACKUP, "https://vbs.cn-north-1.myhuaweicloud.com/v2/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.DNS, "https://dns.myhuaweicloud.com/v2"); endpointResolver.addOverrideEndpoint(ServiceType.AUTO_SCALING, "https://as.cn-north-1.myhuaweicloud.com/autoscaling-api/v1/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.CLOUD_EYE, "https://ces.cn-north-1.myhuaweicloud.com/V1.0/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.LOAD_BALANCER, "https://elb.cn-north-1.myhuaweicloud.com/v1.0/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.MAP_REDUCE, "https://mrs.cn-north-1.myhuaweicloud.com/v1.1/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.KEY_MANAGEMENT, "https://kms.cn-north-1.myhuaweicloud.com/v1.0/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.CLOUD_TRACE, "https://cts.cn-north-1.myhuaweicloud.com/v1.0/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.ANTI_DDOS, "https://antiddos.cn-north-1.myhuaweicloud.com/v1/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.Notification, "https://smn.cn-north-1.myhuaweicloud.com/v2/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.MessageQueue, "https://dms.cn-north-1.myhuaweicloud.com/v1.0/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.MAAS, "https://maas.cn-north-1.myhuaweicloud.com/v1/%(project_id)s/objectstorage"); endpointResolver.addOverrideEndpoint(ServiceType.DATABASE, "https://rds.cn-north-1.myhuaweicloud.com"); /* 第二步: 配置鉴权信息(以对接华北区为例) * user为用户名 * projectId为华为云控制台-账户中心-基本信息-管理我的凭证-项目列表中华北区的项目ID * userDomainId为华为云控制台-账户中心-基本信息-管理我的凭证的账户ID * authURL为IAM服务华北区的域名 */ String user = "wanglianmin-guest"; String password = "XXXXXX"; String projectId = "74610f3a5ad941998e91f076297ecf27"; String userDomainId = "2aa29cbca17a4822abd096610e378ffa"; String authUrl = "https://iam.cn-north-1.myhuaweicloud.com/v3"; // 第三步: 初始化一个连接 OSFactory.enableHttpLoggingFilter(true); //调试用,可以显示request body和response body Config config = Config.newConfig().withEndpointURLResolver(endpointResolver).withLanguage(LANGUAGE) .withSSLVerificationDisabled(); OSClientV3 osclient = OSFactory.builderV3().withConfig(config).endpoint(authUrl) .credentials(user, password, Identifier.byId(userDomainId)).scopeToDomain(Identifier.byId(userDomainId)) .scopeToProject(Identifier.byId(projectId)).authenticate(); //创建router Router router = osclient.networking().router().create(Builders.router() .name("javaSDK-router-test") .build()); // 创建network,DNSNameServer参数请在官网页面创建subnet后获取默认值,各个region(比如华北区、华东区)不一样 Network network = osclient.networking().network() .create(Builders.network().name("javaSDK-net-test") .adminStateUp(true).build()) ; Subnet subnet = osclient.networking().subnet() .create(Builders.subnet().name("javaSDK-subnet-test") .networkId(network.getId()).cidr("192.168.45.0/24") .gateway("192.168.45.1").addDNSNameServer("100.125.1.250") .addDNSNameServer("114.114.114.114").enableDHCP(true).build()) ; System.out.println(subnet); // 将子网添加到router上 RouterInte**ce routerinf = osclient.networking().router() .attachInte**ce(router.getId(), AttachInte**ceType.SUBNET, subnet.getId()); // 删除上面所有资源 osclient.networking().router().detachInte**ce(router.getId(), subnet.getId(),routerinf.getPortId()); osclient.networking().subnet().delete(subnet.getId()); osclient.networking().network().delete(network.getId()); osclient.networking().router().delete(router.getId()); } } [/code]
-
本帖最后由 Mercy 于 2018-3-27 10:29 编辑下面是Java SDK中批量操作云服务器的示例 [code]import java.util.List; import java.util.stream.Collectors; import sun.misc.BASE64Encoder; import sun.misc.BASE64Decoder; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; import com.huawei.openstack4j.api.Builders; import com.huawei.openstack4j.api.OSClient.OSClientV3; import com.huawei.openstack4j.api.types.ServiceType; import com.huawei.openstack4j.core.transport.Config; import com.huawei.openstack4j.model.common.ActionResponse; import com.huawei.openstack4j.model.common.Identifier; import com.huawei.openstack4j.openstack.OSFactory; import com.huawei.openstack4j.openstack.identity.internal.OverridableEndpointURLResolver; import com.huawei.openstack4j.model.compute.Action; import com.huawei.openstack4j.model.compute.RebootType; import com.huawei.openstack4j.model.compute.Server; import com.huawei.openstack4j.model.compute.Server.Status; import com.huawei.openstack4j.model.compute.ServerCreate; import com.huawei.openstack4j.model.compute.StopType; import com.huawei.openstack4j.openstack.loadbalance.domain.AsyncJob; public class Demo_for_ECS_batch { private static final String LANGUAGE = "zh-cn"; // 封装查询Job函数,返回失败子任务的ECS列表 public static ArrayList waitforJob(OSClientV3 osclient, String jobId, int TIMES, int interval) throws InterruptedException { for(int i=1;i=TIMES;i++) { Thread.sleep(interval*1000); AsyncJob Job = osclient.loadBalancer().jobs().get(jobId); if(Job.getStatus() == AsyncJob.Status.SUCCESS) { System.out.println("job success after " + i + " tries"); break; }else if(Job.getStatus() == AsyncJob.Status.FAIL){ System.out.println("job failed after " + i + " tries"); break; }else { continue; } } // 获取失败子任务列表 AsyncJob Job = osclient.loadBalancer().jobs().get(jobId); // 获取Job Object sub_jobs_obj = Job.getEntities().get("sub_jobs"); // 获取Job中的子任务列表 @SuppressWarnings("unchecked") List> sub_jobs_list = (List>)sub_jobs_obj; // 将子任务列表从Object转换为List ArrayList failed_serverIds = new ArrayList(); // 初始化失败子任务的server列表 for(Map sub_job : sub_jobs_list ) { Object entities = sub_job.get("entities"); // 获取子任务的entities,里面包含子任务对象 @SuppressWarnings("unchecked") Map entities_map = (Map)entities; if(!"SUCCESS".equals(sub_job.get("status"))) { System.out.println("status of sub job is " + sub_job.get("status")); failed_serverIds.add(entities_map.get("server_id")); // 获取成功失败子任务的虚拟机uuid } } return failed_serverIds; } public static void main(String[] args) throws InterruptedException { // 第一步:填入华为云区域的endpoint,如下,对接华北区1就需要填入华北区服务的endpoint OverridableEndpointURLResolver endpointResolver = new OverridableEndpointURLResolver(); endpointResolver.addOverrideEndpoint(ServiceType.VOLUME_BACKUP, "https://vbs.cn-north-1.myhuaweicloud.com/v2/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.DNS, "https://dns.myhuaweicloud.com/v2"); endpointResolver.addOverrideEndpoint(ServiceType.AUTO_SCALING, "https://as.cn-north-1.myhuaweicloud.com/autoscaling-api/v1/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.CLOUD_EYE, "https://ces.cn-north-1.myhuaweicloud.com/V1.0/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.LOAD_BALANCER, "https://elb.cn-north-1.myhuaweicloud.com/v1.0/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.MAP_REDUCE, "https://mrs.cn-north-1.myhuaweicloud.com/v1.1/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.KEY_MANAGEMENT, "https://kms.cn-north-1.myhuaweicloud.com/v1.0/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.CLOUD_TRACE, "https://cts.cn-north-1.myhuaweicloud.com/v1.0/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.ANTI_DDOS, "https://antiddos.cn-north-1.myhuaweicloud.com/v1/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.Notification, "https://smn.cn-north-1.myhuaweicloud.com/v2/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.MessageQueue, "https://dms.cn-north-1.myhuaweicloud.com/v1.0/%(project_id)s"); endpointResolver.addOverrideEndpoint(ServiceType.MAAS, "https://maas.cn-north-1.myhuaweicloud.com/v1/%(project_id)s/objectstorage"); endpointResolver.addOverrideEndpoint(ServiceType.DATABASE, "https://rds.cn-north-1.myhuaweicloud.com"); /* 第二步: 配置鉴权信息(以对接华北区为例) * user为用户名 * projectId为华为云控制台-账户中心-基本信息-管理我的凭证-项目列表中华北区的项目ID * userDomainId为华为云控制台-账户中心-基本信息-管理我的凭证的账户ID * authURL为IAM服务华北区的域名 */ String user = "wanglianmin-guest"; String password = "XXXXXX"; String projectId = "74610f3a5ad941998e91f076297ecf27"; String userDomainId = "2aa29cbca17a4822abd096610e378ffa"; String authUrl = "https://iam.cn-north-1.myhuaweicloud.com/v3"; // 第三步: 初始化一个连接 OSFactory.enableHttpLoggingFilter(true); //调试用,可以显示request body和response body,正式使用时请注释掉此行 Config config = Config.newConfig().withEndpointURLResolver(endpointResolver).withLanguage(LANGUAGE) .withSSLVerificationDisabled(); OSClientV3 osclient = OSFactory.builderV3().withConfig(config).endpoint(authUrl) .credentials(user, password, Identifier.byId(userDomainId)).scopeToDomain(Identifier.byId(userDomainId)) .scopeToProject(Identifier.byId(projectId)).authenticate(); // 批量创建虚拟机,填入所需参数;停止、启动、重启、删除虚拟机 String imageId = "e377c242-d74b-4e06-a0a4-2e25b8e7eef0"; String flavorId = "s2.small.1"; String networkId = "ef039b60-6a14-42d1-963b-687b627fea08"; // 创建Linux密码虚拟机,目前密码使用user-data参数传入,将来会统一使用adminPass参数 String userData_org = "#!/bin/bash \r\n echo ´root:P@ssWr0d123´ | chpasswd ;"; byte[] userData_byte = userData_org.getBytes(); String userData = new BASE64Encoder().encode(userData_byte); // generate networkList ArrayList networkList = new ArrayList(); networkList.add(networkId); // generate server body ServerCreate sc_Linux = Builders.server() .name("zt-Linux-test-sdk").flavor(flavorId) .min(50).max(50).image(imageId) .availabilityZone("cn-north-1b") .userData(userData) .networks(networkList).build(); System.out.println("New Server body " + sc_Linux); Server newServer = osclient.compute().servers().boot(sc_Linux); osclient.compute().servers().waitForServerStatus(newServer.getId(), Status.ACTIVE, 10, TimeUnit.MINUTES); // 过滤查询弹性云服务器列表,等待所有ECS状态为ACTIVE Map filter_name = new HashMap(); filter_name.put("name", "zt-Linux-test-sdk"); List? extends Server> servers = osclient.compute().servers().list(filter_name); ArrayList serverIds = new ArrayList(); for (Server server : servers) { osclient.compute().servers().waitForServerStatus(server.getId(), Status.ACTIVE, 3, TimeUnit.MINUTES); serverIds.add(server.getId()); } // 批量重启虚拟机,等待Job执行成功,请根据业务需要调整TIMES、interval参数 String rebootJobId = osclient.compute().serversV1().reboot(serverIds, RebootType.SOFT); ArrayList reboot_failed_serverIds = waitforJob(osclient, rebootJobId, 18, 10); System.out.println("List of reboot failed servers " + reboot_failed_serverIds); // 批量停止虚拟机,等待Job执行成功,请根据业务需要调整TIMES、interval参数 String stopJobId = osclient.compute().serversV1().stop(serverIds, StopType.SOFT); ArrayList stop_failed_serverIds = waitforJob(osclient, stopJobId, 18, 10); System.out.println("List of stop failed servers " + stop_failed_serverIds); if(stop_failed_serverIds.isEmpty()) { System.out.println("batch stop server success, jobId = " + stopJobId); }else { String stopJobId_sec = osclient.compute().serversV1().stop(stop_failed_serverIds, StopType.SOFT); ArrayList stop_failed_serverIds_sec = waitforJob(osclient, stopJobId_sec, 18, 10); System.out.println("Second List of stop failed servers " + stop_failed_serverIds_sec); } // 批量启动虚拟机,等待Job执行成功,请根据业务需要调整TIMES、interval参数 String startJobId = osclient.compute().serversV1().start(serverIds); ArrayList start_failed_serverIds = waitforJob(osclient, startJobId, 18, 10); System.out.println("List of start failed servers " + start_failed_serverIds); // 批量删除虚拟机,等待Job执行成功,请根据业务需要调整TIMES、interval参数 String deleteJobId = osclient.compute().serversV1().delete(serverIds, false, false); ArrayList delete_failed_serverIds = waitforJob(osclient, deleteJobId, 18, 10); System.out.println("List of delete failed servers " + delete_failed_serverIds); } } [/code]
-
解决办法:在Project->Project Structure,添加sdk 库即可解决,以pycharm-professional-2017.3.3 为例, 安装python smn 的sdk库在C:\Python27\Lib\site-packages\smn_sdk_python-1.0.0-py2.7.egg 13086
-
出错信息: /usr1/udocker/answer/build.sh: 4: /usr1/udocker/answer/build.sh: : not found building... /usr1/udocker/answer/build.sh: 8: cd: can't cd to /usr1/udocker/answer /code/ecs/src javac: file not found: /usr1/udocker/answer /makelist.txt (No such file or directory) /usr1/udocker/answer/build.sh: 43: /usr1/udocker/answer/build.sh: Syntax error: end of file unexpected (expecting "then") #### ANSWER BUILD INFO#### {"build_failed": "Build answer failed: /usr1/udocker/answer/build.sh: 4: /usr1/udocker/answer/build.sh: \r: not found\nbuilding...\r\n/usr1/udocker/answer/build.sh: 8: cd: can't cd to /usr1/udocker/answer\r\r/code/ecs/src\r\njavac: file not found: /usr1/udocker/answer\r\r/makelist.txt\r\r (No such file or directory)\n/usr1/udocker/answer/build.sh: 43: /usr1/udocker/answer/build.sh: Syntax error: end of file unexpected (expecting \"then\")\n"} WARNING: Your kernel does not support swap limit capabilities, memory limited without swap.
-
原JAVA SDK for (int i = 1; i ecsContent.length; i++) { if (ecsContent.contains(" ") && ecsContent.split(" ").length == 3) { String[] array = ecsContent.split(" "); String uuid = array[0]; String flavorName = array[1]; String createTime = array[2]; history.add(uuid + " " + flavorName + " " + createTime); } } 关于这一部分解析是不是存在一点问题?? 这一部分不应该是训练数据吗?为什么从1开始读取,还有if条件也跳不进去. 是不是应该改为这样 for (int i = 0; i ecsContent.length; i++) { String[] array = ecsContent.split("\t"); String uuid = array[0]; String flavorName = array[1]; String createTime = array[2]; } 如果有希望交流的可以加qq:865845840
-
如果您还没有下载SDK,请访问http://developer.huaweicloud.com/sdk/java/dms-tcp.html下载SDK压缩包。下载dms.sdk.zip压缩包,即为DMS TCP SDK开发包,包含如下文件:[*]dms.sdk-1.0.0.jar:DMS TCP SDK包 [*]dms.protocol-1.0.0.jar: DMS TCP SDK包 [*]dms.client.properties:配置文件 [*]README.txt:发布说明文件 [*]third_lib.zip:DMS TCP SDK依赖的第三方jar包 [*]dms.sdk.api.chm:API接口参考
-
python中ecs.py文件读取数据的接口是这样的: def read_lines(file_path): if os.path.exists(file_path): array = [] with open(file_path, 'r') as lines: for line in lines: array.append(line) return array else: print 'file not exist: ' + file_path return None 返回的是一个list,然而在predictor中却是这样调用的: for index, item in input_lines: print "index of input data" 这不是会报too many values to unpack错误吗? 我自己改写了这个接口,可是却一直报answer exit abnormal Missing output file
-
ecsDataPath = sys.argv[1] inputFilePath = sys.argv[2] resultFilePath = sys.argv[3] 请问这几行代码是如何获取文件路径的?为什么我运行的len(sys.argv)总是等于1
推荐直播
-
OpenHarmony应用开发之网络数据请求与数据解析
2025/01/16 周四 19:00-20:30
华为开发者布道师、南京师范大学泰州学院副教授,硕士研究生导师,开放原子教育银牌认证讲师
科技浪潮中,鸿蒙生态强势崛起,OpenHarmony开启智能终端无限可能。当下,其原生应用开发适配潜力巨大,终端设备已广泛融入生活各场景,从家居到办公、穿戴至车载。 现在,机会敲门!我们的直播聚焦OpenHarmony关键的网络数据请求与解析,抛开晦涩理论,用真实案例带你掌握数据访问接口,轻松应对复杂网络请求、精准解析Json与Xml数据。参与直播,为开发鸿蒙App夯实基础,抢占科技新高地,别错过!
回顾中 -
Ascend C高层API设计原理与实现系列
2025/01/17 周五 15:30-17:00
Ascend C 技术专家
以LayerNorm算子开发为例,讲解开箱即用的Ascend C高层API
回顾中
热门标签