// CreateMasterDummy creates a dummy network interface
424578
func CreateMasterDummy(t *testing.T, master string) {
	// ip link add <dummy_name> type dummy
	icmd.RunCommand("ip", "link", "add", master, "type", "dummy").Assert(t, icmd.Success)
	icmd.RunCommand("ip", "link", "set", master, "up").Assert(t, icmd.Success)
}
1307473
func createMacVlan(containerIfName, parent, macvlanMode string) (string, error) {
	// Set the macvlan mode. Default is bridge mode
	mode, err := setMacVlanMode(macvlanMode)
	if err != nil {
		return "", fmt.Errorf("Unsupported %s macvlan mode: %v", macvlanMode, err)
	}
	// verify the Docker host interface acting as the macvlan parent iface exists
	if !parentExists(parent) {
		return "", fmt.Errorf("the requested parent interface %s was not found on the Docker host", parent)
	}
	// Get the link for the master index (Example: the docker host eth iface)
	parentLink, err := ns.NlHandle().LinkByName(parent)
	if err != nil {
		return "", fmt.Errorf("error occurred looking up the %s parent iface %s error: %s", macvlanType, parent, err)
	}
	// Create a macvlan link
	macvlan := &netlink.Macvlan{
		LinkAttrs: netlink.LinkAttrs{
			Name:        containerIfName,
			ParentIndex: parentLink.Attrs().Index,
		},
		Mode: mode,
	}
	if err := ns.NlHandle().LinkAdd(macvlan); err != nil {
		// If a user creates a macvlan and ipvlan on same parent, only one slave iface can be active at a time.
		return "", fmt.Errorf("failed to create the %s port: %v", macvlanType, err)
	}

	return macvlan.Attrs().Name, nil
}
806023
func (c *Client) CreateNetwork(regionID int, description string, subnet *net.IPNet) (Network, error) {
	var net string
	var mask int
	values := url.Values{
		"DCID":        {fmt.Sprintf("%v", regionID)},
		"description": {description},
	}
	if subnet != nil && subnet.IP.To4() != nil {
		net = subnet.IP.To4().String()
		mask, _ = subnet.Mask.Size()
		values.Add("v4_subnet", net)
		values.Add("v4_subnet_mask", fmt.Sprintf("%v", mask))
	}
	var network Network
	if err := c.post(`network/create`, values, &network); err != nil {
		return Network{}, err
	}
	network.RegionID = regionID
	network.Description = description
	network.V4Subnet = net
	network.V4SubnetMask = mask

	return network, nil
}
247900
func CreateVlanInterface(t *testing.T, master, slave, id string) {
	// ip link add link <master> name <master>.<VID> type vlan id <VID>
	icmd.RunCommand("ip", "link", "add", "link", master, "name", slave, "type", "vlan", "id", id).Assert(t, icmd.Success)
	// ip link set <sub_interface_name> up
	icmd.RunCommand("ip", "link", "set", slave, "up").Assert(t, icmd.Success)
}
376168
func createNet(d *Daemon, w http.ResponseWriter, r *http.Request) *HttpErr {
	if r.Body == nil {
		return &HttpErr{http.StatusBadRequest, "request body is empty"}
	}

	network := &Network{}
	err := json.NewDecoder(r.Body).Decode(network)

	if err != nil {
		return &HttpErr{http.StatusInternalServerError, err.Error()}
	}

	_, cidr, err := net.ParseCIDR(network.Subnet)

	if err != nil {
		return &HttpErr{http.StatusInternalServerError, err.Error()}
	}

	newNet, err := CreateNetwork(network.Name, cidr)

	if err != nil {
		return &HttpErr{http.StatusInternalServerError, err.Error()}
	}

	data, _ := json.Marshal(newNet)

	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	w.Write(data)

	return nil
}
809794
func (b *BigIP) CreateVirtualServer(name, destination, mask, pool string, port int) error {
	subnetMask := cidr[mask]

	if strings.Contains(mask, ".") {
		subnetMask = mask
	}

	config := &VirtualServer{
		Name:        name,
		Destination: fmt.Sprintf("%s:%d", destination, port),
		Mask:        subnetMask,
		Pool:        pool,
	}

	return b.post(config, uriLtm, uriVirtual)
}
1207870
func (c *SentinelClient) Master(name string) *StringStringMapCmd {
	cmd := NewStringStringMapCmd("sentinel", "master", name)
	c.Process(cmd)
	return cmd
}
1108433
func (d *MasterDaemon) getMasterInfo() (map[string]interface{}, error) {
	info := make(map[string]interface{})

	// get local ip
	localIP, err := netutils.GetDefaultAddr()
	if err != nil {
		return nil, errors.New("error getting local IP address")
	}

	// get current holder of master lock
	leader := leaderLock.GetHolder()
	if leader == "" {
		return nil, errors.New("leader not found")
	}

	// Get all netplugin services
	srvList, err := d.objdbClient.GetService("netplugin")
	if err != nil {
		log.Errorf("Error getting netplugin nodes. Err: %v", err)
		return nil, err
	}

	// Add each node
	pluginNodes := []string{}
	for _, srv := range srvList {
		pluginNodes = append(pluginNodes, srv.HostAddr)
	}

	// Get all netmaster services
	srvList, err = d.objdbClient.GetService("netmaster")
	if err != nil {
		log.Errorf("Error getting netmaster nodes. Err: %v", err)
		return nil, err
	}

	// Add each node
	masterNodes := []string{}
	for _, srv := range srvList {
		masterNodes = append(masterNodes, srv.HostAddr)
	}

	// setup info map
	info["local-ip"] = localIP
	info["leader-ip"] = leader
	info["current-state"] = d.currState
	info["netplugin-nodes"] = pluginNodes
	info["netmaster-nodes"] = masterNodes

	return info, nil
}
494800
func (u *FakeAPIUtil) CreateJob(job *batch_v1.Job) error {
	u.CreatedJobs[job.Namespace+"/"+job.Name] = job
	return nil
}
6794
func (c *Client) PutMaster(name string, client *redis.Client) {
	c.putCh <- &putReq{name, client}
}
38021
func putMasterKeyParams(ns walletdb.ReadWriteBucket, pubParams, privParams []byte) error {
	bucket := ns.NestedReadWriteBucket(mainBucketName)

	if privParams != nil {
		err := bucket.Put(masterPrivKeyName, privParams)
		if err != nil {
			str := "failed to store master private key parameters"
			return managerError(ErrDatabase, str, err)
		}
	}

	if pubParams != nil {
		err := bucket.Put(masterPubKeyName, pubParams)
		if err != nil {
			str := "failed to store master public key parameters"
			return managerError(ErrDatabase, str, err)
		}
	}

	return nil
}
1321438
func (agent *ActionAgent) InitMaster(ctx context.Context) (string, error) {
	if err := agent.lock(ctx); err != nil {
		return "", err
	}
	defer agent.unlock()

	// Initializing as master implies undoing any previous "do not replicate".
	agent.setSlaveStopped(false)

	// we need to insert something in the binlogs, so we can get the
	// current position. Let's just use the mysqlctl.CreateReparentJournal commands.
	cmds := mysqlctl.CreateReparentJournal()
	if err := agent.MysqlDaemon.ExecuteSuperQueryList(ctx, cmds); err != nil {
		return "", err
	}

	// get the current replication position
	pos, err := agent.MysqlDaemon.MasterPosition()
	if err != nil {
		return "", err
	}

	// If using semi-sync, we need to enable it before going read-write.
	if err := agent.fixSemiSync(topodatapb.TabletType_MASTER); err != nil {
		return "", err
	}

	// Set the server read-write, from now on we can accept real
	// client writes. Note that if semi-sync replication is enabled,
	// we'll still need some slaves to be able to commit transactions.
	startTime := time.Now()
	if err := agent.MysqlDaemon.SetReadOnly(false); err != nil {
		return "", err
	}
	agent.setExternallyReparentedTime(startTime)

	// Change our type to master if not already
	if _, err := agent.TopoServer.UpdateTabletFields(ctx, agent.TabletAlias, func(tablet *topodatapb.Tablet) error {
		tablet.Type = topodatapb.TabletType_MASTER
		return nil
	}); err != nil {
		return "", err
	}

	// and refresh our state
	agent.initReplication = true
	if err := agent.refreshTablet(ctx, "InitMaster"); err != nil {
		return "", err
	}
	return mysql.EncodePosition(pos), nil
}
1360729
func (d *Driver) Create() error {
	log.Info("Creating machine...")
	log.Info("Creating network...")
	err := d.createNetwork()
	if err != nil {
		return errors.Wrap(err, "creating network")
	}
	if d.GPU {
		log.Info("Creating devices...")
		d.DevicesXML, err = getDevicesXML()
		if err != nil {
			return errors.Wrap(err, "creating devices")
		}
	}

	log.Info("Setting up minikube home directory...")
	if err := os.MkdirAll(d.ResolveStorePath("."), 0755); err != nil {
		return errors.Wrap(err, "Error making store path directory")
	}

	for dir := d.ResolveStorePath("."); dir != "/"; dir = filepath.Dir(dir) {
		info, err := os.Stat(dir)
		if err != nil {
			return err
		}
		mode := info.Mode()
		if mode&0011 != 1 {
			log.Debugf("Setting executable bit set on %s", dir)
			mode |= 0011
			os.Chmod(dir, mode)
		}
	}

	log.Info("Building disk image...")
	if err = pkgdrivers.MakeDiskImage(d.BaseDriver, d.Boot2DockerURL, d.DiskSize); err != nil {
		return errors.Wrap(err, "Error creating disk")
	}

	log.Info("Creating domain...")
	dom, err := d.createDomain()
	if err != nil {
		return errors.Wrap(err, "creating domain")
	}
	defer dom.Free()

	log.Debug("Finished creating machine, now starting machine...")
	return d.Start()
}
562552
func (c *FakeHelmReleases) Create(helmRelease *v1beta1.HelmRelease) (result *v1beta1.HelmRelease, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewCreateAction(helmreleasesResource, c.ns, helmRelease), &v1beta1.HelmRelease{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1beta1.HelmRelease), err
}
1321741
func (pm *Manager) createPlugin(name string, configDigest digest.Digest, blobsums []digest.Digest, rootFSDir string, privileges *types.PluginPrivileges, opts ...CreateOpt) (p *v2.Plugin, err error) {
	if err := pm.config.Store.validateName(name); err != nil { // todo: this check is wrong. remove store
		return nil, errdefs.InvalidParameter(err)
	}

	config, err := pm.setupNewPlugin(configDigest, blobsums, privileges)
	if err != nil {
		return nil, err
	}

	p = &v2.Plugin{
		PluginObj: types.Plugin{
			Name:   name,
			ID:     stringid.GenerateRandomID(),
			Config: config,
		},
		Config:   configDigest,
		Blobsums: blobsums,
	}
	p.InitEmptySettings()
	for _, o := range opts {
		o(p)
	}

	pdir := filepath.Join(pm.config.Root, p.PluginObj.ID)
	if err := os.MkdirAll(pdir, 0700); err != nil {
		return nil, errors.Wrapf(err, "failed to mkdir %v", pdir)
	}

	defer func() {
		if err != nil {
			os.RemoveAll(pdir)
		}
	}()

	if err := os.Rename(rootFSDir, filepath.Join(pdir, rootFSFileName)); err != nil {
		return nil, errors.Wrap(err, "failed to rename rootfs")
	}

	if err := pm.save(p); err != nil {
		return nil, err
	}

	pm.config.Store.Add(p) // todo: remove

	return p, nil
}
252796
func (zs *Server) NewMasterParticipation(name, id string) (topo.MasterParticipation, error) {
	ctx := context.TODO()

	zkPath := path.Join(zs.root, electionsPath, name)

	// Create the toplevel directory, OK if it exists already.
	// We will create the parent directory as well, but not more.
	if _, err := CreateRecursive(ctx, zs.conn, zkPath, nil, 0, zk.WorldACL(PermDirectory), 1); err != nil && err != zk.ErrNodeExists {
		return nil, convertError(err, zkPath)
	}

	result := &zkMasterParticipation{
		zs:   zs,
		name: name,
		id:   []byte(id),
		done: make(chan struct{}),
	}
	result.stopCtx, result.stopCtxCancel = context.WithCancel(context.Background())
	return result, nil
}
1107328
func (r Network_Storage) CreateFolder(folder *string) (resp bool, err error) {
	params := []interface{}{
		folder,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Storage", "createFolder", params, &r.Options, &resp)
	return
}