0 Replies Latest reply on Nov 22, 2012 11:36 AM by 902735

    Issue while trying to modify the VM size(Memory,CPU) using EM 12c API


      We are trying to modify the VM size(CPU,memory) from a custom web portal by using EM12c Cloud API as mentioned in "http://docs.oracle.com/cd/E24628_01/doc.121/e28814/cloud_examples.htm#autoId16"
      After submitting the request from the java code mentioned below, we are getting the following response : 200 OK {}. But the VM sizes are not getting updated in EM( instance.
      However, we are able to change the VM status (start,stop) using the same code successfully

      The following code is used :
      public class Test {

           public static void main(String[] args) {
                     String host = "https://<em url>";
                     String uri = host+ "/em/cloud/server/XXXXXXXXXX?resource_state";
                     String type = "application/oracle.com.cloud.common.VM+json";
                     String content = type;
                     HostnameVerifier hv = new HostnameVerifier() {
                          public boolean verify(String urlHostName, SSLSession session) {
                               return true;
                     URL url = new URL(uri);
                     HttpURLConnection conn = (HttpURLConnection)url.openConnection();
                     conn.setRequestProperty("Authorization", "basic XXXXX");
                     conn.setRequestProperty("Accept", type);
                     conn.setRequestProperty("Content-Type", content);
                conn.setRequestProperty("Media-Type", content);
                     conn.setRequestProperty("x-specification-version", "10001");
                //conn.setRequestProperty("X-Cloud-Client-Specification-Version", "0.1");
                     String send = "{\n \"cpu\":[1,0],\"memory\":\"512\" \n}";
                     DataOutputStream wr = new DataOutputStream(conn.getOutputStream());
                     BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                     String line = "";
                     while((line=br.readLine()) != null){
                }catch (Exception e) {
           private static void trustAllHttpsCertificates()
      throws Exception
      TrustManager[] trustAllCerts = new TrustManager[1];
      TrustManager tm = new miTM();
      trustAllCerts[0] = tm;
      SSLContext sc = SSLContext.getInstance("SSL");

      sc.init(null, trustAllCerts, null);

      public static class miTM
      implements TrustManager, X509TrustManager
      public X509Certificate[] getAcceptedIssuers()
      return null; }
      public boolean isServerTrusted(X509Certificate[] certs) { return true; }
      public boolean isClientTrusted(X509Certificate[] certs) { return true; }

      public void checkServerTrusted(X509Certificate[] certs, String authType)
      throws CertificateException

      public void checkClientTrusted(X509Certificate[] certs, String authType)
      throws CertificateException


      Please help,