Exemplo n.º 1
0
class ConvertVolumes():
  
  
  def __init__(self, host_name=None, storage_provider=None):
      self.host_name = host_name
      self.storage_provider = storage_provider
      self.euca = EucaAdmin(path=SERVICE_PATH)
          
  def __repr__(self):
      return 'ConvertVolumes %s %s' % (self.host_name, self.storage_provider) 

  def startElement(self, name, attrs, connection):
      return None

  def endElement(self, name, value, connection):
    setattr(self, name, value)
  
  def get_parser(self):
    parser = OptionParser("usage: %prog [options]",version="Eucalyptus %prog VERSION")
    parser.add_option("-H","--host",dest="sc_host",help="Hostname or IP of the storage controller.")
    parser.add_option("-B","--backend",dest="provider",help="Storage backend provider to convert from.")
    return parser

  def execute(self, sc_host, provider):
    try:
      reply = self.euca.connection.get_object('ConvertVolumes', {'Component':'storage', 
                                                                 'OriginalProvider':provider,
                                                                 'Host':sc_host}, BooleanResponse)
      print reply
    except EC2ResponseError, ex:
      self.euca.handle_error(ex)
Exemplo n.º 2
0
class CloneVolume():
  

  def __init__(self, host_name=None, volume_id=None):
      self.host_name = host_name
      self.volume_id = volume_id
      self.euca = EucaAdmin(path=SERVICE_PATH)
          
  def __repr__(self):
      return 'Clone Volume %s %s' % (self.host_name, self.volume_id) 

  def startElement(self, name, attrs, connection):
      return None

  def endElement(self, name, value, connection):
    setattr(self, name, value)
  
  def get_parser(self):
    parser = OptionParser("usage: %prog [options]",version="Eucalyptus %prog VERSION")
    parser.add_option("-H","--host",dest="sc_host",help="Hostname or IP of the storage controller.")
    parser.add_option("-v","--volumeId",dest="volume_id",help="Parent Volume Id.")
    return parser

  def execute(self, sc_host, volume_id):
    try:
      reply = self.euca.connection.get_object('CloneVolume', {'Component':'storage', 
                                                                 'VolumeId':volume_id,
                                                                 'Host':sc_host}, BooleanResponse)
      print reply
    except EC2ResponseError, ex:
      self.euca.handle_error(ex)
Exemplo n.º 3
0
class Walrus():
  
  
  def __init__(self, walrus_name=None, host_name=None, port=None):
    self.walrus_name = walrus_name
    self.host_name = host_name
    self.euca = EucaAdmin(path=SERVICE_PATH)

          
  def __repr__(self):
      return 'WALRUS\t%s\t%s' % (self.walrus_name, self.host_name) 

  def startElement(self, name, attrs, connection):
      return None

  def endElement(self, name, value, connection):
    if name == 'euca:detail':
      self.host_name = value
    elif name == 'euca:name':
      self.walrus_name = value
    else:
      setattr(self, name, value)
  
  def describe(self):
    parser = OptionParser("usage: %prog [options]",version="Eucalyptus %prog VERSION")
    (options, args) = parser.parse_args()
    try:
      list = self.euca.connection.get_list('DescribeWalruses', {}, [('euca:item', Walrus)])
      for i in list:
        print i
    except EC2ResponseError, ex:
      self.euca.handle_error(ex)
Exemplo n.º 4
0
class Component():
  
  def __init__(self, component_name=None, host_name=None,
               port=None, partition=None, state=None):
    self.component_name = component_name
    self.host_name = host_name
    self.port = port
    self.partition = partition
    self.state = state
    self.euca = EucaAdmin(path=SERVICE_PATH)
    self.verbose = False
          
  def __repr__(self):
      return 'COMPONENT\t%-15.15s\t%-15.15s\t%-25s\t%s\t%s' % (self.partition, self.component_name,
                                      self.host_name, self.state, self.detail ) 

  def startElement(self, name, attrs, connection):
      return None

  def endElement(self, name, value, connection):
    if name == 'euca:detail':
      self.detail = value
    elif name == 'euca:state':
      self.state = value
    elif name == 'euca:hostName':
      self.host_name = value
    elif name == 'euca:name':
      self.component_name = value
    elif name == 'euca:partition':
      self.partition = value
    else:
      setattr(self, name, value)
  
  def get_describe_parser(self):
    parser = OptionParser("usage: %prog [COMPONENTS...]",
                          version="Eucalyptus %prog VERSION")
    parser.add_option("-v", "--verbose", dest="verbose", default=False, action="store_true", help="Report verbose details about the state of the component.")
    return parser.parse_args()
  
  def cli_describe(self):
    (options, args) = self.get_describe_parser()
    self.component_describe(args,options.verbose)
    
  def component_describe(self,components=None,verbose=False):
    params = {}
    if components:
      self.euca.connection.build_list_params(params,components,'Name')
    try:
      list = self.euca.connection.get_list('DescribeComponents', params,
                                           [('euca:item', Component)])
      for i in list:
        if verbose:
          print i
        elif not verbose and not i.host_name == 'detail':
          print i
    except EC2ResponseError, ex:
      self.euca.handle_error(ex)
Exemplo n.º 5
0
class Service():

  def __init__(self, service_epoch=None, service_state=None, service_detail=None):
    self.service_epoch = service_epoch
    self.service_state = service_state
    self.service_detail = StringList()
    self.service_id = ServiceStatus()
    self.euca = EucaAdmin(path=SERVICE_PATH)
    self.verbose = False

  def __repr__(self):
      return 'SERVICE\t%s\t%s\t%s\t%s' % (self.service_id, self.service_state, self.service_epoch, self.service_id.service_url )

  def startElement(self, name, attrs, connection):
    if name == 'euca:serviceId':
      return self.service_id
    elif name == 'euca:details':
      return self.service_detail
    else:
      return None    

  def endElement(self, name, value, connection):
    if name == 'euca:item':
      self.service_detail = '%s, %s' % (self.service_detail, value)
    elif name == 'euca:localState':
      self.service_state = value
    elif name == 'euca:localEpoch':
      self.service_epoch = value
    else:
      setattr(self, name, value)

  def get_describe_parser(self):
    parser = OptionParser("usage: %prog [COMPONENTS...]",
                          version="Eucalyptus %prog VERSION")
    parser.add_option("-v", "--verbose", dest="verbose", default=False, action="store_true", help="Report verbose details about the state of the component.")
    return parser.parse_args()

  def cli_describe(self):
    (options, args) = self.get_describe_parser()
    self.service_describe(args,options.verbose)

  def service_describe(self,components=None,verbose=False):
    params = {}
    if components:
      self.euca.connection.build_list_params(params,components,'Name')
    try:
      list = self.euca.connection.get_list('DescribeServices', params,
                                           [('euca:item', Service)])
      for i in list:
        if verbose:
          print i
        elif not verbose:
          print i
    except EC2ResponseError, ex:
      self.euca.handle_error(ex)
Exemplo n.º 6
0
class StorageController():
  
  def __init__(self, storage_name=None, host_name=None,
               port=None, partition=None, state=None):
    self.storage_name = storage_name
    self.host_name = host_name
    self.port = port
    self.partition = partition
    self.state = state
    self.euca = EucaAdmin(path=SERVICE_PATH)
          
  def __repr__(self):
      return 'STORAGE\t%s\t%s\t%s\t%s\t%s' % (self.partition, self.storage_name,
                                      self.host_name, self.state, self.detail) 

  def startElement(self, name, attrs, connection):
      return None

  def endElement(self, name, value, connection):
    if name == 'euca:detail':
      self.detail = value
    elif name == 'euca:state':
      self.state = value
    elif name == 'euca:hostName':
      self.host_name = value
    elif name == 'euca:name':
      self.storage_name = value
    elif name == 'euca:partition':
      self.partition = value
    else:
      setattr(self, name, value)
  
  def get_describe_parser(self):
    parser = OptionParser("usage: %prog [NAME...]",
                          version="Eucalyptus %prog VERSION")
    return parser.parse_args()

  def cli_describe(self):
    (options, args) = self.get_describe_parser()
    self.describe(args)

  def describe(self,scs=None):
    params = {}
    if scs:
      self.euca.connection.build_list_params(params,groups,'Names')
    try:
      list = self.euca.connection.get_list('DescribeStorageControllers',
                                           params,
                                           [('euca:item', StorageController)])
      for i in list:
        print i
    except EC2ResponseError, ex:
      self.euca.handle_error(ex)
Exemplo n.º 7
0
class Arbitrator():
  
  def __init__(self, arbitrator_name=None, host_name=None,
               port=None, partition=None):
    self.arbitrator_name = arbitrator_name
    self.host_name = host_name
    self.port = port
    self.partition = partition
    self.euca = EucaAdmin(path=SERVICE_PATH)

          
  def __repr__(self):
      return 'ARBITRATOR\t%s\t%s\t%s' % (self.arbitrator_name, self.partition,
                                      self.host_name) 

  def startElement(self, name, attrs, connection):
      return None

  def endElement(self, name, value, connection):
    if name == 'euca:detail':
      self.host_name = value
    elif name == 'euca:name':
      self.arbitrator_name = value
    elif name == 'euca:partition':
      self.partition = value
    else:
      setattr(self, name, value)
  
  def get_describe_parser(self):
    parser = OptionParser("usage: %prog [ARBITRATORS...]",
                          version="Eucalyptus %prog VERSION")
    return parser.parse_args()
  
  def cli_describe(self):
    (options, args) = self.get_describe_parser()
    self.arbitrator_describe(args)
    
  def arbitrator_describe(self,arbitrators=None):
    params = {}
    if arbitrators:
      self.euca.connection.build_list_params(params,arbitrators,'Name')
    try:
      list = self.euca.connection.get_list('DescribeArbitrators', params,
                                           [('euca:item', Arbitrator)])
      for i in list:
        print i
    except EC2ResponseError, ex:
      self.euca.handle_error(ex)
Exemplo n.º 8
0
 def __init__(self, service_epoch=None, service_state=None, service_detail=None):
   self.service_epoch = service_epoch
   self.service_state = service_state
   self.service_detail = StringList()
   self.service_id = ServiceStatus()
   self.euca = EucaAdmin(path=SERVICE_PATH)
   self.verbose = False
Exemplo n.º 9
0
 def __init__(self, arbitrator_name=None, host_name=None,
              port=None, partition=None):
   self.arbitrator_name = arbitrator_name
   self.host_name = host_name
   self.port = port
   self.partition = partition
   self.euca = EucaAdmin(path=SERVICE_PATH)
Exemplo n.º 10
0
 def __init__(self, property_name=None, property_value=None,
              property_description=None, property_old_value=None):
   self.property_name = property_name
   self.property_value = property_value
   self.property_description = property_description
   self.property_old_value = property_old_value
   self.euca = EucaAdmin(path=SERVICE_PATH)
Exemplo n.º 11
0
class Group():
  
  
  def __init__(self, groupName=None):
    self.group_groupName = groupName
    self.group_users = StringList()
    self.group_auths = StringList()
    self.euca = EucaAdmin(path=SERVICE_PATH)
          
  def __repr__(self):
    r = 'GROUP\t%s\t' % (self.group_groupName)
    r = '%s\nUSERS\t%s\t%s' % (r,self.group_groupName,self.group_users)
    r = '%s\nAUTH\t%s\t%s' % (r,self.group_groupName,self.group_auths)
    return r
      
  def startElement(self, name, attrs, connection):
    if name == 'euca:users':
      return self.group_users
    if name == 'euca:authorizations':
      return self.group_auths
    else:
      return None

  def endElement(self, name, value, connection):
    if name == 'euca:groupName':
      self.group_groupName = value
    else:
      setattr(self, name, value)
          
  def get_describe_parser(self):
    parser = OptionParser("usage: %prog [GROUPS...]",version="Eucalyptus %prog VERSION")
    return parser.parse_args()
  
  def cli_describe(self):
    (options, args) = self.get_describe_parser()
    self.group_describe(args)
    
  def group_describe(self,groups=None):
    params = {}
    if groups:
      self.euca.connection.build_list_params(params,groups,'GroupNames')
    try:
      list = self.euca.connection.get_list('DescribeGroups', params, [('euca:item', Group)])
      for i in list:
        print i
    except EC2ResponseError, ex:
      self.euca.handle_error(ex)
Exemplo n.º 12
0
class Node():
  
  
  def __init__(self, node_name=None, cluster_name=None, port=None):
    self.node_name = node_name
    self.cluster_name = cluster_name
    self.instances = []
    self.euca = EucaAdmin(path=SERVICE_PATH)

          
  def __repr__(self):
      s = 'NODE\t%s\t%s' % (self.node_name, self.cluster_name)
      for i in self.instances:
        s = '%s\t%s' % (s,i)
      return s

  def startElement(self, name, attrs, connection):
      return None

  def endElement(self, name, value, connection):
    if name == 'euca:clusterName':
      self.cluster_name = value
    elif name == 'euca:name':
      self.node_name = value
    elif name == 'euca:entry':
      self.instances.append(value)
    else:
      setattr(self, name, value)
  
  def get_describe_parser(self):
    parser = OptionParser("usage: %prog [NODES...]",version="Eucalyptus %prog VERSION")
    return parser.parse_args()
  
  def cli_describe(self):
    (options, args) = self.get_describe_parser()
    self.node_describe(args)
    
  def node_describe(self,nodes=None):
    params = {}
    if nodes:
      self.euca.connection.build_list_params(params,nodes,'Name')
    try:
      list = self.euca.connection.get_list('DescribeNodes', params, [('euca:item', Node)])
      for i in list:
        print i
    except EC2ResponseError, ex:
      self.euca.handle_error(ex)
Exemplo n.º 13
0
 def __init__(self, walrus_name=None, host_name=None,
              port=None, partition=None, state=None):
   self.walrus_name = walrus_name
   self.host_name = host_name
   self.port = port
   self.partition = partition
   self.state = state
   self.euca = EucaAdmin(path=SERVICE_PATH)
Exemplo n.º 14
0
 def __init__(self, vmwarebroker_name=None, host_name=None,
              port=None, partition=None, state=None):
   self.vmwarebroker_name = vmwarebroker_name
   self.host_name = host_name
   self.port = port
   self.partition = partition
   self.state = state
   self.euca = EucaAdmin(path=SERVICE_PATH)
Exemplo n.º 15
0
 def __init__(self, component_name=None, host_name=None,
              port=None, partition=None, state=None):
   self.component_name = component_name
   self.host_name = host_name
   self.port = port
   self.partition = partition
   self.state = state
   self.euca = EucaAdmin(path=SERVICE_PATH)
   self.verbose = False
Exemplo n.º 16
0
class VMwareBroker():
  
  def __init__(self, vmwarebroker_name=None, host_name=None,
               port=None, partition=None, state=None):
    self.vmwarebroker_name = vmwarebroker_name
    self.host_name = host_name
    self.port = port
    self.partition = partition
    self.state = state
    self.euca = EucaAdmin(path=SERVICE_PATH)
          
  def __repr__(self):
      return 'VMWARE\t%s\t%s\t%s\t%s\t%s' % (self.partition, self.vmwarebroker_name, 
                                      self.host_name, self.state, self.detail) 

  def startElement(self, name, attrs, connection):
      return None

  def endElement(self, name, value, connection):
    if name == 'euca:detail':
      self.detail = value
    elif name == 'euca:state':
      self.state = value
    elif name == 'euca:hostName':
      self.host_name = value
    elif name == 'euca:name':
      self.vmwarebroker_name = value
    elif name == 'euca:partition':
      self.partition = value
    else:
      setattr(self, name, value)
  
  def describe(self):
    parser = OptionParser("usage: %prog [options]",
                          version="Eucalyptus %prog VERSION")
    (options, args) = parser.parse_args()
    try:
      list = self.euca.connection.get_list('DescribeVMwareBrokers', {},
                                           [('euca:item', VMwareBroker)])
      for i in list:
        print i
    except EC2ResponseError, ex:
      self.euca.handle_error(ex)
Exemplo n.º 17
0
 def __init__(self, userName=None, email="N/A", certificateCode=None, confirmationCode=None, accessKey=None, secretKey=None, confirmed=False, admin=False, enabled=False, distinguishedName=None, certificateSerial=None):
   self.user_userName = userName
   self.user_email = email
   self.user_distinguishedName = distinguishedName
   self.user_certificateSerial = certificateSerial
   self.user_certificateCode = certificateCode
   self.user_confirmationCode = confirmationCode
   self.user_accessKey = accessKey
   self.user_secretKey = secretKey
   self.user_confirmed = confirmed
   self.user_admin = admin
   self.user_enabled = enabled
   self.user_groups = StringList()
   self.user_revoked = StringList()
   self.user_list = self.user_groups
   self.euca = EucaAdmin(path=SERVICE_PATH)
Exemplo n.º 18
0
class Property():
  
  
  def __init__(self, property_name=None, property_value=None,
               property_description=None, property_old_value=None):
    self.property_name = property_name
    self.property_value = property_value
    self.property_description = property_description
    self.property_old_value = property_old_value
    self.euca = EucaAdmin(path=SERVICE_PATH)

          
  def __repr__(self):
    global VERBOSE
    str = 'PROPERTY\t%s\t%s' % (self.property_name, self.property_value)
    if self.property_old_value is not None:
      str = '%s was %s' % (str, self.property_old_value)
    elif VERBOSE:
      str = '%s\nDESCRIPTION\t%s\t%s' % (str, self.property_name, self.property_description) 
    return str

  def startElement(self, name, attrs, connection):
      return None

  def endElement(self, name, value, connection):
    if name == 'euca:name':
      self.property_name = value
    elif name == 'euca:value':
      self.property_value = value
    elif name == 'euca:oldValue':
      self.property_old_value = value
    elif name == 'euca:description':
      self.property_description = value
    else:
      setattr(self, name, value)

  def get_parser(self):
    parser = OptionParser("usage: %prog [PROPERTY...]", version="Eucalyptus %prog VERSION")
    parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
                      help="Show property descriptions.")
    return parser
        
  def parse_describe(self):
    global VERBOSE
    (options,args) = self.get_parser().parse_args()  
    if options.verbose:
      VERBOSE = True
    return (options,args)

  def cli_describe(self):
    (options,args) = self.parse_describe()
    self.describe(args)

  def describe(self,props=None):
    params = {}
    if props:
      self.euca.connection.build_list_params(params,props,'Properties')
    try:
      list = self.euca.connection.get_list('DescribeProperties',
                                           params, [('euca:item', Property)])
      for i in list:
        print i
    except EC2ResponseError, ex:
      self.euca.handle_error(ex)
 def __init__(self, storage_name=None, host_name=None, port=None):
     self.storage_name = storage_name
     self.host_name = host_name
     self.euca = EucaAdmin(path=SERVICE_PATH)
Exemplo n.º 20
0
class User():
  
  
  def __init__(self, userName=None, email="N/A", certificateCode=None, confirmationCode=None, accessKey=None, secretKey=None, confirmed=False, admin=False, enabled=False, distinguishedName=None, certificateSerial=None):
    self.user_userName = userName
    self.user_email = email
    self.user_distinguishedName = distinguishedName
    self.user_certificateSerial = certificateSerial
    self.user_certificateCode = certificateCode
    self.user_confirmationCode = confirmationCode
    self.user_accessKey = accessKey
    self.user_secretKey = secretKey
    self.user_confirmed = confirmed
    self.user_admin = admin
    self.user_enabled = enabled
    self.user_groups = StringList()
    self.user_revoked = StringList()
    self.user_list = self.user_groups
    self.euca = EucaAdmin(path=SERVICE_PATH)
          
  def __repr__(self):
    r = 'USER\t\t%s\t%s%s\t%s' % (self.user_userName, self.user_email, '\tADMIN' if self.user_admin == 'true' else ' ', 'ENABLED' if self.user_enabled == 'true' else 'DISABLED')
    r = '%s\nUSER-GROUP\t%s\t%s' % (r, self.user_userName, self.user_groups)
    r = '%s\nUSER-CERT\t%s\t%s\t%s' % (r, self.user_userName, self.user_distinguishedName, self.user_certificateSerial)
#    for s in self.user_revoked:
#      r = '%s\nUSER-REVOKED\t%s\t%s' % (r,self.user_userName,s)
    r = '%s\nUSER-KEYS\t%s\t%s\t%s' % (r, self.user_userName, self.user_accessKey, self.user_secretKey)
    r = '%s\nUSER-CODE\t%s\t%s' % (r, self.user_userName, self.user_certificateCode)
    r = '%s\nUSER-WEB \t%s\t%s' % (r, self.user_userName, self.user_confirmationCode)
    return r
      
  def startElement(self, name, attrs, connection):
    if name == 'euca:groups':
      return self.user_groups
    elif name == 'euca:revoked':
      return self.user_revoked
    else:
      return None    

  def endElement(self, name, value, connection):
    if name == 'euca:userName':
      self.user_userName = value
    elif name == 'euca:email':
      self.user_email = value
    elif name == 'euca:admin':
      self.user_admin = value
    elif name == 'euca:confirmed':
      self.user_confirmed = value
    elif name == 'euca:enabled':
      self.user_enabled = value
    elif name == 'euca:distinguishedName':
      self.user_distinguishedName = value
    elif name == 'euca:certificateSerial':
      self.user_certificateSerial = value
    elif name == 'euca:certificateCode':
      self.user_certificateCode = value
    elif name == 'euca:confirmationCode':
      self.user_confirmationCode = value
    elif name == 'euca:accessKey':
      self.user_accessKey = value
    elif name == 'euca:secretKey':
      self.user_secretKey = value
    elif name == 'euca:entry':
      self.user_list.append(value)
    else:
      setattr(self, name, value)
          
  def get_describe_parser(self):
    parser = OptionParser("usage: %prog [USERNAME...", version="Eucalyptus %prog VERSION")
    (options, args) = parser.parse_args()    
    return (options, args)  
  
  def cli_describe(self):
    (options, args) = self.get_describe_parser()
    self.describe(args)
				  	
  
  def describe(self,users):
    params = {}
    if users:
      self.euca.connection.build_list_params(params, users, 'UserNames')
    try:
      list = self.euca.connection.get_list('DescribeUsers', params, [('euca:item', User)])
      for i in list:
        print i
    except EC2ResponseError, ex:
      self.euca.handle_error(ex)
Exemplo n.º 21
0
 def __init__(self, groupName=None):
   self.group_groupName = groupName
   self.group_users = StringList()
   self.group_auths = StringList()
   self.euca = EucaAdmin(path=SERVICE_PATH)
Exemplo n.º 22
0
 def __init__(self, walrus_name=None, host_name=None, port=None):
   self.walrus_name = walrus_name
   self.host_name = host_name
   self.euca = EucaAdmin(path=SERVICE_PATH)
Exemplo n.º 23
0
 def __init__(self, host_name=None, storage_provider=None):
     self.host_name = host_name
     self.storage_provider = storage_provider
     self.euca = EucaAdmin(path=SERVICE_PATH)
Exemplo n.º 24
0
 def __init__(self, host_name=None, volume_id=None):
     self.host_name = host_name
     self.volume_id = volume_id
     self.euca = EucaAdmin(path=SERVICE_PATH)
Exemplo n.º 25
0
 def __init__(self, cluster_name=None, host_name=None, port=None):
   self.cluster_name = cluster_name
   self.host_name = host_name
   self.euca = EucaAdmin(path=SERVICE_PATH)
Exemplo n.º 26
0
 def __init__(self, node_name=None, cluster_name=None, port=None):
   self.node_name = node_name
   self.cluster_name = cluster_name
   self.instances = []
   self.euca = EucaAdmin(path=SERVICE_PATH)