Ejemplo n.º 1
0
 def _restart_exports(self):
     if FLAGS.fake_storage:
         return
     utils.runthis("Setting exports to auto: %s",
                   "sudo vblade-persist auto all")
     utils.runthis("Starting all exports: %s",
                   "sudo vblade-persist start all")
Ejemplo n.º 2
0
 def _remove_export(self):
     utils.runthis(
         "Stopped AOE export: %s", "sudo vblade-persist stop %s %s" %
         (self['shelf_id'], self['blade_id']))
     utils.runthis(
         "Destroyed AOE export: %s", "sudo vblade-persist destroy %s %s" %
         (self['shelf_id'], self['blade_id']))
Ejemplo n.º 3
0
Archivo: storage.py Proyecto: jxta/cc
 def setup_export(self):
     (shelf_id, blade_id) = get_next_aoe_numbers()
     self['aoe_device'] = "e%s.%s" % (shelf_id, blade_id)
     self.save()
     utils.runthis("Creating AOE export: %s",
             "sudo vblade-persist setup %s %s %s /dev/%s/%s" %
             (shelf_id, blade_id, FLAGS.aoe_eth_dev, FLAGS.volume_group, self.volume_id))
Ejemplo n.º 4
0
 def _remove_export(self):
     runthis(
         "Destroyed AOE export: %s", "sudo vblade-persist stop %s %s" %
         (self.aoe_device[1], self.aoe_device[3]))
     runthis(
         "Destroyed AOE export: %s", "sudo vblade-persist destroy %s %s" %
         (self.aoe_device[1], self.aoe_device[3]))
Ejemplo n.º 5
0
 def _exec_export(self):
     utils.runthis("Creating AOE export: %s",
             "sudo vblade-persist setup %s %s %s /dev/%s/%s" %
             (self['shelf_id'],
              self['blade_id'],
              FLAGS.aoe_eth_dev,
              FLAGS.volume_group,
              self['volume_id']))
Ejemplo n.º 6
0
 def create_lv(self):
     if str(self['size']) == '0':
         sizestr = '100M'
     else:
         sizestr = '%sG' % self['size']
     utils.runthis(
         "Creating LV: %s", "sudo lvcreate -L %s -n %s %s" %
         (sizestr, self['volume_id'], FLAGS.volume_group))
Ejemplo n.º 7
0
Archivo: node.py Proyecto: jxta/cc
 def detach_volume(self, instance_id, mountpoint):
     """ detach a volume from an instance """
     # despite the documentation, virsh detach-disk just wants the device
     # name without the leading /dev/
     target = mountpoint.rpartition('/dev/')[2]
     utils.runthis("Detached Volume: %s", "sudo virsh detach-disk %s %s "
             % (instance_id, target))
     return defer.succeed(True)
Ejemplo n.º 8
0
 def _init_volume_group(self):
     if FLAGS.fake_storage:
         return
     runthis("PVCreate returned: %s",
             "sudo pvcreate %s" % (FLAGS.storage_dev))
     runthis(
         "VGCreate returned: %s",
         "sudo vgcreate %s %s" % (FLAGS.volume_group, FLAGS.storage_dev))
Ejemplo n.º 9
0
 def _setup_export(self):
     (shelf_id, blade_id) = get_next_aoe_numbers()
     self.aoe_device = "e%s.%s" % (shelf_id, blade_id)
     runthis(
         "Creating AOE export: %s",
         "sudo vblade-persist setup %s %s %s /dev/%s/%s" %
         (shelf_id, blade_id, FLAGS.aoe_eth_dev, FLAGS.volume_group,
          self.volume_id))
Ejemplo n.º 10
0
 def detach_volume(self, instance_id, mountpoint):
     """ detach a volume from an instance """
     # despite the documentation, virsh detach-disk just wants the device
     # name without the leading /dev/
     target = mountpoint.rpartition('/dev/')[2]
     utils.runthis("Detached Volume: %s",
                   "sudo virsh detach-disk %s %s " % (instance_id, target))
     return defer.succeed(True)
Ejemplo n.º 11
0
 def attach_volume(self,
                   instance_id=None,
                   aoe_device=None,
                   mountpoint=None):
     utils.runthis(
         "Attached Volume: %s",
         "sudo virsh attach-disk %s /dev/etherd/%s %s" %
         (instance_id, aoe_device, mountpoint.split("/")[-1]))
     return defer.succeed(True)
Ejemplo n.º 12
0
Archivo: node.py Proyecto: sorenh/cc
 def detach_volume(self, instance_id, volume_id):
     """ detach a volume from an instance """
     # despite the documentation, virsh detach-disk just wants the device
     # name without the leading /dev/
     volume = storage.get_volume(volume_id)
     target = volume['mountpoint'].rpartition('/dev/')[2]
     utils.runthis("Detached Volume: %s", "sudo virsh detach-disk %s %s "
             % (instance_id, target))
     volume.finish_detach()
     return defer.succeed(True)
Ejemplo n.º 13
0
 def detach_volume(self, instance_id, volume_id):
     """ detach a volume from an instance """
     # despite the documentation, virsh detach-disk just wants the device
     # name without the leading /dev/
     volume = storage.get_volume(volume_id)
     target = volume['mountpoint'].rpartition('/dev/')[2]
     utils.runthis("Detached Volume: %s",
                   "sudo virsh detach-disk %s %s " % (instance_id, target))
     volume.finish_detach()
     return defer.succeed(True)
Ejemplo n.º 14
0
 def setup(self):
     # Create keys folder, if it doesn't exist
     if not os.path.exists(FLAGS.keys_path):
         os.makedirs(os.path.abspath(FLAGS.keys_path))
     # Gen root CA, if we don't have one
     root_ca_path = os.path.join(FLAGS.ca_path, FLAGS.ca_file)
     if not os.path.exists(root_ca_path):
         start = os.getcwd()
         os.chdir(FLAGS.ca_path)
         runthis("Generating root CA: %s", "sh genrootca.sh")
         os.chdir(start)
Ejemplo n.º 15
0
 def setup_export(self):
     (shelf_id, blade_id) = get_next_aoe_numbers()
     self['aoe_device'] = "e%s.%s" % (shelf_id, blade_id)
     self['shelf_id'] = shelf_id
     self['blade_id'] = blade_id
     self.save()
     utils.runthis(
         "Creating AOE export: %s",
         "sudo vblade-persist setup %s %s %s /dev/%s/%s" %
         (shelf_id, blade_id, FLAGS.aoe_eth_dev, FLAGS.volume_group,
          self['volume_id']))
Ejemplo n.º 16
0
 def setup(self):
     # Create keys folder, if it doesn't exist
     if not os.path.exists(FLAGS.keys_path):
         os.makedirs(os.path.abspath(FLAGS.keys_path))
     # Gen root CA, if we don't have one
     root_ca_path = os.path.join(FLAGS.ca_path, FLAGS.ca_file)
     if not os.path.exists(root_ca_path):
         start = os.getcwd()
         os.chdir(FLAGS.ca_path)
         runthis("Generating root CA: %s", "sh genrootca.sh")
         os.chdir(start)
Ejemplo n.º 17
0
Archivo: cloud.py Proyecto: yosh/nova
 def setup(self):
     """ Ensure the keychains and folders exist. """
     # FIXME(ja): this should be moved to a nova-manage command,
     # if not setup throw exceptions instead of running
     # Create keys folder, if it doesn't exist
     if not os.path.exists(FLAGS.keys_path):
         os.makedirs(FLAGS.keys_path)
     # Gen root CA, if we don't have one
     root_ca_path = os.path.join(FLAGS.ca_path, FLAGS.ca_file)
     if not os.path.exists(root_ca_path):
         start = os.getcwd()
         os.chdir(FLAGS.ca_path)
         # TODO(vish): Do this with M2Crypto instead
         utils.runthis(_("Generating root CA: %s"), "sh genrootca.sh")
         os.chdir(start)
Ejemplo n.º 18
0
 def express(self, address=None):
     logging.debug("Todo - need to create IPTables natting entries for this net.")
     addresses = self.hosts.values()
     if address:
         addresses = [self.hosts[address]]
     for addr in addresses:
         if not addr.has_key('private_ip'):
             continue
         public_ip = addr['address']
         private_ip = addr['private_ip']
         runthis("Binding IP to interface: %s", "sudo ip addr add %s dev %s" % (public_ip, FLAGS.public_interface))
         confirm_rule("PREROUTING -t nat -d %s -j DNAT --to %s" % (public_ip, private_ip))
         confirm_rule("POSTROUTING -t nat -s %s -j SNAT --to %s" % (private_ip, public_ip))
         # TODO: Get these from the secgroup datastore entries
         confirm_rule("FORWARD -d %s -p icmp -j ACCEPT" % (private_ip))
         for (protocol, port) in [("tcp",80), ("tcp",22), ("udp",1194), ("tcp",443)]:
             confirm_rule("FORWARD -d %s -p %s --dport %s -j ACCEPT" % (private_ip, protocol, port))
Ejemplo n.º 19
0
 def attach_volume(self, instance_id=None, volume_id=None, mountpoint=None):
     volume = storage.get_volume(volume_id)
     yield self._init_aoe()
     yield utils.runthis(
         "Attached Volume: %s",
         "sudo virsh attach-disk %s /dev/etherd/%s %s" %
         (instance_id, volume['aoe_device'], mountpoint.split("/")[-1]))
     volume.finish_attach()
     defer.returnValue(True)
Ejemplo n.º 20
0
Archivo: node.py Proyecto: sorenh/cc
 def attach_volume(self, instance_id = None,
                   volume_id = None, mountpoint = None):
     volume = storage.get_volume(volume_id)
     yield self._init_aoe()
     yield utils.runthis("Attached Volume: %s",
             "sudo virsh attach-disk %s /dev/etherd/%s %s"
             % (instance_id, volume['aoe_device'], mountpoint.split("/")[-1]))
     volume.finish_attach()
     defer.returnValue(True)
Ejemplo n.º 21
0
    def setup(self):
        """ Ensure the keychains and folders exist. """
        # FIXME(ja): this should be moved to a nova-manage command,
        # if not setup throw exceptions instead of running
        # Create keys folder, if it doesn't exist
        if not os.path.exists(FLAGS.keys_path):
            os.makedirs(FLAGS.keys_path)
        # Gen root CA, if we don't have one
        root_ca_path = os.path.join(FLAGS.ca_path, FLAGS.ca_file)
        if not os.path.exists(root_ca_path):
            genrootca_sh_path = os.path.join(os.path.dirname(__file__),
                                             os.path.pardir, os.path.pardir,
                                             'CA', 'genrootca.sh')

            start = os.getcwd()
            if not os.path.exists(FLAGS.ca_path):
                os.makedirs(FLAGS.ca_path)
            os.chdir(FLAGS.ca_path)
            # TODO(vish): Do this with M2Crypto instead
            utils.runthis(_("Generating root CA: %s"), "sh", genrootca_sh_path)
            os.chdir(start)
Ejemplo n.º 22
0
    def setup(self):
        """Ensure the keychains and folders exist."""
        # TODO(todd): this was copyed from api.ec2.cloud
        # FIXME(ja): this should be moved to a nova-manage command,
        # if not setup throw exceptions instead of running
        # Create keys folder, if it doesn't exist
        if not os.path.exists(FLAGS.keys_path):
            os.makedirs(FLAGS.keys_path)
        # Gen root CA, if we don't have one
        root_ca_path = os.path.join(FLAGS.ca_path, FLAGS.ca_file)
        if not os.path.exists(root_ca_path):
            genrootca_sh_path = os.path.join(os.path.dirname(__file__),
                                             os.path.pardir,
                                             os.path.pardir,
                                             'CA',
                                             'genrootca.sh')

            start = os.getcwd()
            if not os.path.exists(FLAGS.ca_path):
                os.makedirs(FLAGS.ca_path)
            os.chdir(FLAGS.ca_path)
            # TODO(vish): Do this with M2Crypto instead
            utils.runthis(_("Generating root CA: %s"), "sh", genrootca_sh_path)
            os.chdir(start)
Ejemplo n.º 23
0
 def express(self, address=None):
     logging.debug(
         "Todo - need to create IPTables natting entries for this net.")
     addresses = self.hosts.values()
     if address:
         addresses = [self.hosts[address]]
     for addr in addresses:
         if not addr.has_key('private_ip'):
             continue
         public_ip = addr['address']
         private_ip = addr['private_ip']
         runthis(
             "Binding IP to interface: %s", "sudo ip addr add %s dev %s" %
             (public_ip, FLAGS.public_interface))
         confirm_rule("PREROUTING -t nat -d %s -j DNAT --to %s" %
                      (public_ip, private_ip))
         confirm_rule("POSTROUTING -t nat -s %s -j SNAT --to %s" %
                      (private_ip, public_ip))
         # TODO: Get these from the secgroup datastore entries
         confirm_rule("FORWARD -d %s -p icmp -j ACCEPT" % (private_ip))
         for (protocol, port) in [("tcp", 80), ("tcp", 22), ("udp", 1194),
                                  ("tcp", 443)]:
             confirm_rule("FORWARD -d %s -p %s --dport %s -j ACCEPT" %
                          (private_ip, protocol, port))
Ejemplo n.º 24
0
 def attach_volume(self, instance_id = None, aoe_device = None, mountpoint = None):
     runthis("Attached Volume: %s", "sudo virsh attach-disk %s /dev/etherd/%s %s"
             % (instance_id, aoe_device, mountpoint.split("/")[-1]))
     return defer.succeed(True)
Ejemplo n.º 25
0
 def _init_aoe(self):
     utils.runthis("Doin an AoE discover, returns %s", "sudo aoe-discover")
     utils.runthis("Doin an AoE stat, returns %s", "sudo aoe-stat")
Ejemplo n.º 26
0
 def detach_volume(self, instance_id, mountpoint):
     """ detach a volume from an instance """
     runthis("Detached Volume: %s", "sudo virsh detach-disk %s %s "
             % (instance_id, mountpoint))
     return defer.succeed(True)
Ejemplo n.º 27
0
 def _remove_export(self):
     utils.runthis("Stopped AOE export: %s", "sudo vblade-persist stop %s %s" % (self['shelf_id'], self['blade_id']))
     utils.runthis("Destroyed AOE export: %s", "sudo vblade-persist destroy %s %s" % (self['shelf_id'], self['blade_id']))
Ejemplo n.º 28
0
 def _delete_lv(self):
     utils.runthis(
         "Removing LV: %s",
         "sudo lvremove -f %s/%s" % (FLAGS.volume_group, self['volume_id']))
Ejemplo n.º 29
0
 def _restart_exports(self):
     if FLAGS.fake_storage:
         return
     runthis("Setting exports to auto: %s", "sudo vblade-persist auto all")
     runthis("Starting all exports: %s", "sudo vblade-persist start all")
     runthis("Discovering AOE devices: %s", "sudo aoe-discover")
Ejemplo n.º 30
0
 def _create_lv(self, size):
     runthis("Creating LV: %s", "sudo lvcreate -L %s -n %s %s" % (size, self.volume_id, FLAGS.volume_group))
Ejemplo n.º 31
0
 def _create_lv(self, size):
     runthis(
         "Creating LV: %s", "sudo lvcreate -L %s -n %s %s" %
         (size, self.volume_id, FLAGS.volume_group))
Ejemplo n.º 32
0
Archivo: storage.py Proyecto: jxta/cc
 def _delete_lv(self):
     utils.runthis("Removing LV: %s", "sudo lvremove -f %s/%s" % (FLAGS.volume_group, self.volume_id))
Ejemplo n.º 33
0
Archivo: storage.py Proyecto: jxta/cc
 def create_lv(self):
     if str(self['size']) == '0':
         sizestr = '100M'
     else:
         sizestr = '%sG' % self['size']
     utils.runthis("Creating LV: %s", "sudo lvcreate -L %s -n %s %s" % (sizestr, self.volume_id, FLAGS.volume_group))
Ejemplo n.º 34
0
Archivo: storage.py Proyecto: jxta/cc
 def _init_volume_group(self):
     if FLAGS.fake_storage:
         return
     utils.runthis("PVCreate returned: %s", "sudo pvcreate %s" % (FLAGS.storage_dev))
     utils.runthis("VGCreate returned: %s", "sudo vgcreate %s %s" % (FLAGS.volume_group, FLAGS.storage_dev))
Ejemplo n.º 35
0
Archivo: storage.py Proyecto: jxta/cc
 def _restart_exports(self):
     if FLAGS.fake_storage:
         return
     utils.runthis("Setting exports to auto: %s", "sudo vblade-persist auto all")
     utils.runthis("Starting all exports: %s", "sudo vblade-persist start all")
     utils.runthis("Discovering AOE devices: %s", "sudo aoe-discover")
Ejemplo n.º 36
0
 def _delete_lv(self):
     runthis(
         "Removing LV: %s",
         "sudo lvremove -f %s/%s" % (FLAGS.volume_group, self.volume_id))
Ejemplo n.º 37
0
Archivo: storage.py Proyecto: jxta/cc
 def _remove_export(self):
     utils.runthis("Destroyed AOE export: %s", "sudo vblade-persist stop %s %s" % (self.aoe_device[1], self.aoe_device[3]))
     utils.runthis("Destroyed AOE export: %s", "sudo vblade-persist destroy %s %s" % (self.aoe_device[1], self.aoe_device[3]))
Ejemplo n.º 38
0
def runthis(desc, cmd):
    if FLAGS.fake_network:
        return execute(cmd)
    else:
        return utils.runthis(desc,cmd)
Ejemplo n.º 39
0
Archivo: node.py Proyecto: sorenh/cc
 def _init_aoe(self):
     utils.runthis("Doin an AoE discover, returns %s", "sudo aoe-discover")
     utils.runthis("Doin an AoE stat, returns %s", "sudo aoe-stat")