def testRun(self) :
      (apikey, secretkey) = self.getApiKeys("localhost", "admin", "password", None)
      blub = mgmtDetails()
      blub.apiKey=apikey
      blub.securityKey=secretkey

      conn = cloudConnection(blub, logging=logging)

      # Seed the random generator that we use to generate names
      random.seed()

      try:
         zone = self.internalQueryZone(conn)
         vpcoffering = self.internalCreateVpcOffering(conn);
         vpc = self.internalCreateVPC(conn, zone, vpcoffering)
 
         vpcnetwithlb = self.internalCreateNetworkOfferingWithLb(conn);
         vpcnetnolb = self.internalCreateNetworkOfferingNoLb(conn);

         network_with_lb = self.internalCreateNetwork(conn, vpcnetwithlb, vpc, zone)
         network_without_lb = self.internalCreateNetwork(conn, vpcnetnolb, vpc, zone)
         network_without_lb = self.internalCreateNetwork(conn, vpcnetnolb, vpc, zone)
         
      except urllib2.HTTPError, e:
         print e.read()
         raise e
   def testRun(self) :
      apikey = "Q1rKKrMjxNhGopcGQv-c5eiVh7oSdiZ1wgElUu5jdawFonr6_c2JB_K5bnBsq7_JnmpNO9rxu-6_qcQzhG3DJA"
      secretkey = "JQV1JqWIUvH6FGOofjfaOs8EAHTUA5IZTRcpQUqFEL06MDUaWM8HMukUT5tBQUb7G7M0cfNK6rM766Ln0HXmDw"
      conn = cloudConnection("localhost", apiKey=apikey, securityKey=secretkey, port=8080, protocol="http")

      # Seed the random generator that we use to generate names
      random.seed()

      try:
         zone = self.internalQueryZone(conn)
         timeremaining = 3 # 20 minutes
         ready = True
         while (timeremaining > 0) :
            templatelist = self.checkTemplateReady(conn, zone)
            if not templatelist is None :
               for template in templatelist :
                  if template.account == "system" and  template.isready :
                     ready = False
            if ready :
               break
            time.sleep(60)
            timeremaining = timeremaining - 1
         if not ready :
            raise Exception('timeout waiting for templates to become ready')
         print "All templates are ready"
         
      except urllib2.HTTPError, e:
         print e.read()
         raise e
   def getConnection(self):
      (apikey, secretkey) = self.getApiKeys("localhost", "admin", "password", None)
      blub = mgmtDetails()
      blub.apiKey=apikey
      blub.securityKey=secretkey

      conn = cloudConnection(blub, logger=logging)
      return conn
Example #4
0
 def make_request(self, command, requests={}):
     conn = cloudConnection(self.host, port=int(self.port),
                            apiKey=self.apiKey, securityKey=self.secretKey,
                            logging=logging.getLogger("cloudConnection"))
     try:
         response = conn.make_request(command, requests)
     except cloudstackAPIException, e:
         self.print_shell("API Error", e)
         return None
Example #5
0
 def make_request(self, command, requests={}, isAsync=False):
     conn = cloudConnection(self.host, port=int(self.port),
                            apiKey=self.apikey, securityKey=self.secretkey,
                            asyncTimeout=self.timeout, logging=logger)
     response = None
     try:
         response = conn.make_request_with_auth(command, requests)
     except cloudstackAPIException, e:
         self.print_shell("API Error:", e)
Example #6
0
def fetch_api_client(config_file="datacenterCfg"):
    """Fetch the Cloudstack API Client"""
    config = configGenerator.get_setup_config(config_file)
    mgt = config.mgtSvr[0]
    testClientLogger = logging.getLogger("testClient")
    asyncTimeout = 3600
    return cloudstackAPIClient.CloudStackAPIClient(
        cloudstackConnection.cloudConnection(
            mgt.mgtSvrIp, mgt.port, mgt.apiKey, mgt.securityKey, asyncTimeout, testClientLogger
        )
    )
 def make_request(self, command, requests={}, isAsync=False):
     conn = cloudConnection(self.host, port=int(self.port),
                            apiKey=self.apikey, securityKey=self.secretkey,
                            asyncTimeout=self.timeout, logging=logger,
                            protocol=self.protocol, path=self.path)
     response = None
     logger.debug("====START Request====")
     logger.debug("Requesting command=%s, args=%s" % (command, requests))
     try:
         response = conn.make_request_with_auth(command, requests)
     except cloudstackAPIException, e:
         self.print_shell("API Error:", e)
   def testRun(self) :
      (apikey, secretkey) = self.getApiKeys("10.200.23.16", "admin", "password", None)
      conn = cloudConnection("10.200.23.16", apiKey=apikey, securityKey=secretkey, port=8080, scheme="http", logging=logging)

      # Seed the random generator that we use to generate names
      random.seed()

      try:
         zone = self.internalQueryZone(conn)
         vpcoffering = self.internalCreateVpcOffering(conn);
         vpc = self.internalCreateVPC(conn, zone, vpcoffering)
 
         vpcnetwithlb = self.internalCreateNetworkOfferingWithLb(conn);
         vpcnetnolb = self.internalCreateNetworkOfferingNoLb(conn);

         network_with_lb = self.internalCreateNetwork(conn, vpcnetwithlb, vpc, zone)
         network_without_lb = self.internalCreateNetwork(conn, vpcnetnolb, vpc, zone)
         network_without_lb = self.internalCreateNetwork(conn, vpcnetnolb, vpc, zone)
         
      except urllib2.HTTPError, e:
         print e.read()
         raise e
    resp = connection.getresponse()
    dom = xml.dom.minidom.parseString(resp.read())
    apiKey = dom.getElementsByTagName('apikey')[0].firstChild.data
    secretKey = dom.getElementsByTagName('secretkey')[0].firstChild.data

  connection.close()
  return (apiKey, secretKey)


(apikey, secretkey) = getApiKeys("10.200.23.16", "admin", "password", None)


#apikey="pom8IkKoTGWX4cEvrrGflh_QMm6-2gtrHYOitqE2PUlIe55tcglvxHlzvpvTPzZ-lZQbuIyxe8umuY59G6BN1w"
#secretkey="5GP3esBMT4yr3oTuTFZxxuQ1k0znUvZClC7Nb3adyhmzeC4hF_bm0TTEGv07JEgs-LBzSbZXCs8JyzMLnlN6ig"

conn = cloudConnection("10.200.23.16", apiKey=apikey, securityKey=secretkey, port=8080, logging=logging)

configuration = {
   'cpu.overprovisioning.factor'     : 10,
   'mem.overprovisioning.factor'     : 10,
   'storage.overprovisioning.factor' : 4,
   'host'                            : "10.200.23.16",
   'expunge.delay'                   : 120,
   'expunge.interval'                : 60,
   'network.gc.interval'             : 60,
   'network.gc.wait'                 : 120
   }

listconfig = listConfigurations.listConfigurationsCmd()
try:
   resp = conn.marvin_request(listconfig)